Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: address logger output issue #43

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 1 addition & 58 deletions src/agents/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def run(self):

def setup_logger(self):
logger = logging.getLogger(f"{self.agent_name} Logger")
# logger.setLevel(logging.INFO) # Set the minimum logging level
logger.setLevel(logging.INFO) # Set the minimum logging level
# logger.disabled = True
date_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
# Provide two log modes: console and file
Expand Down Expand Up @@ -116,63 +116,6 @@ def listen(self, agent_process):
return agent_process.get_response()


def check_tool_use(self, prompt, tool_info, temperature=0.):
prompt = f'You are allowed to use the following tools: \n\n```{tool_info}```\n\n' \
f'Do you think the response ```{prompt}``` calls any tool?\n' \
f'Only answer "Yes" or "No".'
response, waiting_time, turnaround_time = self.get_response(prompt, temperature)
# print(f'Tool use check: {response}')
if 'yes' in response.lower():
return True, waiting_time, turnaround_time
if 'no' in response.lower():
return False, waiting_time, turnaround_time
# print(f'Temperature: {temperature}')

self.logger.error('No valid format output when calling "Tool use check".')
return None, waiting_time, turnaround_time
# exit(1)

def get_prompt(self, tool_info, flow_ptr, task_description, cur_progress):
progress_str = '\n'.join(cur_progress)
prompt = f'{tool_info}\n\nCurrent Progress:\n{progress_str}\n\nTask description: {task_description}\n\n' \
f'Question: {flow_ptr.get_instruction()}\n\nOnly answer the current instruction and do not be verbose.'
return prompt

def get_tool_arg(self, prompt, tool_info, selected_tool):
prompt = f'{tool_info}\n\n' \
f'You attempt to use the tool ```{selected_tool}```. ' \
f'What is the input argument to call tool for this step: ```{prompt}```? ' \
f'Respond "None" if no arguments are needed for this tool. Separate by comma if there are multiple arguments. Do not be verbose!'
response, waiting_time, turnaround_time = self.get_response(prompt)
# print(f'Parameters: {response}')
return response, waiting_time, turnaround_time

def check_tool_name(self, prompt, tool_list, temperature=0.):
prompt = f'Choose the used tool of ```{prompt}``` from the following options:\n'
for i, key in enumerate(tool_list):
prompt += f'{i + 1}: {key}.\n'
prompt += "Your answer should be only an number, referring to the desired choice. Don't be verbose!"
response, waiting_time, turnaround_time = self.get_response(prompt, temperature=temperature)
if response.isdigit() and 1 <= int(response) <= len(tool_list):
response = int(response)
return tool_list[response - 1], waiting_time, turnaround_time
else:
return None, waiting_time, turnaround_time

def check_branch(self, prompt, flow_ptr, temperature=0.):
possible_keys = list(flow_ptr.branch.keys())
prompt = f'Choose the closest representation of ```{prompt}``` from the following options:\n'
for i, key in enumerate(possible_keys):
prompt += f'{i + 1}: {key}.\n'
prompt += "Your answer should be only an number, referring to the desired choice. Don't be verbose!"
response, waiting_time, turnaround_time = self.get_response(prompt=prompt, temperature=temperature)
if response.isdigit() and 1 <= int(response) <= len(possible_keys):
response = int(response)
return possible_keys[response - 1], waiting_time, turnaround_time
else:
return None, waiting_time, turnaround_time


def get_final_result(self, prompt):
prompt = f"Given the interaction history: {prompt}, give the answer to the task input and don't be verbose!"
final_result, waiting_time, turnaround_time = self.get_response(prompt)
Expand Down