Ben Beinke commited on
Commit
841b545
Β·
1 Parent(s): 2251252

agent and preview working

Browse files
app.py CHANGED
@@ -1,6 +1,4 @@
1
- import atexit
2
  import os
3
- import signal
4
  import subprocess
5
  import sys
6
  import time
@@ -8,15 +6,14 @@ from pathlib import Path
8
 
9
  import gradio as gr
10
  import requests
 
 
11
 
12
- from manager_agent import GradioManagerAgent
13
- from utils import load_file
14
 
15
- gr.NO_RELOAD = False
16
-
17
- # Global variables for managing the preview app subprocess
18
  preview_process = None
19
- PREVIEW_PORT = 7861 # Different port from main app
20
  PREVIEW_URL = f"http://localhost:{PREVIEW_PORT}"
21
 
22
 
@@ -40,33 +37,6 @@ def find_app_py_in_sandbox():
40
  return str(app_files[0])
41
 
42
 
43
- def generate_ai_response(message, history):
44
- """Generate AI response using the manager agent for planning and \
45
- coding agent for implementation."""
46
-
47
- history.append({"role": "user", "content": message})
48
- manager_agent_instance = GradioManagerAgent()
49
-
50
- if manager_agent_instance is None:
51
- # Fallback to mock response if planning agent fails to initialize
52
- response = (
53
- "Sorry, the manager agent is not available. "
54
- "Please check your API_KEY environment variable."
55
- )
56
- history.append({"role": "assistant", "content": response})
57
- return history, ""
58
-
59
- try:
60
- manager_result = manager_agent_instance(message)
61
- history.append({"role": "assistant", "content": manager_result})
62
-
63
- except Exception as e:
64
- error_response = f"I encountered an error: {str(e)}"
65
- history.append({"role": "assistant", "content": error_response})
66
-
67
- return history, ""
68
-
69
-
70
  def save_file(path, new_text):
71
  if path is None:
72
  gr.Warning("⚠️ No file selected.")
@@ -152,16 +122,6 @@ def start_preview_app():
152
 
153
  def create_iframe_preview():
154
  """Create an iframe HTML element for the preview."""
155
- app_path = find_app_py_in_sandbox()
156
-
157
- if not app_path or not os.path.exists(app_path):
158
- return """
159
- <div style='padding: 20px; text-align: center; color: #666;'>
160
- <h3>❌ No app.py found</h3>
161
- <p>Create an app.py file in the sandbox directory to see the preview.</p>
162
- </div>
163
- """
164
-
165
  # Start the preview app
166
  success, message = start_preview_app()
167
 
@@ -216,134 +176,225 @@ def ensure_preview_running():
216
  start_preview_app()
217
 
218
 
219
- # Create the main Likable UI
220
- def create_likable_ui():
221
- with gr.Blocks(
222
- title="πŸ’—Likable",
223
- theme=gr.themes.Soft(),
224
- fill_height=True,
225
- fill_width=True,
226
- ) as demo:
227
- gr.Markdown("# πŸ’—Likable")
228
- gr.Markdown(
229
- "*AI-powered Gradio app builder - Plans and implements \
230
- complete applications*"
231
- )
232
 
233
- with gr.Row(elem_classes="main-container"):
234
- # Left side - Chat Interface
235
- with gr.Column(scale=1, elem_classes="chat-container"):
236
- chatbot = gr.Chatbot(
237
- show_copy_button=True,
238
- avatar_images=(None, "πŸ’—"),
239
- type="messages",
240
- height="75vh",
241
- )
242
-
243
- with gr.Row():
244
- msg_input = gr.Textbox(
245
- placeholder="Describe the Gradio app you want to build...",
246
- scale=4,
247
- container=False,
248
- )
249
- send_btn = gr.Button("Build App", scale=1, variant="primary")
250
 
251
- # Right side - Preview/Code Toggle
252
- with gr.Column(scale=4, elem_classes="preview-container"):
253
- with gr.Tab("Preview"):
254
- preview_html = gr.HTML(
255
- value=create_iframe_preview(), elem_id="preview-container"
256
- )
257
 
258
- with gr.Tab("Code"):
259
- with gr.Row():
260
- save_btn = gr.Button("Save", size="sm")
261
- with gr.Row(equal_height=True):
262
- file_explorer = gr.FileExplorer(
263
- scale=1,
264
- file_count="single",
265
- value="app.py",
266
- root_dir="sandbox",
267
- )
268
 
