Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,7 +32,11 @@ custom_prompt = PromptTemplate(template="Context: {context}\nQ: {question}\nA:",
|
|
| 32 |
qa_chain = RetrievalQA.from_chain_type(llm=llm, chain_type="stuff", retriever=db.as_retriever(search_kwargs={"k": 2}), chain_type_kwargs={"prompt": custom_prompt})
|
| 33 |
|
| 34 |
def ask_bot_alternative(question):
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# Gradio interface
|
| 38 |
iface = gr.Interface(fn=ask_bot_alternative, inputs="text", outputs="text", title="Portfolio Chatbot")
|
|
|
|
| 32 |
qa_chain = RetrievalQA.from_chain_type(llm=llm, chain_type="stuff", retriever=db.as_retriever(search_kwargs={"k": 2}), chain_type_kwargs={"prompt": custom_prompt})
|
| 33 |
|
| 34 |
def ask_bot_alternative(question):
|
| 35 |
+
response = qa_chain.invoke({"query": question})
|
| 36 |
+
print(response) # See what the chain returns
|
| 37 |
+
# Adjust the key name accordingly
|
| 38 |
+
return response.get("result") or response.get("answer") or str(response)
|
| 39 |
+
|
| 40 |
|
| 41 |
# Gradio interface
|
| 42 |
iface = gr.Interface(fn=ask_bot_alternative, inputs="text", outputs="text", title="Portfolio Chatbot")
|