Pengi5659 commited on
Commit
29d4f0b
·
verified ·
1 Parent(s): c8ed1b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -65
app.py CHANGED
@@ -1,90 +1,26 @@
1
 
2
 
3
  import gradio as gr
4
-
5
-
6
  import random as rd
7
-
8
-
9
  from huggingface_hub import InferenceClient
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
  client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
18
-
19
-
20
  def respond (message, history):
21
-
22
-
23
  messages = [{"role": "system", "content": "You are a chatbot who is sassy and doesnt explain an anser unless someone asks twice."}]
24
-
25
-
26
-
27
-
28
  if history:
29
-
30
-
31
- messages.extend(history)
32
-
33
-
34
  messages.append({"role": "user", "content": message})
35
-
36
-
37
  response = ""
38
-
39
-
40
  for message in client.chat_completion(
41
-
42
-
43
  messages,
44
-
45
-
46
  max_tokens=500,
47
-
48
-
49
  temperature=0.2,
50
-
51
-
52
  top_p=0.9,
53
-
54
-
55
  stream=True
56
-
57
-
58
  ):
59
-
60
-
61
  token = message.choices[0].delta.content
62
-
63
-
64
  response += token
65
-
66
-
67
  yield response
68
 
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
- chatbot = gr.ChatInterface(respond, type = "messages")
77
-
78
-
79
- chatbot.launch(debug=True)
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
  # Define the Gradio interface
89
  css = """
90
  .gradio-container {
@@ -92,6 +28,10 @@ css = """
92
  font-family: 'Times New Roman', Times, serif;
93
  }
94
  """
 
 
 
 
95
 
96
 
97
 
 
1
 
2
 
3
  import gradio as gr
 
 
4
  import random as rd
 
 
5
  from huggingface_hub import InferenceClient
 
 
 
 
 
 
 
6
  client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
 
 
7
  def respond (message, history):
 
 
8
  messages = [{"role": "system", "content": "You are a chatbot who is sassy and doesnt explain an anser unless someone asks twice."}]
 
 
 
 
9
  if history:
10
+ messages.extend(history)
 
 
 
 
11
  messages.append({"role": "user", "content": message})
 
 
12
  response = ""
 
 
13
  for message in client.chat_completion(
 
 
14
  messages,
 
 
15
  max_tokens=500,
 
 
16
  temperature=0.2,
 
 
17
  top_p=0.9,
 
 
18
  stream=True
 
 
19
  ):
 
 
20
  token = message.choices[0].delta.content
 
 
21
  response += token
 
 
22
  yield response
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  # Define the Gradio interface
25
  css = """
26
  .gradio-container {
 
28
  font-family: 'Times New Roman', Times, serif;
29
  }
30
  """
31
+ chatbot = gr.ChatInterface(respond, type = "messages")
32
+ chatbot.launch(debug=True)
33
+
34
+
35
 
36
 
37