Spaces:
Sleeping
Sleeping
acecalisto3
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -191,14 +191,31 @@ class Agent:
|
|
191 |
# Main application functions
|
192 |
async def run(message: str, history: List[Tuple[str, str]]) -> str:
|
193 |
"""Process user input and generate a response using the agent system."""
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
context = "\n".join([f"Human: {h[0]}\nAI: {h[1]}" for h in history])
|
200 |
try:
|
201 |
-
response = await
|
202 |
return response
|
203 |
except Exception as e:
|
204 |
logger.error(f"Error processing request: {e}")
|
@@ -207,9 +224,9 @@ async def run(message: str, history: List[Tuple[str, str]]) -> str:
|
|
207 |
async def main():
|
208 |
"""Main function to run the Gradio interface."""
|
209 |
examples = [
|
210 |
-
["
|
211 |
-
["
|
212 |
-
["
|
213 |
]
|
214 |
|
215 |
gr.ChatInterface(
|
|
|
191 |
# Main application functions
|
192 |
async def run(message: str, history: List[Tuple[str, str]]) -> str:
|
193 |
"""Process user input and generate a response using the agent system."""
|
194 |
+
# Create a trio of agents for sequential app building
|
195 |
+
agent_structure = [
|
196 |
+
Agent("CodeFusion_Structure", "App Structure Designer", [CodeGenerationTool()]),
|
197 |
+
Agent("CodeFusion_Logic", "App Logic Implementer", [CodeGenerationTool(), CodeExplanationTool()]),
|
198 |
+
Agent("CodeFusion_UI", "App UI Designer", [CodeGenerationTool(), CodeExplanationTool(), DebuggingTool()])
|
199 |
+
]
|
200 |
+
|
201 |
+
# Initialize the current agent based on the user's request
|
202 |
+
current_agent_index = 0
|
203 |
+
for i, agent in enumerate(agent_structure):
|
204 |
+
if "structure" in message.lower():
|
205 |
+
current_agent_index = i
|
206 |
+
break
|
207 |
+
elif "logic" in message.lower():
|
208 |
+
current_agent_index = i
|
209 |
+
break
|
210 |
+
elif "ui" in message.lower():
|
211 |
+
current_agent_index = i
|
212 |
+
break
|
213 |
+
|
214 |
+
# Use the selected agent to process the message
|
215 |
+
current_agent = agent_structure[current_agent_index]
|
216 |
context = "\n".join([f"Human: {h[0]}\nAI: {h[1]}" for h in history])
|
217 |
try:
|
218 |
+
response = await current_agent.act(message, context)
|
219 |
return response
|
220 |
except Exception as e:
|
221 |
logger.error(f"Error processing request: {e}")
|
|
|
224 |
async def main():
|
225 |
"""Main function to run the Gradio interface."""
|
226 |
examples = [
|
227 |
+
["Can you help me structure an app to manage a to-do list?", "Sure, here's a basic structure for a to-do list app:"],
|
228 |
+
["Now, implement the logic for adding and deleting tasks.", "OK, here's the logic for adding and deleting tasks:"],
|
229 |
+
["Finally, design a simple UI for the app.", "Here's a simple UI design for the to-do list app:"],
|
230 |
]
|
231 |
|
232 |
gr.ChatInterface(
|