Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,12 +16,12 @@ def debate_respond(message, history: list[tuple[str, str]],
|
|
16 |
max_tokens=128, temperature=0.4, top_p=0.95):
|
17 |
if position is None or topic is None:
|
18 |
return f"Please fill the Debate Topic -> choose Debate Master stance -> click START"
|
19 |
-
|
20 |
# System message defining assistant behavior in a debate
|
21 |
system_message = {
|
22 |
"role": "system",
|
23 |
"content": f"You are a debate participant tasked with defending the position '{position}' on the topic '{topic}'. Your goal is to articulate your arguments with clarity, logic, and professionalism while addressing counterpoints made by the opposing side. "
|
24 |
-
f"Ensure that your responses are thoughtful, evidence-based, and persuasive. Strictly keep them concise—aim for responses that are 4 to 5 lines in a single paragraph."
|
25 |
f"Analyze user arguments critically and provide respectful but firm counterarguments. Avoid dismissive language and focus on strengthening your case through logic, data, and examples relevant to the topic."
|
26 |
f"Stay consistent with your assigned position ('{position}'), even if the opposing arguments are strong. Keep the tone respectful and formal throughout."
|
27 |
}
|
@@ -40,17 +40,18 @@ def debate_respond(message, history: list[tuple[str, str]],
|
|
40 |
|
41 |
# Generating the response
|
42 |
response = ""
|
43 |
-
for
|
44 |
messages,
|
45 |
max_tokens=max_tokens,
|
46 |
stream=True,
|
47 |
temperature=temperature,
|
48 |
top_p=top_p,
|
49 |
):
|
50 |
-
response +=
|
51 |
yield response
|
52 |
print(f"{datetime.datetime.now()}::{messages[-1]['content']}->{response}\n")
|
53 |
|
|
|
54 |
# Function to start the single-player debate
|
55 |
def start(txt, dd):
|
56 |
global topic, position
|
@@ -80,16 +81,16 @@ def generate_response(position, topic, message, history):
|
|
80 |
|
81 |
# Generate the response
|
82 |
response = ""
|
83 |
-
for
|
84 |
messages,
|
85 |
max_tokens=128,
|
86 |
stream=True,
|
87 |
temperature=0.4,
|
88 |
top_p=0.95,
|
89 |
):
|
90 |
-
response +=
|
91 |
-
|
92 |
-
|
93 |
|
94 |
|
95 |
# Function to start the multi-participant debate
|
@@ -181,7 +182,7 @@ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Roboto Mono")]),
|
|
181 |
output = gr.Textbox(label='Status')
|
182 |
with gr.Column(scale=4):
|
183 |
debate_interface = gr.ChatInterface(debate_respond,
|
184 |
-
|
185 |
with gr.TabItem("Master Vs Master"):
|
186 |
with gr.Row():
|
187 |
with gr.Column(scale=1):
|
|
|
16 |
max_tokens=128, temperature=0.4, top_p=0.95):
|
17 |
if position is None or topic is None:
|
18 |
return f"Please fill the Debate Topic -> choose Debate Master stance -> click START"
|
19 |
+
global topic, position
|
20 |
# System message defining assistant behavior in a debate
|
21 |
system_message = {
|
22 |
"role": "system",
|
23 |
"content": f"You are a debate participant tasked with defending the position '{position}' on the topic '{topic}'. Your goal is to articulate your arguments with clarity, logic, and professionalism while addressing counterpoints made by the opposing side. "
|
24 |
+
f"Ensure that your responses are thoughtful, evidence-based, and persuasive. Strictly keep them concise—aim for responses that are 4 to 5 lines only in a single paragraph i.e 128 tokens only."
|
25 |
f"Analyze user arguments critically and provide respectful but firm counterarguments. Avoid dismissive language and focus on strengthening your case through logic, data, and examples relevant to the topic."
|
26 |
f"Stay consistent with your assigned position ('{position}'), even if the opposing arguments are strong. Keep the tone respectful and formal throughout."
|
27 |
}
|
|
|
40 |
|
41 |
# Generating the response
|
42 |
response = ""
|
43 |
+
for message_chunk in client.chat_completion(
|
44 |
messages,
|
45 |
max_tokens=max_tokens,
|
46 |
stream=True,
|
47 |
temperature=temperature,
|
48 |
top_p=top_p,
|
49 |
):
|
50 |
+
response += message_chunk.choices[0].delta.content
|
51 |
yield response
|
52 |
print(f"{datetime.datetime.now()}::{messages[-1]['content']}->{response}\n")
|
53 |
|
54 |
+
|
55 |
# Function to start the single-player debate
|
56 |
def start(txt, dd):
|
57 |
global topic, position
|
|
|
81 |
|
82 |
# Generate the response
|
83 |
response = ""
|
84 |
+
for message_chunk in client.chat_completion(
|
85 |
messages,
|
86 |
max_tokens=128,
|
87 |
stream=True,
|
88 |
temperature=0.4,
|
89 |
top_p=0.95,
|
90 |
):
|
91 |
+
response += message_chunk.choices[0].delta.content
|
92 |
+
|
93 |
+
return response
|
94 |
|
95 |
|
96 |
# Function to start the multi-participant debate
|
|
|
182 |
output = gr.Textbox(label='Status')
|
183 |
with gr.Column(scale=4):
|
184 |
debate_interface = gr.ChatInterface(debate_respond,
|
185 |
+
chatbot=gr.Chatbot(height=475))
|
186 |
with gr.TabItem("Master Vs Master"):
|
187 |
with gr.Row():
|
188 |
with gr.Column(scale=1):
|