Spaces:
Runtime error
Runtime error
Commit ·
2c8b688
1
Parent(s): 0c57d6d
Update main.py
Browse files
main.py
CHANGED
|
@@ -10,7 +10,7 @@ from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
|
|
| 10 |
from langchain.chains import LLMChain
|
| 11 |
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
|
| 12 |
from langchain.schema import StrOutputParser
|
| 13 |
-
from langchain.chains.conversational_retrieval.prompts import CONDENSE_QUESTION_PROMPT
|
| 14 |
from langchain.chains.question_answering import load_qa_chain
|
| 15 |
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
|
| 16 |
from langchain.vectorstores import Pinecone
|
|
@@ -138,7 +138,15 @@ async def start():
|
|
| 138 |
)
|
| 139 |
|
| 140 |
os.environ['ANTHROPIC_API_KEY'] = os.environ['ANTHROPIC_API_KEY']
|
|
|
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 60,"filter": {'categorie': {'$eq': 'OF'}}})
|
| 143 |
########## Chain with streaming ##########
|
| 144 |
message_history = ChatMessageHistory()
|
|
|
|
| 10 |
from langchain.chains import LLMChain
|
| 11 |
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
|
| 12 |
from langchain.schema import StrOutputParser
|
| 13 |
+
#from langchain.chains.conversational_retrieval.prompts import CONDENSE_QUESTION_PROMPT
|
| 14 |
from langchain.chains.question_answering import load_qa_chain
|
| 15 |
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
|
| 16 |
from langchain.vectorstores import Pinecone
|
|
|
|
| 138 |
)
|
| 139 |
|
| 140 |
os.environ['ANTHROPIC_API_KEY'] = os.environ['ANTHROPIC_API_KEY']
|
| 141 |
+
from langchain_core.prompts.prompt import PromptTemplate
|
| 142 |
|
| 143 |
+
_template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question, in its original language.
|
| 144 |
+
|
| 145 |
+
Chat History:
|
| 146 |
+
{chat_history}
|
| 147 |
+
Follow Up Input: {question}
|
| 148 |
+
Standalone question:"""
|
| 149 |
+
CONDENSE_QUESTION_PROMPT = PromptTemplate.from_template(_template)
|
| 150 |
retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 60,"filter": {'categorie': {'$eq': 'OF'}}})
|
| 151 |
########## Chain with streaming ##########
|
| 152 |
message_history = ChatMessageHistory()
|