Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion camel/configs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
from .cometapi_config import COMETAPI_API_PARAMS, CometAPIConfig
from .crynux_config import CRYNUX_API_PARAMS, CrynuxConfig
from .deepseek_config import DEEPSEEK_API_PARAMS, DeepSeekConfig
from .function_gemma_config import FUNCTION_GEMMA_API_PARAMS, FunctionGemmaConfig
from .function_gemma_config import (
FUNCTION_GEMMA_API_PARAMS,
FunctionGemmaConfig,
)
from .gemini_config import Gemini_API_PARAMS, GeminiConfig
from .groq_config import GROQ_API_PARAMS, GroqConfig
from .internlm_config import INTERNLM_API_PARAMS, InternLMConfig
Expand Down
4 changes: 2 additions & 2 deletions camel/configs/function_gemma_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
# ========= Copyright 2023-2025 @ CAMEL-AI.org. All Rights Reserved. =========
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -10,7 +10,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
# ========= Copyright 2023-2025 @ CAMEL-AI.org. All Rights Reserved. =========
from __future__ import annotations

from typing import List, Optional
Expand Down
28 changes: 15 additions & 13 deletions camel/models/function_gemma_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
# ========= Copyright 2023-2025 @ CAMEL-AI.org. All Rights Reserved. =========
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -10,7 +10,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
# ========= Copyright 2023-2025 @ CAMEL-AI.org. All Rights Reserved. =========
import json
import os
import re
Expand Down Expand Up @@ -279,25 +279,25 @@ def _format_model_turn(self, message: OpenAIMessage) -> str:
str: Formatted model turn.
"""
content = message.get("content", "") or ""
tool_calls = message.get("tool_calls", [])
tool_calls = message.get("tool_calls")

result = f"<start_of_turn>model\n{content}"

if tool_calls:
if tool_calls and isinstance(tool_calls, list):
for tool_call in tool_calls:
func = tool_call.get("function", {})
func_name = func.get("name", "")
args = func.get("arguments", "{}")
if isinstance(args, str):
args = json.loads(args)
args_raw = func.get("arguments", "{}")
if isinstance(args_raw, str):
args: Dict[str, Any] = json.loads(args_raw)
else:
args = dict(args_raw) if args_raw else {}

# format arguments
arg_parts = []
for key, value in sorted(args.items()):
if isinstance(value, str):
arg_parts.append(
f"{key}:{self._escape_string(value)}"
)
arg_parts.append(f"{key}:{self._escape_string(value)}")
else:
arg_parts.append(f"{key}:{json.dumps(value)}")

Expand All @@ -324,6 +324,8 @@ def _format_tool_response(self, message: OpenAIMessage) -> str:

# try to parse content as json for structured response
try:
if not isinstance(content, str):
content = str(content) if content else ""
result_data = json.loads(content)
# check if it's a dict (structured response)
if isinstance(result_data, dict):
Expand Down Expand Up @@ -552,7 +554,7 @@ def _parse_function_args(self, args_str: str) -> Dict[str, Any]:
Returns:
Dict[str, Any]: Parsed arguments dictionary.
"""
args = {}
args: Dict[str, Any] = {}
if not args_str:
return args

Expand All @@ -567,7 +569,7 @@ def _parse_function_args(self, args_str: str) -> Dict[str, Any]:
char = args_str[i]

# check for <escape> tag
if args_str[i:i+8] == "<escape>":
if args_str[i : i + 8] == "<escape>":
in_escape = not in_escape
i += 8
continue
Expand Down Expand Up @@ -627,7 +629,7 @@ def _parse_value(self, value: str) -> Any:
# return as string
return value

def _to_chat_completion(
def _to_chat_completion( # type: ignore[override]
self,
response_text: str,
model: str,
Expand Down
Loading