Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(agent/profile_generator): Improve robustness by leveraging `create_chat_completion`'s parse handling

Reinier van der Leera9b7b175fff9
diff --git a/autogpts/autogpt/autogpt/agent_factory/profile_generator.py b/autogpts/autogpt/autogpt/agent_factory/profile_generator.py
index 8d9ff399e8..ea4a602e49 100644
--- a/autogpts/autogpt/autogpt/agent_factory/profile_generator.py
+++ b/autogpts/autogpt/autogpt/agent_factory/profile_generator.py
@@ -238,18 +238,14 @@ async def generate_agent_profile_for_task(
prompt = agent_profile_generator.build_prompt(task)
# Call LLM with the string as user input
- output = (
- await llm_provider.create_chat_completion(
- prompt.messages,
- model_name=app_config.smart_llm,
- functions=prompt.functions,
- )
- ).response
+ output = await llm_provider.create_chat_completion(
+ prompt.messages,
+ model_name=app_config.smart_llm,
+ functions=prompt.functions,
+ completion_parser=agent_profile_generator.parse_response_content,
+ )
# Debug LLM Output
- logger.debug(f"AI Config Generator Raw Output: {output}")
-
- # Parse the output
- ai_profile, ai_directives = agent_profile_generator.parse_response_content(output)
+ logger.debug(f"AI Config Generator Raw Output: {output.response}")
- return ai_profile, ai_directives
+ return output.parsed_result