Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -51,20 +51,28 @@ def predict(message, history):
|
|
51 |
question = message
|
52 |
context = "" # Add context if
|
53 |
|
54 |
-
# Create a RetrievalQA instance
|
55 |
-
chain = RetrievalQA.from_chain_type(
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
)
|
62 |
|
63 |
-
# Execute the query
|
64 |
-
result = chain({"query": question})
|
65 |
|
66 |
-
# Stream the response
|
67 |
-
partial_message = ""
|
68 |
-
for chunk in result['result']:
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
question = message
|
52 |
context = "" # Add context if
|
53 |
|
54 |
+
# Create a RetrievalQA instance
|
55 |
+
chain = RetrievalQA.from_chain_type(
|
56 |
+
llm=llm,
|
57 |
+
chain_type="stuff",
|
58 |
+
retriever=retriever,
|
59 |
+
return_source_documents=True,
|
60 |
+
chain_type_kwargs={"prompt": QA_CHAIN_PROMPT}
|
61 |
+
)
|
62 |
|
63 |
+
# Execute the query
|
64 |
+
result = chain({"query": question})
|
65 |
|
66 |
+
# Stream the response
|
67 |
+
partial_message = ""
|
68 |
+
for chunk in result['result']:
|
69 |
+
partial_message += chunk
|
70 |
+
yield partial_message
|
71 |
+
|
72 |
+
gr.Interface(
|
73 |
+
fn=predict,
|
74 |
+
inputs=[gr.inputs.Textbox(label="Your Message"), gr.inputs.State(label="History")],
|
75 |
+
outputs='text',
|
76 |
+
live=True,
|
77 |
+
allow_flagging="never"
|
78 |
+
).launch()
|