vpcom commited on
Commit
7f4ea28
1 Parent(s): 12344dc

feat: adding a textbox

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -10,9 +10,9 @@ HF_TOKEN = os.environ.get("HF_TOKEN", None)
10
  API_URL = "https://api-inference.huggingface.co/models/DataAnalyticsLab/PersianGPT-FT-Grover"
11
  BOT_NAME = "PersianGPT-FT"
12
 
13
- STOP_SEQUENCES = [] #["<|endoftext|>",">"]
14
 
15
- EXAMPLES = [
16
  ["<$غزل$@بر لبم هر ذره داغی می توان کردن"],
17
  ["<$غزل$%صائب تبریزی%"],
18
  ["<$قصاید$"],
@@ -66,7 +66,7 @@ def generate(
66
  for response in stream:
67
  output += response
68
 
69
- for stop_str in STOP_SEQUENCES:
70
  if output.endswith(stop_str):
71
  output = output[:-len(stop_str)]
72
  output = output.rstrip()
@@ -124,10 +124,17 @@ p {direction: rtl; white-space: pre-line;}
124
  """
125
 
126
  chatbot = gr.Chatbot(bubble_full_width = False)
 
 
 
 
 
 
127
  chat_interface = gr.ChatInterface(
128
  generate,
129
  chatbot=chatbot,
130
- examples=EXAMPLES,
 
131
  additional_inputs=additional_inputs
132
  )
133
 
@@ -143,4 +150,6 @@ with gr.Blocks(css=CSS) as demo:
143
  chatbot.like(vote, None, None)
144
  chat_interface.render()
145
 
 
 
146
  demo.queue(concurrency_count=100, api_open=False).launch(show_api=False) #, share=True)
 
10
  API_URL = "https://api-inference.huggingface.co/models/DataAnalyticsLab/PersianGPT-FT-Grover"
11
  BOT_NAME = "PersianGPT-FT"
12
 
13
+ stop_sequences = [] #["<|endoftext|>",">"]
14
 
15
+ examples = [
16
  ["<$غزل$@بر لبم هر ذره داغی می توان کردن"],
17
  ["<$غزل$%صائب تبریزی%"],
18
  ["<$قصاید$"],
 
66
  for response in stream:
67
  output += response
68
 
69
+ for stop_str in stop_sequences:
70
  if output.endswith(stop_str):
71
  output = output[:-len(stop_str)]
72
  output = output.rstrip()
 
124
  """
125
 
126
  chatbot = gr.Chatbot(bubble_full_width = False)
127
+ textbox = gr.Textbox(
128
+ label="textbox",
129
+ info="...Type something here",
130
+ lines=5,
131
+ value="",
132
+ )
133
  chat_interface = gr.ChatInterface(
134
  generate,
135
  chatbot=chatbot,
136
+ textbox=textbox,
137
+ examples=examples,
138
  additional_inputs=additional_inputs
139
  )
140
 
 
150
  chatbot.like(vote, None, None)
151
  chat_interface.render()
152
 
153
+ #textbox.change(fn=show_text, inputs=input, outputs=output, show_progress = True, status_tracker = None)
154
+
155
  demo.queue(concurrency_count=100, api_open=False).launch(show_api=False) #, share=True)