Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -142,12 +142,18 @@ def run_code(code):
|
|
142 |
|
143 |
def chat_interface(message, history, agent_cluster, temperature=0.9, max_new_tokens=2048, top_p=0.95, repetition_penalty=1.0):
|
144 |
"""Handles user input and generates responses."""
|
145 |
-
if message.startswith("
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
with gr.Row(:
|
153 |
gr.ChatInterface(
|
|
|
142 |
|
143 |
def chat_interface(message, history, agent_cluster, temperature=0.9, max_new_tokens=2048, top_p=0.95, repetition_penalty=1.0):
|
144 |
"""Handles user input and generates responses."""
|
145 |
+
if message.startswith("python"):
|
146 |
+
# User entered code, execute it
|
147 |
+
code = message[9:-3]
|
148 |
+
output = run_code(code)
|
149 |
+
return (message, output)
|
150 |
+
else: """User entered a normal message, generate a response""" active_agents = [agent for agent, is_active in agent_cluster.items()
|
151 |
+
if is_active] response = generate(message, history, active_agents, temperature, max_new_tokens, top_p, repetition_penalty)
|
152 |
+
return (message, response)
|
153 |
+
|
154 |
+
with gr.Blocks(theme='ParityError/Interstellar') as demo:
|
155 |
+
with gr.Row(): for agent_name, agent_data in agent_roles.items():
|
156 |
+
gr.Button(agent_name, variant="secondary").click(toggle_agent, inputs=[gr.Button], outputs=[gr.Textbox]) gr.Textbox(agent_data["description"], interactive=False)
|
157 |
|
158 |
with gr.Row(:
|
159 |
gr.ChatInterface(
|