diff --git a/src/ragent/__init__.py b/src/ragent/__init__.py index 2e6554a..93f86b7 100644 --- a/src/ragent/__init__.py +++ b/src/ragent/__init__.py @@ -200,12 +200,12 @@ class Agent: def communicate(self, message: str,role:str="user"): log.debug(f"Sending message: {message} to assistant {self.assistant.id} in thread {self.thread.id}.") - messages = isinstance(message, list) and message or [message] + messages = hasattr(message, "__iter__") and message or [message] for message in messages: if isinstance(message, dict): + message_role = message["role"] message = message["content"] - message_role = message["content"] else: message_role = role self.client.beta.threads.messages.create(