asdfsadf
Browse files
app.py
CHANGED
|
@@ -123,34 +123,43 @@ def answer_question(question):
|
|
| 123 |
|
| 124 |
import gradio as gr
|
| 125 |
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
history
|
| 132 |
-
return
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
]
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
|
| 156 |
if __name__ == "__main__":
|
|
|
|
| 123 |
|
| 124 |
import gradio as gr
|
| 125 |
|
| 126 |
+
import gradio as gr
|
| 127 |
+
|
| 128 |
+
def answer_question(user_input, history):
|
| 129 |
+
answer = "This is the answer about SGCS..." # Replace with actual LLM output
|
| 130 |
+
history.append({"role": "user", "content": user_input})
|
| 131 |
+
history.append({"role": "assistant", "content": answer})
|
| 132 |
+
return "", history
|
| 133 |
+
|
| 134 |
+
with gr.Blocks(title="π Inha University SGCS Info Assistant") as demo:
|
| 135 |
+
gr.Markdown("## π Inha University SGCS Info Assistant")
|
| 136 |
+
gr.Markdown("Get answers to your questions about Inha University SGCS.")
|
| 137 |
+
|
| 138 |
+
chatbot = gr.Chatbot(label="π Answer", type="messages") # β
Fixed type
|
| 139 |
+
with gr.Row():
|
| 140 |
+
textbox = gr.Textbox(
|
| 141 |
+
placeholder="e.g. How many Major Required credits should I take for graduation?",
|
| 142 |
+
label="Ask me anything about Inha University SGCSβ¦",
|
| 143 |
+
lines=2
|
| 144 |
+
)
|
| 145 |
+
send_btn = gr.Button("Send")
|
| 146 |
+
|
| 147 |
+
history = gr.State([])
|
| 148 |
+
|
| 149 |
+
send_btn.click(fn=answer_question, inputs=[textbox, history], outputs=[textbox, chatbot])
|
| 150 |
+
textbox.submit(fn=answer_question, inputs=[textbox, history], outputs=[textbox, chatbot])
|
| 151 |
+
|
| 152 |
+
gr.Examples(
|
| 153 |
+
examples=[
|
| 154 |
+
"What classes should I normally take as 3rd semester ISE student?",
|
| 155 |
+
"Tell me about student organizations and activities",
|
| 156 |
+
"What percentage scholarship could I receive with IELTS 7.0"
|
| 157 |
+
],
|
| 158 |
+
inputs=textbox
|
| 159 |
+
)
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
|
| 163 |
|
| 164 |
|
| 165 |
if __name__ == "__main__":
|