269
- # Get initial code content dynamically
270
- def get_initial_code():
271
- app_path = find_app_py_in_sandbox()
272
- if app_path and os.path.exists(app_path):
273
- return load_file(app_path)
274
- return "# No app created yet - use the chat to create one!"
275
-
276
- code_editor = gr.Code(
277
- scale=3,
278
- value=get_initial_code(),
279
- language="python",
280
- visible=True,
281
- interactive=True,
282
- autocomplete=True,
 
 
 
 
 
 
 
 
 
 
 
283
  )
 
284
 
285
- # Event handlers
286
- file_explorer.change(fn=load_file, inputs=file_explorer, outputs=code_editor)
287
-
288
- def save_and_refresh(path, new_text):
289
- save_file(path, new_text)
290
- # Wait a moment for file to be saved
291
- time.sleep(0.5)
292
- # Return updated iframe preview with forced refresh
293
- return create_iframe_preview()
294
-
295
- save_btn.click(
296
- fn=save_and_refresh,
297
- inputs=[file_explorer, code_editor],
298
- outputs=[preview_html],
299
- )
300
-
301
- # Event handlers for chat - updated to use the combined planning and
302
- # coding function
303
- msg_input.submit(
304
- generate_ai_response,
305
- inputs=[msg_input, chatbot],
306
- outputs=[chatbot, msg_input],
307
- )
308
-
309
- send_btn.click(
310
- generate_ai_response,
311
- inputs=[msg_input, chatbot],
312
- outputs=[chatbot, msg_input],
313
  )
314
 
315
- # Auto-start preview when the app loads
316
- def on_app_load():
317
- ensure_preview_running()
318
- return create_iframe_preview()
319
-
320
- demo.load(fn=on_app_load, outputs=[preview_html])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
 
322
- # Clean up on app close
323
- def cleanup():
324
- stop_preview_app()
 
 
 
 
325
 
326
- demo.unload(cleanup)
 
 
 
 
 
327
 
328
- return demo
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
 
330
 
331
  if __name__ == "__main__":
332
- # Register cleanup function to run on exit
333
- atexit.register(stop_preview_app)
334
 
335
- demo = create_likable_ui()
336
- # gradio_config = settings.get_gradio_config()
337
-
338
- # Ensure cleanup on exit
339
- def signal_handler(signum, frame):
340
- stop_preview_app()
341
- sys.exit(0)
342
-
343
- signal.signal(signal.SIGINT, signal_handler)
344
- signal.signal(signal.SIGTERM, signal_handler)
345
-
346
- try:
347
- demo.launch(server_name="0.0.0.0", server_port=7862)
348
- finally:
349
- stop_preview_app()
 
 
1
  import os
 
2
  import subprocess
3
  import sys
4
  import time
 
6
 
7
  import gradio as gr
8
  import requests
9
+ from smolagents.agents import MultiStepAgent
10
+ from smolagents.gradio_ui import stream_to_gradio
11
 
12
+ # from src.manager_agent import GradioManagerAgent
13
+ from src.utils import load_file
14
 
 
 
 
15
  preview_process = None
16
+ PREVIEW_PORT = 7860 # Different port from main app
17
  PREVIEW_URL = f"http://localhost:{PREVIEW_PORT}"
18
 
19
 
 
37
  return str(app_files[0])
38
 
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  def save_file(path, new_text):
41
  if path is None:
42
  gr.Warning("⚠️ No file selected.")
 
122
 
123
  def create_iframe_preview():
124
  """Create an iframe HTML element for the preview."""
 
 
 
 
 
 
 
 
 
 
125
  # Start the preview app
126
  success, message = start_preview_app()
127
 
 
176
  start_preview_app()
177
 
178
 
179
+ class GradioUI:
180
+ """A one-line interface to launch your agent in Gradio"""
 
 
 
 
 
 
 
 
 
 
 
181
 
182
+ def __init__(self, agent: MultiStepAgent):
183
+ self.agent = agent
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
 
185
+ def interact_with_agent(self, prompt, messages, session_state):
186
+ import gradio as gr
 
 
 
 
187
 
