From e06e898486304ce72a53b5e783ab48c3c4db0b34 Mon Sep 17 00:00:00 2001 From: Sambhav Dixit <94298612+sambhavnoobcoder@users.noreply.github.com> Date: Fri, 25 Oct 2024 02:58:47 +0530 Subject: [PATCH] add section for 'choice' based responses . - when response is a choice , this determines how it is handled. - current implementation uses a placeholder for llm_output_parser , it needs to be updated ( next commit ) --- swarms/structs/agent.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/swarms/structs/agent.py b/swarms/structs/agent.py index 29d7037b..49da5987 100644 --- a/swarms/structs/agent.py +++ b/swarms/structs/agent.py @@ -812,6 +812,15 @@ class Agent: *response_args, **kwargs ) + # Check if response is a dictionary and has 'choices' key + if isinstance(response, dict) and 'choices' in response: + response = response['choices'][0]['message']['content'] + elif isinstance(response, str): + # If response is already a string, use it as is + pass + else: + raise ValueError(f"Unexpected response format: {type(response)}") + # Check and execute tools if self.tools is not None: print(f"self.tools is not None: {response}")