Контекст ограничения автогенаPython

Программы на Python
Ответить
Anonymous
 Контекст ограничения автогена

Сообщение Anonymous »

Я пытаюсь создать конвейер агента, который создает модульные тесты для проекта Java.
Проблема в том, что контекст может стать длинным, поскольку агент читает и записывает файлы, но такие вызовы инструментов могут быть удалены из контекста.
Я пытался использовать MessageHistoryLimiter, но иногда он выходит из контекста или забывает, где он загружал Java-файлы, или получает ошибку инструмента, потому что он удаляет вызов инструмента, не удаляя его. ответ. Как я могу его улучшить?
Код:
from autogen import (AssistantAgent, UserProxyAgent, register_function, GroupChat, GroupChatManager)
from autogen.agentchat.contrib.capabilities import transform_messages, transforms
import os_crawl
from common import getModel, termination_msg
from dotenv import load_dotenv

load_dotenv()
proj_path = "C:\\Users\\2252\\Desktop\\projects\\findom-findomwebnew"
max_rounds = 50

llm_config = { "config_list": [getModel("gpt-4o", "OPENAI_API_KEY", 0.3)] }
termination_notice = (
'\n\nDo not show appreciation in your responses, say only what is necessary. '
'if "Thank you" or "You\'re welcome" are said in the conversation, then say TERMINATE '
'to indicate the conversation is finished and this is your last message.'
)

user_proxy = UserProxyAgent("user",
is_termination_msg=termination_msg,
default_auto_reply=termination_notice,
code_execution_config=False,
max_consecutive_auto_reply=2,
human_input_mode="NEVER")

#tester
tester = AssistantAgent("tester", llm_config=llm_config,
system_message="""You are an agent emulating a Senior Java tester.
You will write unit tests for the project provided. Genereate at least one test scenario for each class' method.
When you generate a test class, make sure to write it to a separate file using the Write to file tool.'
You can and must use your tool to fetch the project structure and take a look at all files that may contain code.
Reply 'TERMINATE' when you have finished with all the tests.""" +termination_notice,
description="Senior Java Tester who can write code to solve problems and answer questions.",
human_input_mode="NEVER",
is_termination_msg=termination_msg,
code_execution_config=False)

register_function(os_crawl.list_directories_and_files, caller=tester, executor=tester,
description="List directories and files")
register_function(os_crawl.read_file_content, caller=tester, executor=tester,
description="Read file content")
register_function(os_crawl.write_to_file, caller=tester, executor=tester,
description="Write content to file. If file does not exist, create it.")
register_function(os_crawl.create_directory, caller=tester, executor=tester,
description="Create directory")
register_function(os_crawl.delete_file, caller=tester, executor=tester,
description="Delete file")

# handle long context
select_speaker_compression_args = dict(
model_name="microsoft/llmlingua-2-xlm-roberta-large-meetingbank", use_llmlingua2=True, device_map="cpu"
)

select_speaker_transforms = transform_messages.TransformMessages(
transforms=[
transforms.MessageHistoryLimiter(max_messages=21, keep_first_message=True)
]
)

if __name__ == "__main__":
groupchat = GroupChat([user_proxy, tester],
messages=[],
max_round=max_rounds,
select_speaker_transform_messages=select_speaker_transforms,
speaker_selection_method="auto")

manager = GroupChatManager(groupchat=groupchat, llm_config=llm_config)

user_proxy.initiate_chat(manager,
message=f"""Create all the tests for the project '{proj_path}' """)


Подробнее здесь: https://stackoverflow.com/questions/792 ... ng-context
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»