Jankidepala commited on
Commit
3c0a4dd
·
verified ·
1 Parent(s): 36710f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -65
app.py CHANGED
@@ -1,70 +1,8 @@
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
  from transformers import pipeline
9
 
10
  messages = [
11
  {"role": "user", "content": "Who are you?"},
12
  ]
13
- pipe = pipeline("text-generation", model="pentagoniac/SEMIKONG-70B")
14
- pipe(messages)
15
-
16
- def respond(
17
- message,
18
- history: list[tuple[str, str]],
19
- system_message,
20
- max_tokens,
21
- temperature,
22
- top_p,
23
- ):
24
- messages = [{"role": "system", "content": system_message}]
25
-
26
- for val in history:
27
- if val[0]:
28
- messages.append({"role": "user", "content": val[0]})
29
- if val[1]:
30
- messages.append({"role": "assistant", "content": val[1]})
31
-
32
- messages.append({"role": "user", "content": message})
33
-
34
- response = ""
35
-
36
- for message in client.chat_completion(
37
- messages,
38
- max_tokens=max_tokens,
39
- stream=True,
40
- temperature=temperature,
41
- top_p=top_p,
42
- ):
43
- token = message.choices[0].delta.content
44
-
45
- response += token
46
- yield response
47
-
48
-
49
- """
50
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
51
- """
52
- demo = gr.ChatInterface(
53
- respond,
54
- additional_inputs=[
55
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
56
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
57
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
58
- gr.Slider(
59
- minimum=0.1,
60
- maximum=1.0,
61
- value=0.95,
62
- step=0.05,
63
- label="Top-p (nucleus sampling)",
64
- ),
65
- ],
66
- )
67
-
68
-
69
- if __name__ == "__main__":
70
- demo.launch()
 
1
+ # Use a pipeline as a high-level helper
 
 
 
 
 
 
2
  from transformers import pipeline
3
 
4
  messages = [
5
  {"role": "user", "content": "Who are you?"},
6
  ]
7
+ pipe = pipeline("text-generation", model="pentagoniac/SEMIKONG-8b-GPTQ ")
8
+ pipe(messages)