Jasur05 commited on
Commit
6be21fc
Β·
verified Β·
1 Parent(s): 4d9fdc7
Files changed (1) hide show
  1. app.py +37 -28
app.py CHANGED
@@ -123,34 +123,43 @@ def answer_question(question):
123
 
124
  import gradio as gr
125
 
126
- def answer_question(message, history):
127
- history = history + [[message, ""]]
128
-
129
- # Replace this with your real logic / LLM call
130
- response = "Here is the answer about SGCS..." # ← Dummy response
131
- history[-1][1] = response
132
- return history, history
133
-
134
- # Define interface as chatbot-style inside Interface-like wrapper
135
- chat_interface = gr.ChatInterface(
136
- fn=answer_question,
137
- chatbot=gr.Chatbot(label="πŸ“š Inha University SGCS Info Assistant"),
138
- textbox=gr.Textbox(
139
- label="Ask me anything about Inha University SGCS…",
140
- placeholder="e.g. How many Major Required credits should I take for graduation?",
141
- lines=2
142
- ),
143
- title="πŸ“š Inha University SGCS Info Assistant",
144
- description="Get answers to your questions about Inha University SGCS.",
145
- theme=gr.themes.Soft(),
146
- examples=[
147
- "What classes should I normally take as 3rd semester ISE student?",
148
- "Tell me about student organizations and activities",
149
- "What percentage scholarship could I receive with IELTS 7.0"
150
- ]
151
- )
152
-
153
- demo = chat_interface
 
 
 
 
 
 
 
 
 
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__":