From fd5a86535359c166993b9db95a271d3dfaaaa1ee Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 2 Dec 2024 10:04:23 +0100 Subject: [PATCH] more examples and demos --- .DS_Store | Bin 6148 -> 8196 bytes .gitignore | 6 +- LangChain/Haikus.docx | Bin 0 -> 14865 bytes LangChain/Haikus.pdf | Bin 0 -> 31706 bytes LangChain/caching.py | 37 ++++++++++ LangChain/caching_2.py | 41 +++++++++++ LangChain/langgraph_agents.py | 57 +++++++++++++++ LangChain/litellm_demo.py | 47 +++++++++++++ LangChain/pdf_reader.py | 81 ++++++++++++++++++++++ LangChain/tempCodeRunnerFile.py | 1 + LangChain/token_counting.py | 16 +++++ LangChain/toxic.py | 28 ++++++++ LangChain/website_summarizer.py | 53 ++++++++++++++ ollama/.DS_Store | Bin 6148 -> 6148 bytes ollama/ollama_langchain/basic_chatting.py | 33 +++++++++ 15 files changed, 399 insertions(+), 1 deletion(-) create mode 100644 LangChain/Haikus.docx create mode 100644 LangChain/Haikus.pdf create mode 100644 LangChain/caching.py create mode 100644 LangChain/caching_2.py create mode 100644 LangChain/langgraph_agents.py create mode 100644 LangChain/litellm_demo.py create mode 100644 LangChain/pdf_reader.py create mode 100644 LangChain/tempCodeRunnerFile.py create mode 100644 LangChain/token_counting.py create mode 100644 LangChain/toxic.py create mode 100644 LangChain/website_summarizer.py create mode 100644 ollama/ollama_langchain/basic_chatting.py diff --git a/.DS_Store b/.DS_Store index 22ece38ec4de8000fb32369cdb3931ec1951b892..8643fdd8c1354e5b64b7ef6cf00d650832a61a15 100644 GIT binary patch delta 500 zcmZoMXmOBWU|?W$DortDU;r^WfEYvza8E20o2aKKDh!eb@);PM88R3W88R92JaaY+ za)_~PR^aGmUd+zHF|mQg5TuNg!3U@yk0BjdX?}82PJR-|M4&mcKw9rV7)&-`k>E)x zFD`&e@0`S1s3BQhZDwhtqhM%ZYFMkIP;F^sprc@7Y*t&#$sww&Zygk$os*lF-#vL6 zt2|@RWF8h}W`UO9lVeyUCVR1Pu_=0T<)5mX9L1snW45rUG7Ba!Og3N>+kA*+C!?VN zLoP!;(2XfTGM^zHNGCFs0I?oJ7DF*e#xn=S#od!z!NQCP z2bQs0=yEayF}N}~GPp4K0%<*<{V8a6{6vJx#=<*Hg3LfZ5J+$X30F{50E7EG^JIPz Z&&mEg92~&d0L2o+?wzdz1hG delta 187 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5r;6q~50D9R6#2a7o~WH2N$WHRLCq;D)- z&dkU^*i+1h|2OE6Dzhh2NPc^UHXGT*JTwaT&<544dP5 H<}d>QKj|lz diff --git a/.gitignore b/.gitignore index 97a08f8..1524196 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,8 @@ LangChain/lib LangChain/share LangChain/pyvenv.cfg mondoo_data.json -mondoo_prompt_output.txt \ No newline at end of file +mondoo_prompt_output.txt +.langchain.db +.DS_Store +ollama/ollama_langchain/.env +ollama/.DS_Store diff --git a/LangChain/Haikus.docx b/LangChain/Haikus.docx new file mode 100644 index 0000000000000000000000000000000000000000..7345bb5e620d9e5044910cbbe81c0736d7e62c1e GIT binary patch literal 14865 zcmeIZbxa`Zv0J_Ly_HoFv#MGyntu3IG5Q1GWlgEj2&@03vVz02KfQswrq=?Pz4} z_)W>p*2qEov#XUQQQjv|svH35$Myev{12XihJ~5Y>J%(hE4uaR$oizj!tYTRuBf##{RfTMHtzP{EPr}wMRe{O=7ePnfrGpg23Mx zOxq8gn_$VC1C z_GuGtFYPlO(?^KXQ-$6RKh4*I4#^F z78}s9reL{l_frSUs~O=1KkRNn%<}j6hBm7$D}R`60~n9ze6-WW7EPug@2qmZ;*T7x zy;wbh0RZpsU;w$lEJ=b`oaW09Ig|NVaj+jt@|(Spr33KuAM}5h;{V|F_or8{i0d`) zXMp>98Sok~(<#5&iTQ*;Md*xnU2Gu^+6CIzOi=TFP$PjVb zPSC!>Nm7On?}T1_(&^WH>2L)k26YrNx-Q!8!lfVF8^4Z`ic^mTM5v>OPvJnsK8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= zZoZOlUTdJkG#G4N#KTPhV+;X*e!PIrF_}cdNI1r!f7upFIL|+A2pQ;3FkU~|P!yEW|gG2n7aezl05I<%d2!R;~&=7{y zh2TISIKUo-OgI4VGut3I!1g7~eh?hsZkpK-f&;?m2-y6QsV;=i5eT0nC~a`vt=12!zkUb62LiD1^^Z2%m$8fRMV( z?^h_8|NeU3z^4o#Hf9_sgwIh3pQB*D&(sEl&rt}UqYyqv!TwCY#skyqUu`rDjQd~a z-QY str: + response = completion(model=model_name, messages=[{"role": "user", "content": prompt}]) + return response.choices[0].message.content + +st.title("Multi-Model Chat") + +# Model selection +model_option = st.selectbox( + "Choose a language model:", + ("gpt-3.5-turbo", "ollama/llama2", "gpt-4o") +) + +# Initialize session state for chat history +if 'chat_history' not in st.session_state: + st.session_state['chat_history'] = [] + +# User input +user_input = st.text_input("You:") + +# Send button +if st.button("Send"): + if openai_api_key or user_input: + # Append user message to chat history + st.session_state['chat_history'].append({"role": "user", "content": user_input}) + + # Generate response using the selected model + with st.spinner("Thinking..."): + response = get_model_response(model_name=model_option, prompt=user_input) + + # Append model response to chat history + st.session_state['chat_history'].append({"role": "model", "content": response}) + +# Display chat history in reverse order +for message in reversed(st.session_state['chat_history']): + if message['role'] == 'user': + st.write(f"You: {message['content']}") + else: + st.write(f"Model: {message['content']}") diff --git a/LangChain/pdf_reader.py b/LangChain/pdf_reader.py new file mode 100644 index 0000000..aef6229 --- /dev/null +++ b/LangChain/pdf_reader.py @@ -0,0 +1,81 @@ +import os +from dotenv import load_dotenv +import streamlit as st +from langchain.chat_models import ChatOpenAI +from langchain.chains import ConversationalRetrievalChain +from langchain.memory import ConversationBufferMemory +from langchain.document_loaders import PyPDFLoader +from langchain.vectorstores import Chroma +from langchain.embeddings.openai import OpenAIEmbeddings +from langchain.text_splitter import CharacterTextSplitter +import tempfile + +# Load API key +load_dotenv() +openai_api_key = os.getenv('OPENAI_API_KEY') + +# Load and process PDF +@st.cache_resource +def load_and_process_pdf(pdf_file): + # Create a temporary file + with tempfile.NamedTemporaryFile(delete=False) as tmp_file: + tmp_file.write(pdf_file.getvalue()) + tmp_file_path = tmp_file.name + + loader = PyPDFLoader(tmp_file_path) + documents = loader.load() + text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) + texts = text_splitter.split_documents(documents) + embeddings = OpenAIEmbeddings() + vectorstore = Chroma.from_documents(texts, embeddings) + + # Remove the temporary file + os.unlink(tmp_file_path) + + return vectorstore + +# Conversation chain +def get_conversation_chain(vectorstore): + llm = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo", api_key=openai_api_key) + memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True) + conversation_chain = ConversationalRetrievalChain.from_llm( + llm=llm, + retriever=vectorstore.as_retriever(), + memory=memory + ) + return conversation_chain + +# Handle user input +def handle_user_input(user_question): + response = st.session_state.conversation({'question': user_question}) + st.session_state.chat_history = response['chat_history'] + + for i, message in enumerate(st.session_state.chat_history): + if i % 2 == 0: + st.write("Human: " + message.content) + else: + st.write("AI: " + message.content) + +# Handle application +def main(): + st.set_page_config(page_title="Chat with your PDF", page_icon=":books:") + st.header("Chat with your PDF:") + + if "conversation" not in st.session_state: + st.session_state.conversation = None + if "chat_history" not in st.session_state: + st.session_state.chat_history = None + + uploaded_file = st.file_uploader("Choose a PDF file", type="pdf") + if uploaded_file is not None: + with st.spinner("Processing PDF..."): + vectorstore = load_and_process_pdf(uploaded_file) + st.session_state.conversation = get_conversation_chain(vectorstore) + st.success("PDF processed successfully!") + + user_question = st.text_input("Ask a question about your PDF:") + if user_question: + handle_user_input(user_question) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/LangChain/tempCodeRunnerFile.py b/LangChain/tempCodeRunnerFile.py new file mode 100644 index 0000000..1db657b --- /dev/null +++ b/LangChain/tempCodeRunnerFile.py @@ -0,0 +1 @@ +boto3 \ No newline at end of file diff --git a/LangChain/token_counting.py b/LangChain/token_counting.py new file mode 100644 index 0000000..95cecbb --- /dev/null +++ b/LangChain/token_counting.py @@ -0,0 +1,16 @@ +from langchain.chat_models import ChatOpenAI +from langchain.callbacks import get_openai_callback +import os +from dotenv import load_dotenv + +# Load environment variables +load_dotenv() +openai_api_key = os.getenv('OPENAI_API_KEY') + +# Initialize model +llm = ChatOpenAI(model_name="gpt-3.5-turbo", openai_api_key=openai_api_key) + +with get_openai_callback() as callback: + llm.invoke("What is AI?") + +print(callback) \ No newline at end of file diff --git a/LangChain/toxic.py b/LangChain/toxic.py new file mode 100644 index 0000000..2dec3cc --- /dev/null +++ b/LangChain/toxic.py @@ -0,0 +1,28 @@ + +from transformers import ( + AutoModelForSequenceClassification, + AutoTokenizer, + TextClassificationPipeline, +) + +_toxicity_model_path = "martin-ha/toxic-comment-model" + +model_path = _toxicity_model_path +_toxicity_tokenizer = AutoTokenizer.from_pretrained(model_path) +model = AutoModelForSequenceClassification.from_pretrained(model_path) +_toxicity_pipeline = TextClassificationPipeline( + model=model, tokenizer=_toxicity_tokenizer + ) + +text="You really suck" +result = _toxicity_pipeline( + text, truncation=True, max_length=_toxicity_tokenizer.model_max_length + ) +print(result) + + +text="I love you" +result = _toxicity_pipeline( + text, truncation=True, max_length=_toxicity_tokenizer.model_max_length + ) +print(result) \ No newline at end of file diff --git a/LangChain/website_summarizer.py b/LangChain/website_summarizer.py new file mode 100644 index 0000000..1897a2b --- /dev/null +++ b/LangChain/website_summarizer.py @@ -0,0 +1,53 @@ +import os +from dotenv import load_dotenv +from langchain_openai import ChatOpenAI +from langchain.chains import LLMChain +from langchain.prompts import PromptTemplate +from langchain.document_loaders import WebBaseLoader +from langchain.text_splitter import CharacterTextSplitter +from langchain.vectorstores import Chroma +from langchain.embeddings.openai import OpenAIEmbeddings + +# load api key +load_dotenv() +openai_api_key = os.getenv('OPENAI_API_KEY') + +def create_vectorstore(url): + loader = WebBaseLoader(url) + documents = loader.load() + + text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) + texts = text_splitter.split_documents(documents) + + embeddings = OpenAIEmbeddings() + return Chroma.from_documents(texts, embeddings) + +def summarize_url(url): + vectorstore = create_vectorstore(url) + + llm = ChatOpenAI(model_name="gpt-3.5-turbo", + temperature=0.2, + api_key=openai_api_key) + + prompt_template = """Write a concise summary of the following text: + + {text} + + CONCISE SUMMARY:""" + + prompt = PromptTemplate(template=prompt_template, input_variables=["text"]) + chain = LLMChain(llm=llm, prompt=prompt) + + docs = vectorstore.similarity_search(query="", k=3) + summaries = [] + for doc in docs: + summary = chain.run(text=doc.page_content) + summaries.append(summary) + + final_summary = "\n\n".join(summaries) + return final_summary + +# Lets go +url = input("Enter a URL to summarize: ") +summary = summarize_url(url) +print(f"SUMMARY OF {url}:\n{summary}") \ No newline at end of file diff --git a/ollama/.DS_Store b/ollama/.DS_Store index 4fad4c92b6aee55530cc41e900386b3243fbb7e9..e6c10830045165c777a273d7d9b4f935660d34ce 100644 GIT binary patch delta 74 zcmZoMXffE3%)+>H@_E)m4aw?iT|+}tLmdSRvsxX6YD*&n9R(9(v)Wot4pC)&>!A4T eoZP(p?#aJcHe$WRw3(gbFFyc8P8Nay delta 24 gcmZoMXffE3%rf~R>#oVpETWrDSuZgyX5kP30CE@z5&!@I diff --git a/ollama/ollama_langchain/basic_chatting.py b/ollama/ollama_langchain/basic_chatting.py new file mode 100644 index 0000000..0e9dc46 --- /dev/null +++ b/ollama/ollama_langchain/basic_chatting.py @@ -0,0 +1,33 @@ +from langchain_community.llms import Ollama +from langchain_openai import ChatOpenAI +import os +from dotenv import load_dotenv +from langchain.chains import ConversationChain +from langchain.memory import ConversationBufferMemory + +# load api key +load_dotenv() +openai_api_key = os.getenv('OPENAI_API_KEY') + +# Initialize the LLM +#llm = Ollama(model="llama2") +llm = ChatOpenAI(model="gpt-3.5-turbo", + api_key=openai_api_key) + +# Set up the conversation memory +memory = ConversationBufferMemory() + +# Create the conversation chain +conversation = ConversationChain( + llm=llm, + memory=memory, + verbose=True +) + +# Main chat loop +while True: + user_input = input("Human: ") + if user_input.lower() == 'quit': + break + response = conversation.predict(input=user_input) + print("AI:", response) \ No newline at end of file