acecalisto3 commited on
Commit
e2d157e
·
verified ·
1 Parent(s): f8d79a8

Update definitions.py

Browse files
Files changed (1) hide show
  1. definitions.py +89 -34
definitions.py CHANGED
@@ -264,19 +264,87 @@ class QualityMetrics:
264
  "performance": 0.80
265
  }
266
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
 
268
  class AutonomousAgent:
269
  """Autonomous agent for the system."""
270
  def __init__(self, app):
271
  self.app = app
272
  self.workspace_manager = WorkspaceManager(workspace_dir=os.getenv('WORKSPACE_DIR', 'workspace'))
 
273
  self.pipeline = self._initialize_pipeline()
274
  self.refinement_loop = RefinementLoop(pipeline=self.pipeline)
275
  self.tools_repository = self._initialize_tool_repository()
276
  self.chat_system = ChatSystem(self)
277
- self.interface = StreamlitInterface(self) # Updated initialization
278
 
279
- def _setup_tool_manager(self):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  """Setup tool manager with configuration."""
281
  return ToolManager()
282
 
@@ -284,40 +352,27 @@ class AutonomousAgent:
284
  """Initialize the development pipeline."""
285
  return DevelopmentPipeline(
286
  workspace_manager=self.workspace_manager,
287
- tool_manager=self._setup_tool_manager()
288
  )
289
 
290
- def initialize_tool_repository(self, tool_repository: object) -> None:
291
- """Initializes the tool repository."""
292
- self._tool_repository = tool_repository
293
-
294
- def build_tool(self, tool_name, task):
295
- """Builds a tool."""
296
- tool = self.tool_repository.get_tool(tool_name)
297
- if tool:
298
- tool.run(task)
299
- return f"{tool_name} built and ran successfully."
300
- else:
301
- return f"{tool_name} not found in tool repository."
302
-
303
- def build_agent(self, agent_name, role):
304
- """Builds an agent."""
305
- agent = self._create_agent(agent_name, role)
306
- if agent:
307
- return f"{agent_name} agent built successfully."
308
- else:
309
- return f"{agent_name} agent creation failed."
310
-
311
- def _create_agent(self, agent_name, role):
312
- """Creates a new agent."""
313
- if role == "development":
314
- return DevelopmentAgent(agent_name)
315
- elif role == "testing":
316
- return TestingAgent(agent_name)
317
- elif role == "security":
318
- return SecurityAgent(agent_name)
319
- else:
320
- return None
321
 
322
  class DevelopmentPipeline:
323
  def __init__(self, workspace_manager, tool_manager):
 
264
  "performance": 0.80
265
  }
266
 
267
+ class ToolRepository:
268
+ """Repository for managing tools and their configurations"""
269
+
270
+ def __init__(self):
271
+ self.tools = {}
272
+ self.default_tools = {
273
+ 'code_analyzer': {
274
+ 'name': 'Code Analyzer',
275
+ 'type': 'analysis',
276
+ 'config': {'enabled': True}
277
+ },
278
+ 'test_runner': {
279
+ 'name': 'Test Runner',
280
+ 'type': 'testing',
281
+ 'config': {'enabled': True}
282
+ },
283
+ 'security_scanner': {
284
+ 'name': 'Security Scanner',
285
+ 'type': 'security',
286
+ 'config': {'enabled': True}
287
+ }
288
+ }
289
+ self._initialize_default_tools()
290
+
291
+ def _initialize_default_tools(self):
292
+ """Initialize the repository with default tools."""
293
+ self.tools.update(self.default_tools)
294
+
295
+ def get_tool(self, tool_name: str) -> Optional[Dict]:
296
+ """Get a tool by name."""
297
+ return self.tools.get(tool_name)
298
+
299
+ def add_tool(self, tool_name: str, tool_config: Dict):
300
+ """Add a new tool to the repository."""
301
+ self.tools[tool_name] = tool_config
302
+
303
+ def remove_tool(self, tool_name: str):
304
+ """Remove a tool from the repository."""
305
+ if tool_name in self.tools:
306
+ del self.tools[tool_name]
307
+
308
+ def list_tools(self) -> List[str]:
309
+ """List all available tools."""
310
+ return list(self.tools.keys())
311
+
312
+ def get_tools_by_type(self, tool_type: str) -> List[Dict]:
313
+ """Get all tools of a specific type."""
314
+ return [
315
+ tool for tool in self.tools.values()
316
+ if tool.get('type') == tool_type
317
+ ]
318
 
319
  class AutonomousAgent:
320
  """Autonomous agent for the system."""
321
  def __init__(self, app):
322
  self.app = app
323
  self.workspace_manager = WorkspaceManager(workspace_dir=os.getenv('WORKSPACE_DIR', 'workspace'))
324
+ self.tool_manager = self._setup_tool_manager()
325
  self.pipeline = self._initialize_pipeline()
326
  self.refinement_loop = RefinementLoop(pipeline=self.pipeline)
327
  self.tools_repository = self._initialize_tool_repository()
328
  self.chat_system = ChatSystem(self)
329
+ self.interface = StreamlitInterface(self)
330
 
331
+ def _initialize_tool_repository(self) -> ToolRepository:
332
+ """Initialize the tool repository."""
333
+ repository = ToolRepository()
334
+
335
+ # Add any additional tool configurations here
336
+ repository.add_tool('custom_analyzer', {
337
+ 'name': 'Custom Code Analyzer',
338
+ 'type': 'analysis',
339
+ 'config': {
340
+ 'enabled': True,
341
+ 'custom_rules': []
342
+ }
343
+ })
344
+
345
+ return repository
346
+
347
+ def _setup_tool_manager(self) -> ToolManager:
348
  """Setup tool manager with configuration."""
349
  return ToolManager()
350
 
 
352
  """Initialize the development pipeline."""
353
  return DevelopmentPipeline(
354
  workspace_manager=self.workspace_manager,
355
+ tool_manager=self.tool_manager
356
  )
357
 
358
+ def get_tool(self, tool_name: str) -> Optional[Dict]:
359
+ """Get a tool configuration by name."""
360
+ return self.tools_repository.get_tool(tool_name)
361
+
362
+ def add_tool(self, tool_name: str, tool_config: Dict):
363
+ """Add a new tool to the repository."""
364
+ self.tools_repository.add_tool(tool_name, tool_config)
365
+
366
+ def remove_tool(self, tool_name: str):
367
+ """Remove a tool from the repository."""
368
+ self.tools_repository.remove_tool(tool_name)
369
+
370
+ def list_available_tools(self) -> List[str]:
371
+ """List all available tools."""
372
+ return self.tools_repository.list_tools()
373
+
374
+ def get_tools_by_type(self, tool_type: str) -> List[Dict]:
375
+ """Get all tools of a specific type."""
 
 
 
 
 
 
 
 
 
 
 
 
 
376
 
377
  class DevelopmentPipeline:
378
  def __init__(self, workspace_manager, tool_manager):