timbosssds commited on
Commit
a64a0da
·
verified ·
1 Parent(s): e23d8ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -41
app.py CHANGED
@@ -23,47 +23,47 @@
23
  import gradio as gr
24
  from huggingface_hub import InferenceClient
25
 
26
- """
27
- 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
28
- """
29
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
30
-
31
-
32
- def respond(
33
- message,
34
- history: list[tuple[str, str]],
35
- system_message,
36
- max_tokens,
37
- temperature,
38
- top_p,
39
- ):
40
- messages = [{"role": "system", "content": system_message}]
41
-
42
- for val in history:
43
- if val[0]:
44
- messages.append({"role": "user", "content": val[0]})
45
- if val[1]:
46
- messages.append({"role": "assistant", "content": val[1]})
47
-
48
- messages.append({"role": "user", "content": message})
49
-
50
- response = ""
51
-
52
- for message in client.chat_completion(
53
- messages,
54
- max_tokens=max_tokens,
55
- stream=True,
56
- temperature=temperature,
57
- top_p=top_p,
58
- ):
59
- token = message.choices[0].delta.content
60
-
61
- response += token
62
- yield response
63
-
64
- """
65
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
66
- """
67
  demo = gr.ChatInterface(
68
  respond,
69
  additional_inputs=[
 
23
  import gradio as gr
24
  from huggingface_hub import InferenceClient
25
 
26
+ # """
27
+ # 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
28
+ # """
29
+ # client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
30
+
31
+
32
+ # def respond(
33
+ # message,
34
+ # history: list[tuple[str, str]],
35
+ # system_message,
36
+ # max_tokens,
37
+ # temperature,
38
+ # top_p,
39
+ # ):
40
+ # messages = [{"role": "system", "content": system_message}]
41
+
42
+ # for val in history:
43
+ # if val[0]:
44
+ # messages.append({"role": "user", "content": val[0]})
45
+ # if val[1]:
46
+ # messages.append({"role": "assistant", "content": val[1]})
47
+
48
+ # messages.append({"role": "user", "content": message})
49
+
50
+ # response = ""
51
+
52
+ # for message in client.chat_completion(
53
+ # messages,
54
+ # max_tokens=max_tokens,
55
+ # stream=True,
56
+ # temperature=temperature,
57
+ # top_p=top_p,
58
+ # ):
59
+ # token = message.choices[0].delta.content
60
+
61
+ # response += token
62
+ # yield response
63
+
64
+ # """
65
+ # For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
66
+ # """
67
  demo = gr.ChatInterface(
68
  respond,
69
  additional_inputs=[