ReputAgent commited on
Commit
3c9499e
·
verified ·
1 Parent(s): b7bc550

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -26
app.py CHANGED
@@ -1,30 +1,21 @@
1
  import gradio as gr
2
- from huggingface_hub import InferenceClient
3
 
4
- SYSTEM_PROMPT = """You are a skilled business negotiation agent. You represent
5
- your client's interests
6
- firmly but fairly. You analyze proposals carefully, identify leverage points,
7
- and make strategic
8
- counter-offers. You are professional, articulate, and always working toward the
9
- best possible deal
10
- for your side. When given a role and scenario, you stay in character throughout
11
- the conversation."""
12
 
13
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- def respond(message, history):
16
- messages = [{"role": "system", "content": SYSTEM_PROMPT}]
17
- for h in history:
18
- messages.append({"role": "user", "content": h[0]})
19
- if h[1]:
20
- messages.append({"role": "assistant", "content": h[1]})
21
- messages.append({"role": "user", "content": message})
22
-
23
- response = ""
24
- for token in client.chat_completion(messages, max_tokens=512, stream=True):
25
- delta = token.choices[0].delta.content or ""
26
- response += delta
27
- return response
28
-
29
- demo = gr.ChatInterface(respond, title="Negotiation Agent")
30
- demo.launch()
 
1
  import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
 
4
+ SYSTEM_PROMPT = "You are a skilled business negotiation agent. You represent your client's interests firmly but fairly. You analyze proposals carefully, identify leverage points, and make strategic counter-offers. You are professional, articulate, and always working toward the best possible deal for your side. When given a role and scenario, you stay in character throughout the conversation."
5
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
 
 
 
 
 
 
6
 
7
+ def respond(message, history):
8
+ messages = [{"role": "system", "content": SYSTEM_PROMPT}]
9
+ for h in history:
10
+ messages.append({"role": "user", "content": h[0]})
11
+ if h[1]:
12
+ messages.append({"role": "assistant", "content": h[1]})
13
+ messages.append({"role": "user", "content": message})
14
+ response = ""
15
+ for token in client.chat_completion(messages, max_tokens=512, stream=True):
16
+ delta = token.choices[0].delta.content or ""
17
+ response += delta
18
+ return response
19
 
20
+ demo = gr.ChatInterface(respond, title="Negotiation Agent")
21
+ demo.launch()