188
+ # Get the agent type from the template agent
189
+ if "agent" not in session_state:
190
+ session_state["agent"] = self.agent
 
 
 
 
 
 
 
191
 
192
+ try:
193
+ messages.append(
194
+ gr.ChatMessage(role="user", content=prompt, metadata={"status": "done"})
195
+ )
196
+ yield messages
197
+
198
+ for msg in stream_to_gradio(
199
+ session_state["agent"], task=prompt, reset_agent_memory=False
200
+ ):
201
+ if isinstance(msg, gr.ChatMessage):
202
+ messages[-1].metadata["status"] = "done"
203
+ messages.append(msg)
204
+ elif isinstance(msg, str): # Then it's only a completion delta
205
+ msg = msg.replace("<", r"\<").replace(
206
+ ">", r"\>"
207
+ ) # HTML tags seem to break Gradio Chatbot
208
+ if messages[-1].metadata["status"] == "pending":
209
+ messages[-1].content = msg
210
+ else:
211
+ messages.append(
212
+ gr.ChatMessage(
213
+ role="assistant",
214
+ content=msg,
215
+ metadata={"status": "pending"},
216
+ )
217
  )
218
+ yield messages
219
 
220
+ yield messages
221
+ except Exception as e:
222
+ yield messages
223
+ raise gr.Error(f"Error in interaction: {str(e)}")
224
+
225
+ def log_user_message(self, text_input, file_uploads_log):
226
+ import gradio as gr
227
+
228
+ return (
229
+ text_input
230
+ + (
231
+ f"\nYou have been provided with these files, which might be helpful or not: {file_uploads_log}"
232
+ if len(file_uploads_log) > 0
233
+ else ""
234
+ ),
235
+ "",
236
+ gr.Button(interactive=False),
 
 
 
 
 
 
 
 
 
 
 
237
  )
238
 
239
+ def launch(self, share: bool = True, **kwargs):
240
+ self.create_app().launch(debug=True, share=share, **kwargs)
241
+
242
+ def create_app(self):
243
+ import gradio as gr
244
+
245
+ # with gr.Blocks(theme="ocean", fill_height=True) as demo:
246
+ with gr.Blocks(
247
+ title="πŸ’—Likable",
248
+ theme=gr.themes.Soft(),
249
+ fill_height=True,
250
+ fill_width=True,
251
+ ) as demo:
252
+ gr.Markdown("# πŸ’—Likable")
253
+
254
+ with gr.Row(elem_classes="main-container"):
255
+ # Left side - Chat Interface
256
+ with gr.Column(scale=1, elem_classes="chat-container"):
257
+ chatbot = gr.Chatbot(
258
+ # show_copy_button=True,
259
+ avatar_images=(
260
+ None,
261
+ "http://em-content.zobj.net/source/apple/419/growing-heart_1f497.png",
262
+ ),
263
+ type="messages",
264
+ resizable=True,
265
+ )
266
 
267
+ with gr.Column():
268
+ text_input = gr.Textbox(
269
+ placeholder="Ask Likable...",
270
+ scale=4,
271
+ container=False,
272
+ )
273
+ submit_btn = gr.Button("↑", size="sm", variant="primary")
274
 
275
+ # Right side - Preview/Code Toggle
276
+ with gr.Column(scale=4, elem_classes="preview-container"):
277
+ with gr.Tab("Preview"):
278
+ preview_html = gr.HTML(
279
+ value=create_iframe_preview(), elem_id="preview-container"
280
+ )
281
 
