Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +5 -2
src/streamlit_app.py
CHANGED
|
@@ -107,9 +107,12 @@ parser = StrOutputParser()
|
|
| 107 |
|
| 108 |
def create_rag_chain(retriever, model, prompt):
|
| 109 |
def fetch_context(user_input):
|
|
|
|
|
|
|
| 110 |
docs = retriever.get_relevant_documents(user_input)
|
| 111 |
-
|
| 112 |
-
return {"context":
|
|
|
|
| 113 |
|
| 114 |
chain = fetch_context | prompt | model | parser
|
| 115 |
return chain
|
|
|
|
| 107 |
|
| 108 |
def create_rag_chain(retriever, model, prompt):
|
| 109 |
def fetch_context(user_input):
|
| 110 |
+
if isinstance(user_input, dict):
|
| 111 |
+
user_input = user_input.get("question", "")
|
| 112 |
docs = retriever.get_relevant_documents(user_input)
|
| 113 |
+
context_text = "\n\n".join(doc.page_content for doc in docs)
|
| 114 |
+
return {"context": context_text, "question": user_input}
|
| 115 |
+
|
| 116 |
|
| 117 |
chain = fetch_context | prompt | model | parser
|
| 118 |
return chain
|