Skip to content

Commit

Permalink
Control image count
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudotensor committed Nov 7, 2024
1 parent ac1b5bd commit b384043
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
10 changes: 9 additions & 1 deletion openai_server/agent_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def get_ret_dict_and_handle_files(chat_result, chat_result_planning,
agent_venv_dir, agent_code_writer_system_message, agent_system_site_packages,
system_message_parts,
autogen_code_restrictions_level, autogen_silent_exchange,
agent_accuracy,
client_metadata=''):
# DEBUG
if agent_verbose:
Expand Down Expand Up @@ -227,7 +228,14 @@ def get_ret_dict_and_handle_files(chat_result, chat_result_planning,

image_files, non_image_files = identify_image_files(file_list)
# keep no more than 10 image files among latest files created
image_files = image_files[-10:]
if agent_accuracy == 'maximum':
pass
elif agent_accuracy == 'standard':
image_files = image_files[-20:]
elif agent_accuracy == 'basic':
image_files = image_files[-10:]
else:
image_files = image_files[-5:]
file_list = image_files + non_image_files

# guardrail artifacts even if LLM never saw them, shouldn't show user either
Expand Down
1 change: 1 addition & 0 deletions openai_server/autogen_2agent_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ def code_writer_terminate_func(msg):
agent_system_site_packages,
system_message_parts,
autogen_code_restrictions_level, autogen_silent_exchange,
agent_accuracy,
client_metadata=client_metadata)
if client_metadata:
print("END FILES FOR 2AGENT: client_metadata: %s" % client_metadata, flush=True)
Expand Down
3 changes: 2 additions & 1 deletion openai_server/autogen_multi_agent_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def run_autogen_multi_agent(query=None,
agent_venv_dir, agent_code_writer_system_message,
agent_system_site_packages,
system_message_parts,
autogen_code_restrictions_level, autogen_silent_exchange)
autogen_code_restrictions_level, autogen_silent_exchange,
agent_accuracy)

return ret_dict
5 changes: 3 additions & 2 deletions openai_server/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ def convert_messages_to_structure(
assert content, "Missing content"

if previous_role == role and role != "tool":
print(f"bad messages: {messages}")
raise ValueError(
"Consecutive messages with the same role are not allowed: %s %s\n\n%s"
% (previous_role, role, messages)
"Consecutive messages with the same role are not allowed: %s %s"
% (previous_role, role)
)
previous_role = role

Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "61b6b30f9b8a64dda74893bf76727dc7d0262dd0"
__version__ = "ac1b5bd626665b443aa3c4a6986ebfb80f92b47d"

0 comments on commit b384043

Please sign in to comment.