freddyaboulton HF staff commited on
Commit
94f6ac7
·
1 Parent(s): 1890c65

Use chatinterface

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -47,8 +47,9 @@ def generate(
47
  response = f'The accumulated input is too long ({input_token_length} > {MAX_INPUT_TOKEN_LENGTH}). Please create a new thread.'
48
  else:
49
  response = run(message, history, system_prompt, max_new_tokens, temperature, top_p, top_k)
50
- return response, history + [(message, response)]
51
 
 
52
 
53
  with gr.Blocks() as demo:
54
 
@@ -67,17 +68,13 @@ with gr.Blocks() as demo:
67
  ```python
68
  secrets = {"HUGGING_FACE_HUB_TOKEN": "<your-key-here>",}
69
  client = grc.Client.duplicate("gradio-discord-bots/llama-2-13b-chat-transformers", secrets=secrets, hardware="a10g-small")
70
- client.deploy_discord(api_names=["chat"])
71
  ```
72
  """
73
  )
74
 
75
  gr.Markdown(LICENSE)
76
  with gr.Row(visible=False):
77
- state = gr.State([])
78
- msg = gr.Textbox()
79
- output = gr.Textbox()
80
- btn = gr.Button()
81
- btn.click(generate, [msg, state], [output, state], api_name="chat")
82
 
83
  demo.queue(max_size=20).launch()
 
47
  response = f'The accumulated input is too long ({input_token_length} > {MAX_INPUT_TOKEN_LENGTH}). Please create a new thread.'
48
  else:
49
  response = run(message, history, system_prompt, max_new_tokens, temperature, top_p, top_k)
50
+ return response
51
 
52
+ interface = gr.ChatInterface(generate)
53
 
54
  with gr.Blocks() as demo:
55
 
 
68
  ```python
69
  secrets = {"HUGGING_FACE_HUB_TOKEN": "<your-key-here>",}
70
  client = grc.Client.duplicate("gradio-discord-bots/llama-2-13b-chat-transformers", secrets=secrets, hardware="a10g-small")
71
+ client.deploy_discord(api_names=["chat"], hf_token="<your-key-here>")
72
  ```
73
  """
74
  )
75
 
76
  gr.Markdown(LICENSE)
77
  with gr.Row(visible=False):
78
+ interface.render()
 
 
 
 
79
 
80
  demo.queue(max_size=20).launch()