Jasur05 commited on
Commit
68b3bb2
Β·
verified Β·
1 Parent(s): 7923066
Files changed (1) hide show
  1. app.py +55 -23
app.py CHANGED
@@ -107,39 +107,71 @@ def rag_answer(question: str, collection) -> str:
107
 
108
  # gradio interface code below
109
 
 
 
110
  def answer_question(user_input, history):
111
  answer = rag_answer(user_input, collection)
112
-
113
  history.append({"role": "user", "content": user_input})
114
  history.append({"role": "assistant", "content": answer})
115
  return "", history
116
 
117
- with gr.Blocks(title="πŸ“š Inha University SGCS Info Assistant") as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  gr.Markdown("## πŸ“š Inha University SGCS Info Assistant")
119
  gr.Markdown("Get answers to your questions about Inha University SGCS.")
120
 
121
- chatbot = gr.Chatbot(label="πŸ“Œ Answer", type="messages") # βœ… Fixed type
122
- with gr.Row():
123
- textbox = gr.Textbox(
124
- placeholder="e.g. How many Major Required credits should I take for graduation?",
125
- label="Ask me anything about Inha University SGCS…",
126
- lines=2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  )
128
- send_btn = gr.Button("Send")
129
-
130
- history = gr.State([])
131
-
132
- send_btn.click(fn=answer_question, inputs=[textbox, history], outputs=[textbox, chatbot])
133
- textbox.submit(fn=answer_question, inputs=[textbox, history], outputs=[textbox, chatbot])
134
-
135
- gr.Examples(
136
- examples=[
137
- "What classes should I normally take as 3rd semester ISE student?",
138
- "Tell me about student organizations and activities",
139
- "What percentage scholarship could I receive with IELTS 7.0"
140
- ],
141
- inputs=textbox
142
- )
143
 
144
 
145
 
 
107
 
108
  # gradio interface code below
109
 
110
+ import gradio as gr
111
+
112
  def answer_question(user_input, history):
113
  answer = rag_answer(user_input, collection)
 
114
  history.append({"role": "user", "content": user_input})
115
  history.append({"role": "assistant", "content": answer})
116
  return "", history
117
 
118
+ with gr.Blocks(title="πŸ“š Inha University SGCS Info Assistant", css="""
119
+ .chatbot-container {
120
+ display: flex;
121
+ flex-direction: column;
122
+ height: 100vh;
123
+ padding: 0;
124
+ margin: 0;
125
+ }
126
+
127
+ .chatbot-box {
128
+ flex-grow: 1;
129
+ overflow-y: auto;
130
+ }
131
+
132
+ .input-area {
133
+ margin-top: auto;
134
+ }
135
+
136
+ @media (max-width: 768px) {
137
+ .gr-textbox textarea {
138
+ font-size: 16px;
139
+ }
140
+
141
+ .gr-button {
142
+ font-size: 16px;
143
+ }
144
+ }
145
+ """) as demo:
146
+
147
  gr.Markdown("## πŸ“š Inha University SGCS Info Assistant")
148
  gr.Markdown("Get answers to your questions about Inha University SGCS.")
149
 
150
+ with gr.Column(elem_classes="chatbot-container"):
151
+ chatbot = gr.Chatbot(label="πŸ“Œ Answer", type="messages", elem_classes="chatbot-box")
152
+
153
+ with gr.Row(elem_classes="input-area"):
154
+ textbox = gr.Textbox(
155
+ placeholder="e.g. How many Major Required credits should I take for graduation?",
156
+ label="Ask me anything about Inha University SGCS...",
157
+ lines=2,
158
+ scale=8
159
+ )
160
+ send_btn = gr.Button("Send", scale=1)
161
+
162
+ history = gr.State([])
163
+
164
+ send_btn.click(fn=answer_question, inputs=[textbox, history], outputs=[textbox, chatbot])
165
+ textbox.submit(fn=answer_question, inputs=[textbox, history], outputs=[textbox, chatbot])
166
+
167
+ gr.Examples(
168
+ examples=[
169
+ "What classes should I normally take as 3rd semester ISE student?",
170
+ "Tell me about student organizations and activities",
171
+ "What percentage scholarship could I receive with IELTS 7.0"
172
+ ],
173
+ inputs=textbox
174
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
 
176
 
177