Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,13 +52,7 @@ chat_prompt = ChatPromptTemplate.from_messages([
|
|
| 52 |
|
| 53 |
chat_model = ChatOpenAI(model="gpt-4o-mini")
|
| 54 |
set_llm_cache(InMemoryCache())
|
| 55 |
-
|
| 56 |
-
retrieval_augmented_qa_chain = (
|
| 57 |
-
{"context": itemgetter("question") | retriever, "question": itemgetter("question")}
|
| 58 |
-
| RunnablePassthrough.assign(context=itemgetter("context"))
|
| 59 |
-
| chat_prompt | chat_model
|
| 60 |
-
)
|
| 61 |
-
|
| 62 |
|
| 63 |
### On Chat Start (Session Start) Section ###
|
| 64 |
@cl.on_chat_start
|
|
@@ -114,18 +108,17 @@ async def on_chat_start():
|
|
| 114 |
vectorstore.add_documents(docs)
|
| 115 |
retriever = vectorstore.as_retriever(search_type="mmr", search_kwargs={"k": 3})
|
| 116 |
|
| 117 |
-
chat_openai = ChatOpenAI()
|
| 118 |
-
|
| 119 |
# Create a chain
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
|
|
|
| 123 |
)
|
| 124 |
|
| 125 |
# Let the user know that the system is ready
|
| 126 |
msg.content = f"Processing `{file.name}` done. You can now ask questions!"
|
| 127 |
await msg.update()
|
| 128 |
-
cl.user_session.set("chain",
|
| 129 |
|
| 130 |
|
| 131 |
### Rename Chains ###
|
|
|
|
| 52 |
|
| 53 |
chat_model = ChatOpenAI(model="gpt-4o-mini")
|
| 54 |
set_llm_cache(InMemoryCache())
|
| 55 |
+
chat_openai = ChatOpenAI()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
### On Chat Start (Session Start) Section ###
|
| 58 |
@cl.on_chat_start
|
|
|
|
| 108 |
vectorstore.add_documents(docs)
|
| 109 |
retriever = vectorstore.as_retriever(search_type="mmr", search_kwargs={"k": 3})
|
| 110 |
|
|
|
|
|
|
|
| 111 |
# Create a chain
|
| 112 |
+
retrieval_augmented_qa_chain = (
|
| 113 |
+
{"context": itemgetter("question") | retriever, "question": itemgetter("question")}
|
| 114 |
+
| RunnablePassthrough.assign(context=itemgetter("context"))
|
| 115 |
+
| chat_prompt | chat_model
|
| 116 |
)
|
| 117 |
|
| 118 |
# Let the user know that the system is ready
|
| 119 |
msg.content = f"Processing `{file.name}` done. You can now ask questions!"
|
| 120 |
await msg.update()
|
| 121 |
+
cl.user_session.set("chain", retrieval_augmented_qa_chain)
|
| 122 |
|
| 123 |
|
| 124 |
### Rename Chains ###
|