asfasdf3
Browse files
app.py
CHANGED
|
@@ -106,27 +106,11 @@ def rag_answer(question: str, collection) -> str:
|
|
| 106 |
context = retrieve_context(question, collection, top_k=2)
|
| 107 |
return generate_agent_answer(context, question)
|
| 108 |
|
| 109 |
-
|
| 110 |
-
def answer_question(question):
|
| 111 |
-
"""
|
| 112 |
-
Main function that processes the question and returns the answer
|
| 113 |
-
"""
|
| 114 |
-
if not question.strip():
|
| 115 |
-
return "Please enter a question about Inha University."
|
| 116 |
-
|
| 117 |
-
try:
|
| 118 |
-
answer = rag_answer(question, collection)
|
| 119 |
-
return answer
|
| 120 |
-
except Exception as e:
|
| 121 |
-
return f"Sorry, I encountered an error: {str(e)}"
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
import gradio as gr
|
| 125 |
-
|
| 126 |
-
import gradio as gr
|
| 127 |
|
| 128 |
def answer_question(user_input, history):
|
| 129 |
-
answer =
|
|
|
|
| 130 |
history.append({"role": "user", "content": user_input})
|
| 131 |
history.append({"role": "assistant", "content": answer})
|
| 132 |
return "", history
|
|
|
|
| 106 |
context = retrieve_context(question, collection, top_k=2)
|
| 107 |
return generate_agent_answer(context, question)
|
| 108 |
|
| 109 |
+
# gradio interface code below
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
def answer_question(user_input, history):
|
| 112 |
+
answer = rag_answer(question, collection)
|
| 113 |
+
|
| 114 |
history.append({"role": "user", "content": user_input})
|
| 115 |
history.append({"role": "assistant", "content": answer})
|
| 116 |
return "", history
|