Migu3low commited on
Commit
e9fad31
1 Parent(s): edeb481

Update original

Browse files
Files changed (1) hide show
  1. app.py +2 -22
app.py CHANGED
@@ -5,7 +5,7 @@ from huggingface_hub import InferenceClient
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
 
8
- client = InferenceClient("meta-llama/Meta-Llama-3-8B")
9
 
10
 
11
  def respond(
@@ -40,32 +40,12 @@ def respond(
40
  response += token
41
  yield response
42
 
43
- def chat_function(message, history, system_prompt, max_new_tokens, temperature):
44
- messages = [{"role":"system","content":system_prompt},
45
- {"role":"user", "content":message}]
46
- prompt = pipeline.tokenizer.apply_chat_template(
47
- messages,
48
- tokenize=False,
49
- add_generation_prompt=True,)
50
- terminators = [
51
- pipeline.tokenizer.eos_token_id,
52
- pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")]
53
- outputs = pipeline(
54
- prompt,
55
- max_new_tokens = max_new_tokens,
56
- eos_token_id = terminators,
57
- do_sample = True,
58
- temperature = temperature + 0.1,
59
- top_p = 0.9,)
60
- return outputs[0]["generated_text"][len(prompt):]
61
-
62
-
63
  """
64
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
65
  """
66
 
67
  demo = gr.ChatInterface(
68
- chat_function,
69
  textbox=gr.Textbox(placeholder="Enter message here", container=False, scale = 7),
70
  chatbot=gr.Chatbot(height=400),
71
  additional_inputs=[
 
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
 
8
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
9
 
10
 
11
  def respond(
 
40
  response += token
41
  yield response
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  """
44
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
45
  """
46
 
47
  demo = gr.ChatInterface(
48
+ respond,
49
  textbox=gr.Textbox(placeholder="Enter message here", container=False, scale = 7),
50
  chatbot=gr.Chatbot(height=400),
51
  additional_inputs=[