Sarath0x8f commited on
Commit
9cf3e12
·
verified ·
1 Parent(s): bd3018c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -47,7 +47,7 @@ def explain_word(message, history: list[tuple[str, str]],max_tokens=128, tempera
47
 
48
 
49
  # Function for generating debate responses
50
- def generate_response(llm, position, topic, message):
51
  system_message = {
52
  "role": "system",
53
  "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. "
@@ -59,7 +59,7 @@ def generate_response(llm, position, topic, message):
59
  messages = [system_message]
60
  messages.append({"role": "user", "content": message})
61
 
62
- response = ""
63
  for message_chunk in llm.chat_completion(
64
  messages, max_tokens=128, stream=True, temperature=0.4, top_p=0.95):
65
  response += message_chunk.choices[0].delta.content
@@ -80,7 +80,7 @@ def start_debate(topic, position_1, position_2):
80
  turn = "Master-1"
81
  history = [] # Reset history
82
  initial_message = "Opening Statement"
83
- response = generate_response(Master1, position_1, topic, initial_message)
84
  history.append((initial_message, response))
85
  return f"The debate has started! {turn} begins.", history
86
 
@@ -94,13 +94,13 @@ def next_turn(topic, position_1, position_2, current_history):
94
  # Alternate turn logic
95
  if turn == "Master-1":
96
  turn = "Master-2"
97
- llm, position = Master2, position_2
98
  else:
99
  turn = "Master-1"
100
- llm, position = Master1, position_1
101
 
102
  last_response = current_history[-1][1] # Get the last message
103
- response = generate_response(llm, position, topic, last_response)
104
  history.append(("", response)) # Add the response to history
105
  return f"It's now {turn}'s turn.", history
106
 
@@ -133,7 +133,7 @@ def debate_respond(message, history: list[tuple[str, str]],
133
 
134
  # Generating the response
135
  response = ""
136
- for message in client.chat_completion(
137
  messages,
138
  max_tokens=max_tokens,
139
  stream=True,
 
47
 
48
 
49
  # Function for generating debate responses
50
+ def generate_response(llm, position, who, topic, message):
51
  system_message = {
52
  "role": "system",
53
  "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. "
 
59
  messages = [system_message]
60
  messages.append({"role": "user", "content": message})
61
 
62
+ response = f"{who}:\n"
63
  for message_chunk in llm.chat_completion(
64
  messages, max_tokens=128, stream=True, temperature=0.4, top_p=0.95):
65
  response += message_chunk.choices[0].delta.content
 
80
  turn = "Master-1"
81
  history = [] # Reset history
82
  initial_message = "Opening Statement"
83
+ response = generate_response(Master1, position_1, 'Master-1', topic, initial_message)
84
  history.append((initial_message, response))
85
  return f"The debate has started! {turn} begins.", history
86
 
 
94
  # Alternate turn logic
95
  if turn == "Master-1":
96
  turn = "Master-2"
97
+ llm, position, who = Master2, position_2, 'Master-2'
98
  else:
99
  turn = "Master-1"
100
+ llm, position, who = Master1, position_1, "Master-1"
101
 
102
  last_response = current_history[-1][1] # Get the last message
103
+ response = generate_response(llm, position, who, topic, last_response)
104
  history.append(("", response)) # Add the response to history
105
  return f"It's now {turn}'s turn.", history
106
 
 
133
 
134
  # Generating the response
135
  response = ""
136
+ for message in Master1.chat_completion(
137
  messages,
138
  max_tokens=max_tokens,
139
  stream=True,