ysharma HF staff commited on
Commit
9e2e59a
1 Parent(s): 0426b89

update api url

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -1,7 +1,8 @@
1
  import time
2
  import gradio as gr
3
 
4
- API_URL = "https://joi-20b.ngrok.io/generate_stream"
 
5
 
6
  def predict(inputs, top_p, temperature, top_k, repetition_penalty, history=[]):
7
  if not inputs.startswith("User: "):
@@ -44,7 +45,7 @@ def predict(inputs, top_p, temperature, top_k, repetition_penalty, history=[]):
44
 
45
  yield chat, history #resembles {chatbot: chat, state: history}
46
 
47
- title = """<h1 align="center">Gradio Streaming</h1>"""
48
  description = """Language models can be conditioned to act like dialogue agents through a conversational prompt that typically takes the form:
49
  ```
50
  User: <utterance>
@@ -58,8 +59,8 @@ In this app, you can explore the outputs of the Joi alpha language models.
58
 
59
  with gr.Blocks(css = "#chatbot {height: 400px, overflow: auto;}") as demo:
60
  gr.HTML(title)
61
- inputs = gr.Textbox(placeholder= "Hi my name is Joe.", label= "Type an input and press Enter") #t
62
  chatbot = gr.Chatbot(elem_id='chatbot') #c
 
63
  state = gr.State([]) #s
64
  b1 = gr.Button()
65
 
@@ -75,6 +76,6 @@ with gr.Blocks(css = "#chatbot {height: 400px, overflow: auto;}") as demo:
75
  inputs.submit( predict, [inputs, top_p, temperature, top_k, repetition_penalty, state], [chatbot, state],)
76
  b1.click( predict, [inputs, top_p, temperature, top_k, repetition_penalty, state], [chatbot, state],)
77
 
78
- gr.HTML(description)
79
  demo.queue().launch(debug=True)
80
 
 
1
  import time
2
  import gradio as gr
3
 
4
+ #Streaming endpoint
5
+ API_URL = os.getenv("API_URL") + "/generate_stream"
6
 
7
  def predict(inputs, top_p, temperature, top_k, repetition_penalty, history=[]):
8
  if not inputs.startswith("User: "):
 
45
 
46
  yield chat, history #resembles {chatbot: chat, state: history}
47
 
48
+ title = """<h1 align="center">Gradio Supports Streaming</h1>"""
49
  description = """Language models can be conditioned to act like dialogue agents through a conversational prompt that typically takes the form:
50
  ```
51
  User: <utterance>
 
59
 
60
  with gr.Blocks(css = "#chatbot {height: 400px, overflow: auto;}") as demo:
61
  gr.HTML(title)
 
62
  chatbot = gr.Chatbot(elem_id='chatbot') #c
63
+ inputs = gr.Textbox(placeholder= "Hi my name is Joe.", label= "Type an input and press Enter") #t
64
  state = gr.State([]) #s
65
  b1 = gr.Button()
66
 
 
76
  inputs.submit( predict, [inputs, top_p, temperature, top_k, repetition_penalty, state], [chatbot, state],)
77
  b1.click( predict, [inputs, top_p, temperature, top_k, repetition_penalty, state], [chatbot, state],)
78
 
79
+ gr.Markdown(description)
80
  demo.queue().launch(debug=True)
81