sudo-soldier commited on
Commit
ab73e6b
·
verified ·
1 Parent(s): 31c9373

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -1,10 +1,9 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
-
5
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
6
 
7
-
8
  def respond(
9
  message,
10
  history: list[tuple[str, str]],
@@ -13,20 +12,20 @@ def respond(
13
  temperature,
14
  top_p,
15
  ):
16
-
17
  messages = [{"role": "system", "content": system_message}]
18
-
19
-
20
  for user_msg, assistant_msg in history:
21
  if user_msg:
22
  messages.append({"role": "user", "content": user_msg})
23
  if assistant_msg:
24
  messages.append({"role": "assistant", "content": assistant_msg})
25
 
26
-
27
  messages.append({"role": "user", "content": message})
28
 
29
-
30
  response = ""
31
  for message in client.chat_completion(
32
  messages,
@@ -39,7 +38,7 @@ def respond(
39
  response += token
40
  yield response
41
 
42
-
43
  demo = gr.ChatInterface(
44
  fn=respond,
45
  additional_inputs=[
@@ -48,8 +47,8 @@ demo = gr.ChatInterface(
48
  "Your name is Jesse. You are a highly professional, results-driven AI assistant. "
49
  "You are a CompTIA Tech+ certified technician with a bachelor's degree in Information Technology. "
50
  "You specialize in networking, IT support, cybersecurity, and troubleshooting. "
51
- "Do not use humor or casual language. Focus on providing accurate, concise, and actionable technical assistance. "
52
- "Always refer to yourself as Jesse."
53
  ),
54
  label="System message"
55
  ),
@@ -62,6 +61,7 @@ demo = gr.ChatInterface(
62
  theme="default"
63
  )
64
 
 
65
  if __name__ == "__main__":
66
  demo.launch()
67
 
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
+ # Initialize Hugging Face model
5
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
6
 
 
7
  def respond(
8
  message,
9
  history: list[tuple[str, str]],
 
12
  temperature,
13
  top_p,
14
  ):
15
+ # Initialize messages with the system message (Jesse's identity)
16
  messages = [{"role": "system", "content": system_message}]
17
+
18
+ # Add previous chat history to the message stream
19
  for user_msg, assistant_msg in history:
20
  if user_msg:
21
  messages.append({"role": "user", "content": user_msg})
22
  if assistant_msg:
23
  messages.append({"role": "assistant", "content": assistant_msg})
24
 
25
+ # Append the latest user message
26
  messages.append({"role": "user", "content": message})
27
 
28
+ # Generate and stream the response
29
  response = ""
30
  for message in client.chat_completion(
31
  messages,
 
38
  response += token
39
  yield response
40
 
41
+ # Gradio UI configuration
42
  demo = gr.ChatInterface(
43
  fn=respond,
44
  additional_inputs=[
 
47
  "Your name is Jesse. You are a highly professional, results-driven AI assistant. "
48
  "You are a CompTIA Tech+ certified technician with a bachelor's degree in Information Technology. "
49
  "You specialize in networking, IT support, cybersecurity, and troubleshooting. "
50
+ "Do not use humor or casual language. Respond succinctly and in a tone similar to a certified IT helpdesk technician. "
51
+ "Focus on providing accurate, concise, and actionable technical assistance. Always refer to yourself as Jesse."
52
  ),
53
  label="System message"
54
  ),
 
61
  theme="default"
62
  )
63
 
64
+ # Launch the interface
65
  if __name__ == "__main__":
66
  demo.launch()
67