🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
fix: Gemini tool calling support (#1469)
Wendong-Fana62b8a8576e7
diff --git a/camel/messages/func_message.py b/camel/messages/func_message.pyindex 2e10f25d4..3c1d2575c 100644--- a/camel/messages/func_message.py+++ b/camel/messages/func_message.py@@ -129,7 +129,7 @@ class FunctionCallingMessage(BaseMessage):"content": self.content or "","tool_calls": [{- "id": self.tool_call_id or "",+ "id": self.tool_call_id or "null","type": "function","function": {"name": self.func_name,@@ -159,5 +159,5 @@ class FunctionCallingMessage(BaseMessage):return {"role": "tool","content": result_content,- "tool_call_id": self.tool_call_id or "",+ "tool_call_id": self.tool_call_id or "null",}diff --git a/camel/models/gemini_model.py b/camel/models/gemini_model.pyindex 1e5b6b670..2da873998 100644--- a/camel/models/gemini_model.py+++ b/camel/models/gemini_model.py@@ -97,8 +97,17 @@ class GeminiModel(BaseModelBackend):`ChatCompletion` in the non-stream mode, or`Stream[ChatCompletionChunk]` in the stream mode."""+ # Process messages to ensure no empty content, it's not accepeted by+ # Gemini+ processed_messages = []+ for msg in messages:+ msg_copy = msg.copy()+ if 'content' in msg_copy and msg_copy['content'] == '':+ msg_copy['content'] = 'null'+ processed_messages.append(msg_copy)+response = self._client.chat.completions.create(- messages=messages,+ messages=processed_messages,model=self.model_type,**self.model_config_dict,)diff --git a/test/messages/test_func_message.py b/test/messages/test_func_message.pyindex fb6b17b0b..c6e92bfaf 100644--- a/test/messages/test_func_message.py+++ b/test/messages/test_func_message.py@@ -92,7 +92,7 @@ def test_function_func_message(msg_dict: Dict[str, str] = {"role": "tool","content": json.dumps(3),- "tool_call_id": "",+ "tool_call_id": "null",}assert function_result_message.to_openai_tool_message() == msg_dict@@ -103,7 +103,7 @@ def test_assistant_func_message_to_openai_tool_message(expected_msg_dict: Dict[str, str] = {"role": "tool","content": json.dumps(None),- "tool_call_id": "",+ "tool_call_id": "null",}assert (