less debug info when errors happen (#1233)

* less debug info when errors happen

* add another traceback

* better prompt debugs

* remove unuse arg
This commit is contained in:
Robert Brennan 2024-04-19 15:15:38 -04:00 committed by GitHub
parent 0a59d46ca3
commit d61fdb8bba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 10 deletions

View File

@ -50,7 +50,7 @@ class ActionManager:
except Exception as e:
observation = AgentErrorObservation(str(e))
logger.error(e)
traceback.print_exc()
logger.debug(traceback.format_exc())
return observation
def run_command(self, command: str, background=False) -> CmdOutputObservation:

View File

@ -1,5 +1,6 @@
import asyncio
import time
import traceback
from typing import Callable, List
from litellm.exceptions import APIConnectionError
@ -169,12 +170,13 @@ class AgentController:
observation: Observation = NullObservation('')
try:
action = self.agent.step(self.state)
logger.info(action, extra={'msg_type': 'ACTION'})
if action is None:
raise AgentNoActionError()
logger.info(action, extra={'msg_type': 'ACTION'})
except Exception as e:
observation = AgentErrorObservation(str(e))
logger.error(e)
logger.debug(traceback.format_exc())
if isinstance(e, APIConnectionError):
time.sleep(3)

View File

@ -46,7 +46,10 @@ class LLM:
messages = kwargs['messages']
else:
messages = args[1]
llm_prompt_logger.debug(messages)
debug_message = ''
for message in messages:
debug_message += '\n\n----------\n\n' + message['content']
llm_prompt_logger.debug(debug_message)
resp = completion_unwrapped(*args, **kwargs)
message_back = resp['choices'][0]['message']['content']
llm_response_logger.debug(message_back)

View File

@ -26,12 +26,6 @@ def parse_arguments():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser(
description='Run an agent with a specific task')
parser.add_argument(
'-d',
'--directory',
type=str,
help='The working directory for the agent',
)
parser.add_argument(
'-t', '--task', type=str, default='', help='The task for the agent to perform'
)
@ -89,7 +83,7 @@ async def main():
'No task provided. Please specify a task through -t, -f.')
print(
f'Running agent {args.agent_cls} (model: {args.model_name}, directory: {args.directory}) with task: "{task}"'
f'Running agent {args.agent_cls} (model: {args.model_name}) with task: "{task}"'
)
llm = LLM(args.model_name)
AgentCls: Type[Agent] = Agent.get_cls(args.agent_cls)