test commited on
Commit
fb64db4
1 Parent(s): ec5af7e

fix: responsive font-size

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +23 -5
  3. static/app.css +17 -0
.gitignore CHANGED
@@ -160,3 +160,4 @@ cython_debug/
160
  #.idea/
161
 
162
  .vscode
 
 
160
  #.idea/
161
 
162
  .vscode
163
+ prompts.py
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
  import uuid
3
- from typing import Dict, List, Optional, Tuple
 
4
 
5
  import gradio as gr
6
  import requests
@@ -108,14 +109,21 @@ def get_chat_id():
108
  return str(uuid.uuid4())
109
 
110
 
111
- with gr.Blocks() as demo:
 
 
 
112
  chat_id = gr.State(value=get_chat_id)
113
  history_en = gr.State(value=[])
114
- history_bo = gr.Chatbot(label="Tibetan Chatbot").style(height=650)
 
 
115
  input_bo = gr.Textbox(
116
  show_label=False,
117
- placeholder=f"Type a message here and press enter",
 
118
  )
 
119
  input_bo.submit(
120
  fn=user,
121
  inputs=[input_bo, history_bo],
@@ -126,8 +134,18 @@ with gr.Blocks() as demo:
126
  inputs=[history_bo, chat_id],
127
  outputs=[history_bo],
128
  )
 
 
 
 
 
 
 
 
 
 
129
 
130
- clear = gr.Button("New Chat")
131
  clear.click(lambda: [], None, history_bo, queue=False)
132
 
133
  demo.launch()
 
1
  import os
2
  import uuid
3
+ from pathlib import Path
4
+ from typing import Dict, List, Tuple
5
 
6
  import gradio as gr
7
  import requests
 
109
  return str(uuid.uuid4())
110
 
111
 
112
+ css_fn = Path(__file__).resolve().parent / "static" / "app.css"
113
+ assert css_fn.exists() and css_fn.is_file(), f"CSS file not found: {css_fn}"
114
+
115
+ with gr.Blocks(css=str(css_fn)) as demo:
116
  chat_id = gr.State(value=get_chat_id)
117
  history_en = gr.State(value=[])
118
+ history_bo = gr.Chatbot(label="Tibetan Chatbot", elem_id="maiChatHistory").style(
119
+ height=650
120
+ )
121
  input_bo = gr.Textbox(
122
  show_label=False,
123
+ placeholder="Type here...",
124
+ elem_id="maiChatInput",
125
  )
126
+ input_submit_btn = gr.Button("Submit")
127
  input_bo.submit(
128
  fn=user,
129
  inputs=[input_bo, history_bo],
 
134
  inputs=[history_bo, chat_id],
135
  outputs=[history_bo],
136
  )
137
+ input_submit_btn.click(
138
+ fn=user,
139
+ inputs=[input_bo, history_bo],
140
+ outputs=[input_bo, history_bo],
141
+ queue=False,
142
+ ).then(
143
+ fn=bot,
144
+ inputs=[history_bo, chat_id],
145
+ outputs=[history_bo],
146
+ )
147
 
148
+ clear = gr.Button("Clear")
149
  clear.click(lambda: [], None, history_bo, queue=False)
150
 
151
  demo.launch()
static/app.css ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #maiChatHistory .message-wrap div {
2
+ font-size: 30px;
3
+ }
4
+
5
+ #maiChatInput textarea {
6
+ font-size: 30px
7
+ }
8
+
9
+ @media screen and (min-width: 768px) {
10
+ #maiChatInput textarea {
11
+ font-size: 20px
12
+ }
13
+
14
+ #maiChatHistory .message-wrap div {
15
+ font-size: 20px;
16
+ }
17
+ }