This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install scikit-learn numpy ollama | |
import ollama | |
import numpy as np | |
from sklearn.metrics.pairwise import cosine_similarity | |
text1 = ollama.embeddings(model='nomic-embed-text', prompt='The sky is blue because of rayleigh scattering') | |
text2 = ollama.embeddings(model='nomic-embed-text', prompt='The sky is cloudy and grey today') | |
vec1 = np.array(text1['embedding']).reshape(1, -1) | |
vec2 = np.array(text2['embedding']).reshape(1, -1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import requests | |
from langchain.llms import Ollama | |
from langchain.document_loaders import WebBaseLoader | |
from langchain.text_splitter import RecursiveCharacterTextSplitter | |
from langchain.embeddings import GPT4AllEmbeddings | |
from langchain.vectorstores import Chroma | |
from langchain.chains import RetrievalQA | |
def main(args): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install chromadb==0.4.15 # need to pin to this version for current langchain version | |
from langchain.llms import Ollama | |
from langchain.document_loaders import WebBaseLoader | |
from langchain.text_splitter import RecursiveCharacterTextSplitter | |
from langchain.embeddings import GPT4AllEmbeddings | |
from langchain.vectorstores import Chroma | |
from langchain.chains import RetrievalQA | |
ollama = Ollama(base_url='http://localhost:11434', model='zephyr:latest') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.express as px | |
import matplotlib.pyplot as plt | |
from collections import Counter | |
import re | |
import sys | |
import nltk | |
from nltk.corpus import stopwords | |
def plot_word_frequencies_matplot(file_path, top): | |
# Load stop words |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import requests | |
from bs4 import BeautifulSoup | |
from urllib.parse import urljoin, urlparse | |
def is_valid(url, base_url): | |
parsed = urlparse(url) | |
return bool(parsed.netloc) and parsed.netloc == urlparse(base_url).netloc | |
def is_binary(url): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from langchain.chat_models import ChatOllama | |
from langchain.callbacks.manager import CallbackManager | |
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler | |
from langchain.schema import HumanMessage | |
chat_model = ChatOllama(model="mistral", base_url = "http://localhost:11434", callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])) | |
#chat_model = ChatOllama(model="mistral") | |
messages = [ | |
HumanMessage(content="Why is the sky blue?") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sentence_transformers import SentenceTransformer | |
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') | |
embeddings = model.encode("A fat tuxedo cat") | |
print(embeddings) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sentence_transformers import SentenceTransformer, util | |
model = SentenceTransformer('all-MiniLM-L6-v2') | |
# Two lists of sentences | |
sentences1 = ['The cat sits outside', | |
'A man is playing guitar', | |
'The new movie is awesome', | |
'Jim can run very fast', | |
'My goldfish is hungry'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
def main(): | |
organizations_client = boto3.client("organizations") | |
list_accounts_object = organizations_client.list_accounts() | |
all_accounts = [] | |
accounts = list_accounts_object["Accounts"] | |
while "NextToken" in list_accounts_object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os, socket, sys, time | |
socket.setdefaulttimeout(10) | |
start = time.time() | |
subnets = ['140.107.42','140.107.43','140.107.88','140.107.89','140.107.134',\ | |
'140.107.135','140.107.52','140.107.53','140.107.152','140.107.153',\ | |
'140.107.170','140.107.171'] | |
scanips = []; hosts = []; vhosts = []; free = []; vfree = []; reclaim = []; squatters = [] |
NewerOlder