282
+ with gr.Tab("Code"):
283
+ with gr.Row():
284
+ save_btn = gr.Button("Save", size="sm")
285
+ with gr.Row(equal_height=True):
286
+ file_explorer = gr.FileExplorer(
287
+ scale=1,
288
+ file_count="single",
289
+ value="app.py",
290
+ root_dir="sandbox",
291
+ )
292
+
293
+ # Get initial code content dynamically
294
+ def get_initial_code():
295
+ app_path = find_app_py_in_sandbox()
296
+ if app_path and os.path.exists(app_path):
297
+ return load_file(app_path)
298
+ return (
299
+ "# No app created yet - use the chat to create one!"
300
+ )
301
+
302
+ code_editor = gr.Code(
303
+ scale=3,
304
+ value=get_initial_code(),
305
+ language="python",
306
+ visible=True,
307
+ interactive=True,
308
+ autocomplete=True,
309
+ )
310
+ # Add session state to store session-specific data
311
+ session_state = gr.State({})
312
+ stored_messages = gr.State([])
313
+ file_uploads_log = gr.State([])
314
+
315
+ # Set up event handlers
316
+ file_explorer.change(
317
+ fn=load_file, inputs=file_explorer, outputs=code_editor
318
+ )
319
+
320
+ def save_and_refresh(path, new_text):
321
+ save_file(path, new_text)
322
+ # Wait a moment for file to be saved
323
+ time.sleep(0.5)
324
+ # Return updated iframe preview with forced refresh
325
+ return create_iframe_preview()
326
+
327
+ save_btn.click(
328
+ fn=save_and_refresh,
329
+ inputs=[file_explorer, code_editor],
330
+ outputs=[preview_html],
331
+ )
332
+
333
+ text_input.submit(
334
+ self.log_user_message,
335
+ [text_input, file_uploads_log],
336
+ [stored_messages, text_input, submit_btn],
337
+ ).then(
338
+ self.interact_with_agent,
339
+ [stored_messages, chatbot, session_state],
340
+ [chatbot],
341
+ ).then(
342
+ fn=create_iframe_preview,
343
+ inputs=[],
344
+ outputs=[preview_html],
345
+ ).then(
346
+ lambda: (
347
+ gr.Textbox(
348
+ interactive=True,
349
+ placeholder="Ask Likable...",
350
+ ),
351
+ gr.Button(interactive=True),
352
+ ),
353
+ None,
354
+ [text_input, submit_btn],
355
+ )
356
+
357
+ submit_btn.click(
358
+ self.log_user_message,
359
+ [text_input, file_uploads_log],
360
+ [stored_messages, text_input, submit_btn],
361
+ ).then(
362
+ self.interact_with_agent,
363
+ [stored_messages, chatbot, session_state],
364
+ [chatbot],
365
+ ).then(
366
+ fn=create_iframe_preview,
367
+ inputs=[],
368
+ outputs=[preview_html],
369
+ ).then(
370
+ lambda: (
371
+ gr.Textbox(
372
+ interactive=True,
373
+ placeholder="Ask Likable....",
374
+ ),
375
+ gr.Button(interactive=True),
376
+ ),
377
+ None,
378
+ [text_input, submit_btn],
379
+ )
380
+
381
+ def on_app_load():
382
+ ensure_preview_running()
383
+ return create_iframe_preview()
384
+
385
+ demo.load(fn=on_app_load, outputs=[preview_html])
386
+
387
+ # Clean up on app close
388
+ def cleanup():
389
+ stop_preview_app()
390
+
391
+ demo.unload(cleanup)
392
+
393
+ return demo
394
 
395
 
396
  if __name__ == "__main__":
397
+ from kiss_agent import KISSAgent
 
398
 
399
+ agent = KISSAgent()
400
+ GradioUI(agent).launch(share=False, server_name="0.0.0.0", server_port=7862)
 
 
 
 
 
 
 
 
 
 
 
 
 
