-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+5.99 MB
tutorial67/chroma_db/ce71682d-7dbe-4328-bcd4-59bd9db0b70a/data_level0.bin
Binary file not shown.
Binary file added
BIN
+100 Bytes
tutorial67/chroma_db/ce71682d-7dbe-4328-bcd4-59bd9db0b70a/header.bin
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
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
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 not shown.
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
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 | ||
""" |
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
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 |
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
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 not shown.