Spaces:
Sleeping
Sleeping
Yingxu He
commited on
Commit
·
ae714e8
1
Parent(s):
064bcd7
Update app.py
Browse files
app.py
CHANGED
@@ -15,9 +15,18 @@ from langchain.embeddings import OpenAIEmbeddings
|
|
15 |
from langchain.vectorstores import Chroma
|
16 |
|
17 |
from langchain.chains import ConversationalRetrievalChain
|
|
|
18 |
|
19 |
os.environ['OPENAI_API_KEY'] = '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'
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
def loading_pdf():
|
22 |
return "Loading..."
|
23 |
|
@@ -34,6 +43,7 @@ def pdf_changes():
|
|
34 |
qa = ConversationalRetrievalChain.from_llm(
|
35 |
llm=OpenAI(temperature=0.5),
|
36 |
retriever=retriever,
|
|
|
37 |
return_source_documents=False)
|
38 |
return "Ready"
|
39 |
|
|
|
15 |
from langchain.vectorstores import Chroma
|
16 |
|
17 |
from langchain.chains import ConversationalRetrievalChain
|
18 |
+
from langchain.prompts.prompt import PromptTemplate
|
19 |
|
20 |
os.environ['OPENAI_API_KEY'] = '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'
|
21 |
|
22 |
+
_template = """Assume you are He Yingxu, please complete the following conversations:
|
23 |
+
Chat History:
|
24 |
+
{chat_history}
|
25 |
+
Follow Up Input: {question}
|
26 |
+
"""
|
27 |
+
|
28 |
+
CUSTOM_QUESTION_PROMPT = PromptTemplate.from_template(_template)
|
29 |
+
|
30 |
def loading_pdf():
|
31 |
return "Loading..."
|
32 |
|
|
|
43 |
qa = ConversationalRetrievalChain.from_llm(
|
44 |
llm=OpenAI(temperature=0.5),
|
45 |
retriever=retriever,
|
46 |
+
condense_question_prompt=CUSTOM_QUESTION_PROMPT,
|
47 |
return_source_documents=False)
|
48 |
return "Ready"
|
49 |
|