acecalisto3 commited on
Commit
f6dbbdc
·
verified ·
1 Parent(s): f3e820f

Update definitions.py

Browse files
Files changed (1) hide show
  1. definitions.py +71 -72
definitions.py CHANGED
@@ -342,88 +342,87 @@ class AutonomousAgent:
342
  '/help': self.handle_help_command,
343
  '/modify': self.handle_modify_command
344
  }
 
345
 
346
- def render_chat_interface(self):
347
- """Render the chat interface in Streamlit sidebar."""
348
- with st.sidebar:
349
- st.markdown("---")
350
- st.subheader("System Chat")
351
 
352
- # Chat controls
353
  if st.button("Clear Chat History"):
354
  self.clear_chat_history()
355
-
356
- # Chat history display
357
- chat_container = st.container()
358
  with chat_container:
359
  for message in self.chat_history:
360
  self._render_message(message)
361
 
362
- # Input area
363
- user_input = st.text_input("Type message/command...", key="chat_input")
364
- if st.button("Send", key="send_message"):
365
  self.process_user_input(user_input)
366
 
367
- def handle_task_command(self, input_data: Dict):
368
- """Handle task command."""
369
- self.logger.info("Handling task command")
370
- task = input_data["task"]
371
- self.app.refinement_loop.run_refinement_cycle(task)
372
- return "Task command handled"
373
-
374
- def handle_status_command(self, input_data: Dict):
375
- """Handle status command."""
376
- self.logger.info("Handling status command")
377
- status = input_data["status"]
378
- self.app.refinement_loop.get_refinement_history()
379
- return "Status command handled"
380
-
381
- def handle_stop_command(self, input_data: Dict):
382
- """Handle stop command."""
383
- self.logger.info("Handling stop command")
384
- stop = input_data["stop"]
385
- self.app.refinement_loop.stop_refinement_cycle()
386
- return "Stop command handled"
387
-
388
- def handle_help_command(self, input_data: Dict):
389
- """Handle help command."""
390
- self.logger.info("Handling help command")
391
- help_message = """
392
- Here are some available commands:
393
-
394
- /task <task_name> - Run the autonomous agent with the given task.
395
- /status - Get the current status of the refinement cycle.
396
- /stop - Stop the refinement cycle.
397
- /help - Show this help message.
398
- """
399
- return help_message
400
-
401
- def handle_modify_command(self, input_data: Dict):
402
- """Handle modify command."""
403
- self.logger.info("Handling modify command")
404
- modify = input_data["modify"]
405
- # Add logic to handle modify command
406
- return "Modify command handled"
407
-
408
- def clear_chat_history(self):
409
- """Clear the chat history."""
410
- self.logger.info("Clearing chat history")
411
- self.chat_history.clear()
412
- return "Chat history cleared"
413
-
414
- def _render_message(self, message: str):
415
- """Render a chat message."""
416
- st.write(message)
417
-
418
- def process_user_input(self, user_input: str):
419
- """Process user input."""
420
- self.logger.info("Processing user input")
421
- command = user_input.strip().split()[0]
422
- if command in self.command_handlers:
423
- result = self.command_handlers[command]({"input": user_input})
424
- self.chat_history.append(f"User: {user_input}")
425
- self.chat_history.append(f"System: {result}")
426
-
427
 
428
  class DevelopmentAgent:
429
  """Development agent."""
 
342
  '/help': self.handle_help_command,
343
  '/modify': self.handle_modify_command
344
  }
345
+ self.logger = logging.getLogger(__name__) # Define the logger attribute
346
 
347
+ def render_chat_interface(self):
348
+ """Render the chat interface in Streamlit sidebar."""
349
+ with st.sidebar:
350
+ st.markdown("---")
351
+ st.subheader("System Chat")
352
 
353
+ # Chat controls
354
  if st.button("Clear Chat History"):
355
  self.clear_chat_history()
356
+ # Chat history display
357
+ chat_container = st.container()
 
358
  with chat_container:
359
  for message in self.chat_history:
360
  self._render_message(message)
361
 
362
+ # Input area
363
+ user_input = st.text_input("Type message/command...", key="chat_input")
364
+ if st.button("Send", key="send_message"):
365
  self.process_user_input(user_input)
366
 
367
+ def handle_task_command(self, input_data: Dict):
368
+ """Handle task command."""
369
+ self.logger.info("Handling task command")
370
+ task = input_data["task"]
371
+ self.app.refinement_loop.run_refinement_cycle(task)
372
+ return "Task command handled"
373
+
374
+ def handle_status_command(self, input_data: Dict):
375
+ """Handle status command."""
376
+ self.logger.info("Handling status command")
377
+ status = input_data["status"]
378
+ self.app.refinement_loop.get_refinement_history()
379
+ return "Status command handled"
380
+
381
+ def handle_stop_command(self, input_data: Dict):
382
+ """Handle stop command."""
383
+ self.logger.info("Handling stop command")
384
+ stop = input_data["stop"]
385
+ self.app.refinement_loop.stop_refinement_cycle()
386
+ return "Stop command handled"
387
+
388
+ def handle_help_command(self, input_data: Dict):
389
+ """Handle help command."""
390
+ self.logger.info("Handling help command")
391
+ help_message = """
392
+ Here are some available commands:
393
+
394
+ /task <task_name> - Run the autonomous agent with the given task.
395
+ /status - Get the current status of the refinement cycle.
396
+ /stop - Stop the refinement cycle.
397
+ /help - Show this help message.
398
+ """
399
+ return help_message
400
+
401
+ def handle_modify_command(self, input_data: Dict):
402
+ """Handle modify command."""
403
+ self.logger.info("Handling modify command")
404
+ modify = input_data["modify"]
405
+ # Add logic to handle modify command
406
+ return "Modify command handled"
407
+
408
+ def clear_chat_history(self):
409
+ """Clear the chat history."""
410
+ self.logger.info("Clearing chat history")
411
+ self.chat_history.clear()
412
+ return "Chat history cleared"
413
+
414
+ def _render_message(self, message: str):
415
+ """Render a chat message."""
416
+ st.write(message)
417
+
418
+ def process_user_input(self, user_input: str):
419
+ """Process user input."""
420
+ self.logger.info("Processing user input")
421
+ command = user_input.strip().split()[0]
422
+ if command in self.command_handlers:
423
+ result = self.command_handlers[command]({"input": user_input})
424
+ self.chat_history.append(f"User: {user_input}")
425
+ self.chat_history.append(f"System: {result}")
 
426
 
427
  class DevelopmentAgent:
428
  """Development agent."""