Subha95 commited on
Commit
b0c0a48
·
verified ·
1 Parent(s): f0b7bc3

Update chatbot_rag.py

Browse files
Files changed (1) hide show
  1. chatbot_rag.py +14 -0
chatbot_rag.py CHANGED
@@ -95,3 +95,17 @@ except Exception as e:
95
  print("❌ Failed to build QA pipeline")
96
  print("Error message:", str(e))
97
  traceback.print_exc()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  print("❌ Failed to build QA pipeline")
96
  print("Error message:", str(e))
97
  traceback.print_exc()
98
+
99
+
100
+ def get_answer(query: str) -> str:
101
+ """
102
+ Run a query against the QA pipeline and return the answer text.
103
+ """
104
+ if qa_pipeline is None:
105
+ return "⚠️ QA pipeline not initialized."
106
+
107
+ try:
108
+ result = qa_pipeline.invoke(query) # for LCEL chain
109
+ return result
110
+ except Exception as e:
111
+ return f"❌ QA run failed: {e}"