go back to just one time chat
Browse files
app.py
CHANGED
|
@@ -106,42 +106,41 @@ def rag_answer(question: str, collection) -> str:
|
|
| 106 |
return generate_agent_answer(context, question)
|
| 107 |
|
| 108 |
# gradio interface code below
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
]
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
|
| 146 |
|
| 147 |
|
|
|
|
| 106 |
return generate_agent_answer(context, question)
|
| 107 |
|
| 108 |
# gradio interface code below
|
| 109 |
+
def answer_question(question):
|
| 110 |
+
"""
|
| 111 |
+
Main function that processes the question and returns the answer
|
| 112 |
+
"""
|
| 113 |
+
if not question.strip():
|
| 114 |
+
return "Please enter a question about Inha University."
|
| 115 |
+
|
| 116 |
+
try:
|
| 117 |
+
answer = rag_answer(question, collection)
|
| 118 |
+
return answer
|
| 119 |
+
except Exception as e:
|
| 120 |
+
return f"Sorry, I encountered an error: {str(e)}"
|
| 121 |
+
|
| 122 |
+
# βββ 6. Gradio Frontend βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 123 |
+
# Create the Gradio interface
|
| 124 |
+
demo = gr.Interface(
|
| 125 |
+
fn=answer_question,
|
| 126 |
+
inputs=gr.Textbox(
|
| 127 |
+
label="Ask me anything about Inha University SGCSβ¦",
|
| 128 |
+
placeholder="e.g. How many Major Required credits should I take for graduation? ",
|
| 129 |
+
lines=2
|
| 130 |
+
),
|
| 131 |
+
outputs=gr.Markdown(
|
| 132 |
+
label="π Answer",
|
| 133 |
+
show_copy_button=True
|
| 134 |
+
),
|
| 135 |
+
title="π Inha University SGCS Info Assistant",
|
| 136 |
+
description="Get answers to your questions about Inha University SGCS .",
|
| 137 |
+
theme=gr.themes.Soft(),
|
| 138 |
+
examples=[
|
| 139 |
+
["What classes should I normally take as 3nd semester ISE student?"],
|
| 140 |
+
["Tell me about student organizations and activities"],
|
| 141 |
+
["What percentage scholarship could I recieve with IELTS 7.0"]
|
| 142 |
+
]
|
| 143 |
+
)
|
|
|
|
| 144 |
|
| 145 |
|
| 146 |
|