Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -145,30 +145,18 @@ def get_conversational_rag_chain(retriever_chain):
|
|
| 145 |
|
| 146 |
return create_retrieval_chain(retriever_chain, stuff_documents_chain)
|
| 147 |
|
| 148 |
-
def get_response(user_input):
|
| 149 |
-
retriever_chain = get_context_retriever_chain(st.session_state.vector_store)
|
| 150 |
-
conversation_rag_chain = get_conversational_rag_chain(retriever_chain)
|
| 151 |
-
|
| 152 |
-
response = conversation_rag_chain.invoke({
|
| 153 |
-
"chat_history": st.session_state.chat_history,
|
| 154 |
-
"input": user_query
|
| 155 |
-
})
|
| 156 |
|
| 157 |
return response
|
| 158 |
|
| 159 |
-
app = FastAPI()
|
| 160 |
|
| 161 |
-
@app.post("/generate/")
|
| 162 |
-
def generate(user_input):
|
| 163 |
-
retriever_chain = get_context_retriever_chain(st.session_state.vector_store)
|
| 164 |
-
conversation_rag_chain = get_conversational_rag_chain(retriever_chain)
|
| 165 |
-
|
| 166 |
-
response = conversation_rag_chain.invoke({
|
| 167 |
-
"chat_history": [],
|
| 168 |
-
"input": user_query
|
| 169 |
-
})
|
| 170 |
-
|
| 171 |
-
return response
|
| 172 |
|
| 173 |
###################
|
| 174 |
|
|
@@ -210,6 +198,18 @@ def get_response(user_input):
|
|
| 210 |
return last_part
|
| 211 |
|
| 212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
def history_to_dialog_format(chat_history: list[str]):
|
| 214 |
dialog = []
|
| 215 |
if len(chat_history) > 0:
|
|
|
|
| 145 |
|
| 146 |
return create_retrieval_chain(retriever_chain, stuff_documents_chain)
|
| 147 |
|
| 148 |
+
#def get_response(user_input):
|
| 149 |
+
# retriever_chain = get_context_retriever_chain(st.session_state.vector_store)
|
| 150 |
+
# conversation_rag_chain = get_conversational_rag_chain(retriever_chain)
|
| 151 |
+
#
|
| 152 |
+
# response = conversation_rag_chain.invoke({
|
| 153 |
+
# "chat_history": st.session_state.chat_history,
|
| 154 |
+
# "input": user_query
|
| 155 |
+
# })
|
| 156 |
|
| 157 |
return response
|
| 158 |
|
|
|
|
| 159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
###################
|
| 162 |
|
|
|
|
| 198 |
return last_part
|
| 199 |
|
| 200 |
|
| 201 |
+
###############
|
| 202 |
+
|
| 203 |
+
from fastapi import FastAPI
|
| 204 |
+
|
| 205 |
+
app = FastAPI()
|
| 206 |
+
|
| 207 |
+
@app.post("/generate/")
|
| 208 |
+
def generate(user_input):
|
| 209 |
+
print("----yuhu -----")
|
| 210 |
+
return get_response(user_input)
|
| 211 |
+
##################
|
| 212 |
+
|
| 213 |
def history_to_dialog_format(chat_history: list[str]):
|
| 214 |
dialog = []
|
| 215 |
if len(chat_history) > 0:
|