Skip to content

Commit

Permalink
tutorial67
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed May 23, 2024
1 parent 41eb426 commit 5605bb7
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file added tutorial67/chroma_db/chroma.sqlite3
Binary file not shown.
14 changes: 14 additions & 0 deletions tutorial67/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from langchain_community.document_loaders import PyPDFLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_chroma import Chroma
from langchain_openai import OpenAIEmbeddings


loader=PyPDFLoader("C:\\Users\\welcome\\OneDrive\\Documents\\GitHub\LLMtutorial\\tutorial67\\manual.pdf")
docs=loader.load()
print(docs)
text_splitter=RecursiveCharacterTextSplitter(chunk_size=1000,chunk_overlap=50)
chunked_documents=text_splitter.split_documents(docs)
vectordb=Chroma.from_documents(
docs, OpenAIEmbeddings(), persist_directory="./chroma_db"
)
Binary file added tutorial67/manual.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions tutorial67/prompt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
You are an intelligent help desk agent specializing in printers.
Answer user queries {input} related to printers based strictly on the provided {context}.
Do not make assumptions or provide information not included in the context.
If no information found in the {context} just reply sorry answer not known
"""
5 changes: 5 additions & 0 deletions tutorial67/qsn.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
how to use Epson Smart Panel Mobile App
Using Epson RemotePrint
i want to connect to a New Wi-Fi Router help me
how to print photos
i want to play football how to do this
31 changes: 31 additions & 0 deletions tutorial67/rag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from langchain_community.vectorstores import Chroma
from langchain_openai import ChatOpenAI,OpenAIEmbeddings
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
import streamlit as st
import os
st.title("help desk agent for printers")
st.write("printer help desk")

vectordb=Chroma(persist_directory=os.getcwd()+"/chroma_db",embedding_function=OpenAIEmbeddings())
prompt_template="""
You are an intelligent help desk agent specializing in printers.
Answer user queries {input} related to printers based strictly on the provided {context}.
Do not make assumptions or provide information not included in the {context}.
"""
llm=ChatOpenAI(model="gpt-4o",max_tokens=1024)
qa_chain=LLMChain(llm=llm,prompt=PromptTemplate.from_template(prompt_template))
question=st.text_area("ask your question")

if question is not None:
button=st.button("submit")
if button:
rd=vectordb.similarity_search(question,k=5)
context=""
for d in rd:
context +=d.page_content
print(context)
response=qa_chain.invoke({"input":question,"context":context})
result=response["text"]
print(result)
st.write(result)
Binary file added tutorial67/tutorial67.pptx
Binary file not shown.

0 comments on commit 5605bb7

Please sign in to comment.