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

Update definitions.py

Browse files
Files changed (1) hide show
  1. definitions.py +149 -74
definitions.py CHANGED
@@ -326,8 +326,12 @@ class AutonomousAgent:
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()
@@ -374,6 +378,7 @@ class AutonomousAgent:
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):
379
  """Initialize the development pipeline with the given workspace and tool managers."""
@@ -731,13 +736,122 @@ class StreamlitInterface:
731
  self.metrics_history = []
732
  self.activity_log = []
733
 
734
- # ... (previous methods remain the same) ...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
735
 
736
  def get_recent_activity(self) -> List[Dict]:
737
  """Get recent activity data for display."""
738
  return [
739
  {
740
- "timestamp": activity["timestamp"],
741
  "action": activity["action"],
742
  "status": activity["status"],
743
  "details": activity["details"]
@@ -745,81 +859,69 @@ class StreamlitInterface:
745
  for activity in self.activity_log[-10:] # Show last 10 activities
746
  ]
747
 
748
- def render_stage_details(self, stage: PipelineStage):
 
 
 
 
749
  """Render details for a specific pipeline stage."""
750
- stage_results = self.agent.pipeline.stage_results.get(stage, {})
751
 
752
  if not stage_results:
753
  st.write("No data available for this stage yet.")
754
  return
755
 
756
- # Display stage-specific information
757
- if stage == PipelineStage.PLANNING:
758
  self._render_planning_details(stage_results)
759
- elif stage == PipelineStage.DEVELOPMENT:
760
  self._render_development_details(stage_results)
761
- elif stage == PipelineStage.TESTING:
762
  self._render_testing_details(stage_results)
763
 
764
  def _render_planning_details(self, results: Dict):
765
  """Render planning stage details."""
766
  st.subheader("Tasks")
767
- for task in results.get('tasks', []):
768
- st.write(f"- {task['id']}: {task['status']}")
769
-
770
- st.subheader("Timeline")
771
- timeline = results.get('timeline', {})
772
- st.write(f"Start Date: {timeline.get('start_date')}")
773
- st.write(f"Estimated Completion: {timeline.get('estimated_completion')}")
774
 
775
  def _render_development_details(self, results: Dict):
776
  """Render development stage details."""
777
- st.subheader("Code Files")
778
- for file in results.get('code_files', []):
779
- st.write(f"- {file}")
780
 
781
- st.subheader("Metrics")
782
- metrics = results.get('metrics', {})
783
- if metrics:
784
- st.json(metrics)
 
785
 
786
  def _render_testing_details(self, results: Dict):
787
  """Render testing stage details."""
788
  st.subheader("Test Results")
789
 
790
- # Test Cases
791
- st.write("Test Cases:")
792
- for test in results.get('test_cases', []):
793
- st.write(f"- {test}")
794
-
795
- # Coverage
796
- st.write("Coverage:")
797
- coverage = results.get('coverage', {})
798
- for file, cov in coverage.items():
799
- st.write(f"- {file}: {cov}%")
800
-
801
- # Issues
802
- st.write("Issues:")
803
- for issue in results.get('issues', []):
804
- st.write(f"- {issue}")
805
 
806
  def save_settings(self, workspace_dir: str, quality_threshold: float):
807
  """Save the system settings."""
808
  try:
809
- # Update workspace directory
810
  self.agent.workspace_manager.workspace_dir = workspace_dir
 
811
 
812
- # Update quality threshold
813
- self.agent.pipeline.quality_threshold = quality_threshold
814
-
815
- # Log the activity
816
  self.log_activity({
817
  "timestamp": datetime.now(),
818
  "action": "Settings Update",
819
  "status": "Success",
820
- "details": "System settings updated successfully"
821
  })
822
-
823
  st.success("Settings saved successfully!")
824
 
825
  except Exception as e:
@@ -828,36 +930,9 @@ class StreamlitInterface:
828
  def log_activity(self, activity: Dict):
829
  """Log an activity in the system."""
830
  self.activity_log.append(activity)
831
- # Keep only the last 100 activities
832
- if len(self.activity_log) > 100:
833
  self.activity_log = self.activity_log[-100:]
834
 
835
- def update_metrics_history(self, metrics: Dict):
836
- """Update the metrics history."""
837
- self.metrics_history.append({
838
- "timestamp": datetime.now(),
839
- **metrics
840
- })
841
- # Keep only the last 50 metrics records
842
- if len(self.metrics_history) > 50:
843
- self.metrics_history = self.metrics_history[-50:]
844
-
845
- def show_error(self, message: str):
846
- """Display an error message."""
847
- st.error(message)
848
-
849
- def show_success(self, message: str):
850
- """Display a success message."""
851
- st.success(message)
852
-
853
- def show_warning(self, message: str):
854
- """Display a warning message."""
855
- st.warning(message)
856
-
857
- def show_info(self, message: str):
858
- """Display an info message."""
859
- st.info(message)
860
-
861
  if __name__ == "__main__":
862
  app = AutonomousAgentApp()
863
- app.interface.render_main_interface()
 
326
  self.refinement_loop = RefinementLoop(pipeline=self.pipeline)
327
  self.tools_repository = self._initialize_tool_repository()
328
  self.chat_system = ChatSystem(self)
329
+ self.autonomous_agent = AutonomousAgent(self)
330
+ self.interface = StreamlitInterface(self.autonomous_agent)
331
 
332
+ def run(self):
333
+ """Run the Streamlit application."""
334
+ self.interface.render_main_interface()
335
  def _initialize_tool_repository(self) -> ToolRepository:
336
  """Initialize the tool repository."""
337
  repository = ToolRepository()
 
378
  def get_tools_by_type(self, tool_type: str) -> List[Dict]:
379
  """Get all tools of a specific type."""
380
 
381
+
382
  class DevelopmentPipeline:
383
  def __init__(self, workspace_manager, tool_manager):
384
  """Initialize the development pipeline with the given workspace and tool managers."""
 
736
  self.metrics_history = []
737
  self.activity_log = []
738
 
739
+ def render_main_interface(self):
740
+ """Render the main Streamlit interface."""
741
+ st.title("Autonomous Agent System")
742
+
743
+ # Initialize session state if not exists
744
+ if 'current_page' not in st.session_state:
745
+ st.session_state.current_page = 'Dashboard'
746
+
747
+ # Sidebar for navigation
748
+ self.render_sidebar()
749
+
750
+ # Main content area
751
+ selected_page = st.session_state.current_page
752
+
753
+ if selected_page == 'Dashboard':
754
+ self.render_dashboard()
755
+ elif selected_page == 'Pipeline':
756
+ self.render_pipeline_view()
757
+ elif selected_page == 'Metrics':
758
+ self.render_metrics_view()
759
+ elif selected_page == 'Settings':
760
+ self.render_settings()
761
+
762
+ def render_sidebar(self):
763
+ """Render the sidebar navigation."""
764
+ with st.sidebar:
765
+ st.title("Navigation")
766
+ pages = ['Dashboard', 'Pipeline', 'Metrics', 'Settings']
767
+ selected_page = st.radio("Select Page", pages, key='nav_radio')
768
+ st.session_state.current_page = selected_page
769
+
770
+ def render_dashboard(self):
771
+ """Render the dashboard view."""
772
+ st.header("System Dashboard")
773
+
774
+ # System Status
775
+ col1, col2, col3 = st.columns(3)
776
+ with col1:
777
+ st.metric("Pipeline Status", "Active")
778
+ with col2:
779
+ current_stage = getattr(self.agent.pipeline, 'current_stage', None)
780
+ stage_name = current_stage.name if current_stage else "None"
781
+ st.metric("Current Stage", stage_name)
782
+ with col3:
783
+ st.metric("Tasks Completed", "0")
784
+
785
+ # Recent Activity
786
+ st.subheader("Recent Activity")
787
+ activity_data = self.get_recent_activity()
788
+ if activity_data:
789
+ st.table(activity_data)
790
+ else:
791
+ st.info("No recent activity")
792
+
793
+ def render_pipeline_view(self):
794
+ """Render the pipeline view."""
795
+ st.header("Development Pipeline")
796
+
797
+ # Pipeline Stages
798
+ stages = {
799
+ 'PLANNING': "Planning",
800
+ 'DEVELOPMENT': "Development",
801
+ 'TESTING': "Testing"
802
+ }
803
+
804
+ for stage_key, stage_name in stages.items():
805
+ with st.expander(f"{stage_name} Stage"):
806
+ current_stage = getattr(self.agent.pipeline, 'current_stage', None)
807
+ if current_stage and stage_key == current_stage.name:
808
+ st.info("Current Stage")
809
+ self.render_stage_details(stage_key)
810
+
811
+ def render_metrics_view(self):
812
+ """Render the metrics view."""
813
+ st.header("System Metrics")
814
+
815
+ # Code Quality Metrics
816
+ st.subheader("Code Quality Metrics")
817
+ metrics = self.get_metrics()
818
+
819
+ if metrics:
820
+ for file, file_metrics in metrics.items():
821
+ with st.expander(f"Metrics for {file}"):
822
+ st.json(file_metrics)
823
+ else:
824
+ st.info("No metrics available yet")
825
+
826
+ def render_settings(self):
827
+ """Render the settings view."""
828
+ st.header("System Settings")
829
+
830
+ # General Settings
831
+ st.subheader("General Settings")
832
+ workspace_dir = st.text_input(
833
+ "Workspace Directory",
834
+ value=self.agent.workspace_manager.workspace_dir
835
+ )
836
+
837
+ # Pipeline Settings
838
+ st.subheader("Pipeline Settings")
839
+ quality_threshold = st.slider(
840
+ "Quality Threshold",
841
+ min_value=0.0,
842
+ max_value=1.0,
843
+ value=0.8,
844
+ step=0.1
845
+ )
846
+
847
+ if st.button("Save Settings"):
848
+ self.save_settings(workspace_dir, quality_threshold)
849
 
850
  def get_recent_activity(self) -> List[Dict]:
851
  """Get recent activity data for display."""
852
  return [
853
  {
854
+ "timestamp": activity["timestamp"].strftime("%Y-%m-%d %H:%M:%S"),
855
  "action": activity["action"],
856
  "status": activity["status"],
857
  "details": activity["details"]
 
859
  for activity in self.activity_log[-10:] # Show last 10 activities
860
  ]
861
 
862
+ def get_metrics(self) -> Dict:
863
+ """Get current metrics data."""
864
+ return getattr(self.agent.pipeline, 'metrics', {})
865
+
866
+ def render_stage_details(self, stage: str):
867
  """Render details for a specific pipeline stage."""
868
+ stage_results = getattr(self.agent.pipeline, f'{stage.lower()}_results', {})
869
 
870
  if not stage_results:
871
  st.write("No data available for this stage yet.")
872
  return
873
 
874
+ if stage == 'PLANNING':
 
875
  self._render_planning_details(stage_results)
876
+ elif stage == 'DEVELOPMENT':
877
  self._render_development_details(stage_results)
878
+ elif stage == 'TESTING':
879
  self._render_testing_details(stage_results)
880
 
881
  def _render_planning_details(self, results: Dict):
882
  """Render planning stage details."""
883
  st.subheader("Tasks")
884
+ tasks = results.get('tasks', [])
885
+ for task in tasks:
886
+ st.write(f"- {task}")
 
 
 
 
887
 
888
  def _render_development_details(self, results: Dict):
889
  """Render development stage details."""
890
+ st.subheader("Development Progress")
891
+ progress = results.get('progress', 0)
892
+ st.progress(progress)
893
 
894
+ files = results.get('files', [])
895
+ if files:
896
+ st.subheader("Modified Files")
897
+ for file in files:
898
+ st.write(f"- {file}")
899
 
900
  def _render_testing_details(self, results: Dict):
901
  """Render testing stage details."""
902
  st.subheader("Test Results")
903
 
904
+ tests = results.get('tests', {})
905
+ if tests:
906
+ passed = tests.get('passed', 0)
907
+ failed = tests.get('failed', 0)
908
+ st.write(f"Passed: {passed}")
909
+ st.write(f"Failed: {failed}")
910
+ else:
911
+ st.write("No test results available")
 
 
 
 
 
 
 
912
 
913
  def save_settings(self, workspace_dir: str, quality_threshold: float):
914
  """Save the system settings."""
915
  try:
 
916
  self.agent.workspace_manager.workspace_dir = workspace_dir
917
+ # Add more settings as needed
918
 
 
 
 
 
919
  self.log_activity({
920
  "timestamp": datetime.now(),
921
  "action": "Settings Update",
922
  "status": "Success",
923
+ "details": "Settings updated successfully"
924
  })
 
925
  st.success("Settings saved successfully!")
926
 
927
  except Exception as e:
 
930
  def log_activity(self, activity: Dict):
931
  """Log an activity in the system."""
932
  self.activity_log.append(activity)
933
+ if len(self.activity_log) > 100: # Keep only last 100 activities
 
934
  self.activity_log = self.activity_log[-100:]
935
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
936
  if __name__ == "__main__":
937
  app = AutonomousAgentApp()
938
+ app.run()