kiss_agent.py ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import subprocess
3
+ from pathlib import Path
4
+
5
+ from smolagents import LiteLLMModel, MCPClient, ToolCallingAgent, tool
6
+
7
+ from src.settings import settings
8
+
9
+ PROMPT_TEMPLATE = """You are an expert software developer for Gradio.
10
+ You are given a task to develop a Gradio application and can use all the tools at your disposal to do so.
11
+ You always try to do everything inside of the app.py file. Only in rare cases you might need to edit or create other files.
12
+
13
+ The overarching goal is always to create a Gradio application.
14
+
15
+ Here is the user's request:
16
+ {task}
17
+
18
+ Always test the app.py file after you have made changes to it!
19
+ """
20
+
21
+
22
+ @tool
23
+ def python_editor(whole_edit: str) -> str:
24
+ """
25
+ Edit python files using aider's whole edit format. You can use this tool to edit any python file or create a new one.
26
+
27
+ Your input should be a string in the following format:
28
+ [filename]
29
+ ```python
30
+ [complete file content]
31
+ ```
32
+
33
+ For example:
34
+ app.py
35
+ ```python
36
+ import gradio as gr
37
+ ...
38
+ ```
39
+
40
+ Args:
41
+ whole_edit: The new complete content in whole edit format
42
+
43
+ Returns:
44
+ Status message indicating success or failure
45
+ """
46
+ try:
47
+ # Split into lines and find first non-empty line as filename
48
+ lines = whole_edit.strip().split("\n")
49
+ if not lines:
50
+ return "Error: Empty input provided"
51
+
52
+ filename = next((line.strip() for line in lines if line.strip()), None)
53
+ if not filename:
54
+ return "Error: No filename found in input"
55
+
56
+ # Find code block content between ```
57
+ content = whole_edit.strip()
58
+ start_marker = content.find("```")
59
+ if start_marker == -1:
60
+ return "Error: No code block found"
61
+
62
+ # Find the end of the first line after ```
63
+ start_content = content.find("\n", start_marker) + 1
64
+ end_marker = content.find("```", start_content)
65
+
66
+ if end_marker == -1:
67
+ # No closing ```, take everything after the opening ```
68
+ file_content = content[start_content:]
69
+ else:
70
+ file_content = content[start_content:end_marker]
71
+
72
+ # Create the file path and write content
73
+ file_path = Path("./sandbox") / filename
74
+ file_path.parent.mkdir(parents=True, exist_ok=True)
75
+
76
+ with open(file_path, "w", encoding="utf-8") as f:
77
+ f.write(file_content.rstrip()) # Remove trailing whitespace
78
+
79
+ line_count = (
80
+ len(file_content.strip().split("\n")) if file_content.strip() else 0
81
+ )
82
+ return f"Successfully wrote {line_count} lines to {filename}"
83
+
84
+ except Exception as e:
85
+ return f"Error applying whole edit: {str(e)}"
86
+
87
+
88
+ @tool
89
+ def test_app_py() -> str:
90
+ """
91
+ Test if the current app.py runs without syntax errors.
92
+
93
+ Returns:
94
+ Test result message
95
+ """
96
+ try:
97
+ app_path = Path("sandbox") / "app.py"
98
+
99
+ if not app_path.exists():
100
+ return "Error: app.py does not exist"
101
+
102
+ # Store original working directory
103
+ original_cwd = os.getcwd()
104
+
105
+ # Change to project directory for testing
106
+ os.chdir(app_path.parent)
107
+
108
+ # Test syntax by attempting to compile
109
+ result = subprocess.run(
110
+ ["python", "-m", "py_compile", "app.py"],
111
+ capture_output=True,
112
+ text=True,
113
+ )
114
+
115
+ # Change back to original directory
116
+ os.chdir(original_cwd)
117
+
118
+ if result.returncode == 0:
119
+ return "βœ… app.py syntax check passed successfully"
120
+ else:
121
+ return f"❌ Syntax error in app.py:\n{result.stderr}"
122
+
123
+ except Exception as e:
124
+ # Restore working directory on error
125
+ try:
126
+ os.chdir(original_cwd)
127
+ except NameError:
128
+ pass
129
+ return f"Error testing app.py: {str(e)}"
130
+
131
+
132
+ class KISSAgent(ToolCallingAgent):
133
+ def __init__(
134
+ self,
135
+ model_id: str | None = None,
136
+ api_base_url: str | None = None,
137
+ api_key: str | None = None,
138
+ prompt_template: str | None = None,
139
+ **kwargs,
140
+ ):
141
+ model_id = model_id or settings.manager_model_id
142
+ api_base_url = api_base_url or settings.api_base_url
143
+ api_key = api_key or settings.api_key
144
+ self.prompt_template = prompt_template or PROMPT_TEMPLATE
145
+
146
+ # Initialize the language model
147
+ model = LiteLLMModel(
148
+ model_id=model_id,
149
+ api_base=api_base_url,
150
+ api_key=api_key,
151
+ )
152
+
153
+ # Initialize the parent CodeAgent
154
+ super().__init__(
155
+ tools=[python_editor, test_app_py],
156
+ model=model,
157
+ add_base_tools=False,
158
+ **kwargs,
159
+ )
160
+
161
+ def run(self, task: str, **kwargs) -> str:
162
+ """Override run method to format prompt with task before calling parent run."""
163
+ formatted_prompt = self.prompt_template.format(task=task)
164
+ return super().run(formatted_prompt, **kwargs)
pyproject.toml CHANGED
@@ -11,6 +11,7 @@ dependencies = [
11
  "smolagents[litellm,mcp]>=1.17.0",
12
  "selenium>=4.25.0",
13
  "requests>=2.32.0",
 
14
  ]
