freddyaboulton HF staff commited on
Commit
3ab75c1
1 Parent(s): 2e74f63

Add app code

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -31,8 +31,6 @@ def format_chat_prompt(message: str, chat_history, instructions: str) -> str:
31
 
32
 
33
 
34
-
35
-
36
  def run_chat(message: str, chat_history):
37
  prompt = format_chat_prompt(message, chat_history, DEFAULT_INSTRUCTIONS)
38
  chat_history = chat_history + [[message, ""]]
@@ -43,7 +41,7 @@ def run_chat(message: str, chat_history):
43
  stop_sequences=[STOP_STR, "<|endoftext|>"],
44
  temperature=0.8,
45
  top_p=0.9,
46
- )
47
  chat_history[-1][1] = response
48
  return response, chat_history
49
 
@@ -60,12 +58,14 @@ with gr.Blocks() as demo:
60
  pip install gradio_client
61
  ```
62
 
 
63
  grc.Client.duplicate("gradio-discord-bots/falcon-7b-instruct", private=False, secrets={"HF_TOKEN": "<your-key-here>", "INFERENCE_ENDPOINT": "<endpoint-url>"}).deploy_discord()
 
64
  """)
65
  button = gr.Button(visible=False)
66
  history = gr.State([])
67
- message = gr.Textbox()
68
- response = gr.Textbox()
69
  button.click(run_chat, [message, history], [response, history], api_name="chat")
70
 
71
 
 
31
 
32
 
33
 
 
 
34
  def run_chat(message: str, chat_history):
35
  prompt = format_chat_prompt(message, chat_history, DEFAULT_INSTRUCTIONS)
36
  chat_history = chat_history + [[message, ""]]
 
41
  stop_sequences=[STOP_STR, "<|endoftext|>"],
42
  temperature=0.8,
43
  top_p=0.9,
44
+ ).generated_text.replace("\nUser:", "")
45
  chat_history[-1][1] = response
46
  return response, chat_history
47
 
 
58
  pip install gradio_client
59
  ```
60
 
61
+ ```python
62
  grc.Client.duplicate("gradio-discord-bots/falcon-7b-instruct", private=False, secrets={"HF_TOKEN": "<your-key-here>", "INFERENCE_ENDPOINT": "<endpoint-url>"}).deploy_discord()
63
+ ```
64
  """)
65
  button = gr.Button(visible=False)
66
  history = gr.State([])
67
+ message = gr.Textbox(visible=False)
68
+ response = gr.Textbox(visible=False)
69
  button.click(run_chat, [message, history], [response, history], api_name="chat")
70
 
71