CJ Hauser commited on
Commit
a643f54
·
verified ·
1 Parent(s): 53466d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -1,9 +1,12 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
- import os
4
 
 
 
 
5
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
6
 
 
7
  def respond(
8
  message,
9
  history: list[tuple[str, str]],
@@ -32,15 +35,14 @@ def respond(
32
  top_p=top_p,
33
  ):
34
  token = message.choices[0].delta.content
 
35
  response += token
36
  yield response
37
 
38
- # Capture query parameter from the URL
39
- def get_query():
40
- return os.getenv("GRADIO_QUERY", "")
41
-
42
- query = get_query() # Get query input from the URL
43
 
 
 
 
44
  demo = gr.ChatInterface(
45
  respond,
46
  additional_inputs=[
@@ -55,9 +57,8 @@ demo = gr.ChatInterface(
55
  label="Top-p (nucleus sampling)",
56
  ),
57
  ],
58
- textbox=gr.Textbox(value=query, label="Your message:"), # Auto-fill with search query
59
  )
60
 
61
- if __name__ == "__main__":
62
- demo.launch()
63
 
 
 
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
 
3
 
4
+ """
5
+ For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
+ """
7
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
 
9
+
10
  def respond(
11
  message,
12
  history: list[tuple[str, str]],
 
35
  top_p=top_p,
36
  ):
37
  token = message.choices[0].delta.content
38
+
39
  response += token
40
  yield response
41
 
 
 
 
 
 
42
 
43
+ """
44
+ For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
45
+ """
46
  demo = gr.ChatInterface(
47
  respond,
48
  additional_inputs=[
 
57
  label="Top-p (nucleus sampling)",
58
  ),
59
  ],
 
60
  )
61
 
 
 
62
 
63
+ if __name__ == "__main__":
64
+ demo.launch()