15
 
16
  [dependency-groups]
@@ -49,5 +50,5 @@ members = [
49
  "sandbox/calculator_app",
50
  "sandbox/gradio_calculator",
51
  "sandbox/gradio_calculator_app",
52
- "sandbox/simple_calculator",
53
  ]
 
11
  "smolagents[litellm,mcp]>=1.17.0",
12
  "selenium>=4.25.0",
13
  "requests>=2.32.0",
14
+ "watchdog>=5.0.0",
15
  ]
16
 
17
  [dependency-groups]
 
50
  "sandbox/calculator_app",
51
  "sandbox/gradio_calculator",
52
  "sandbox/gradio_calculator_app",
53
+ "sandbox/simple_calculator", "sandbox/todo_list_app", "sandbox/calculator", "sandbox/todo_app", "sandbox/gradio_todo_app", "sandbox/gradio_hello_world", "sandbox/sandbox/todo-app", "sandbox/to_do_list_app", "sandbox/sandbox/to-do-app", "sandbox/todo_gradio_app", "sandbox/sandbox/to-do-list", "sandbox/sandbox/calculator",
54
  ]
coding_agent.py β†’ src/coding_agent.py RENAMED
File without changes
manager_agent.py β†’ src/manager_agent.py RENAMED
File without changes
planning_agent.py β†’ src/planning_agent.py RENAMED
File without changes
settings.py β†’ src/settings.py RENAMED
File without changes
test_coding_agent.py β†’ src/test_coding_agent.py RENAMED
File without changes
src/test_gradio_manager.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Test script demonstrating GradioManagerAgent with Gradio UI integration.
4
+
5
+ This script shows how to use the GradioManagerAgent with the GradioUI
6
+ to create a web interface for the multi-agent development workflow.
7
+ """
8
+
9
+ import sys
10
+ import os
11
+
12
+ # Add the current directory to the path so we can import our modules
13
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
14
+
15
+ try:
16
+ from manager_agent import GradioManagerAgent
17
+ from smolagents.gradio_ui import GradioUI
18
+
19
+ def main():
20
+ """Main function to launch the Gradio UI with the GradioManagerAgent."""
21
+ print("πŸš€ Initializing GradioManagerAgent...")
22
+
23
+ # Create the manager agent
24
+ manager_agent = GradioManagerAgent()
25
+
26
+ print(f"βœ… Manager agent created successfully!")
27
+ print(f" - Name: {manager_agent.name}")
28
+ print(f" - Description: {manager_agent.description[:100]}...")
29
+ print(f" - Is CodeAgent: {hasattr(manager_agent, 'run')}")
30
+
31
+ # Create the Gradio UI
32
+ print("\n🎨 Creating Gradio UI...")
33
+ gradio_ui = GradioUI(agent=manager_agent)
34
+
35
+ print("βœ… Gradio UI created successfully!")
36
+ print("\n🌐 Launching Gradio interface...")
37
+ print(" - The interface will be available at the URL shown below")
38
+ print(" - You can now interact with the multi-agent development workflow")
39
+ print(" - Try asking: 'Create a simple calculator app'")
40
+
41
+ # Launch the Gradio interface
42
+ # Note: Set share=False for local development, share=True to create a public link
43
+ gradio_ui.launch(share=False, server_name="0.0.0.0", server_port=7860)
44
+
45
+ if __name__ == "__main__":
46
+ main()
47
+
48
+ except ImportError as e:
49
+ print(f"❌ Import error: {e}")
50
+ print("Please make sure all dependencies are installed and modules are available.")
51
+ sys.exit(1)
52
+ except Exception as e:
53
+ print(f"❌ Error: {e}")
54
+ sys.exit(1)
test_manager_agent.py β†’ src/test_manager_agent.py RENAMED
File without changes
test_planning_agent.py β†’ src/test_planning_agent.py RENAMED
File without changes
test_testing_agent.py β†’ src/test_testing_agent.py RENAMED
File without changes
testing_agent.py β†’ src/testing_agent.py RENAMED
File without changes
utils.py β†’ src/utils.py RENAMED
File without changes
uv.lock CHANGED
The diff for this file is too large to render. See raw diff