Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

fix: remove strict param in vllm model (#2134)

JINO ROHITd389d68a25d3
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 6baa4a87b..4ab7eb123 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -26,7 +26,7 @@ body:
attributes:
label: What version of camel are you using?
description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.
- placeholder: E.g., 0.2.42
+ placeholder: E.g., 0.2.43
validations:
required: true
diff --git a/camel/__init__.py b/camel/__init__.py
index 2d28429e3..c35dd6996 100644
--- a/camel/__init__.py
+++ b/camel/__init__.py
@@ -14,7 +14,7 @@
from camel.logger import disable_logging, enable_logging, set_log_level
-__version__ = '0.2.42'
+__version__ = '0.2.43'
__all__ = [
'__version__',
diff --git a/camel/models/azure_openai_model.py b/camel/models/azure_openai_model.py
index 135cb9a30..80fe2d19c 100644
--- a/camel/models/azure_openai_model.py
+++ b/camel/models/azure_openai_model.py
@@ -219,9 +219,13 @@ class AzureOpenAIModel(BaseModelBackend):
response_format: Type[BaseModel],
tools: Optional[List[Dict[str, Any]]] = None,
) -> ChatCompletion:
- request_config = self.model_config_dict.copy()
+ import copy
+
+ request_config = copy.deepcopy(self.model_config_dict)
request_config["response_format"] = response_format
+ # Remove stream from request config since OpenAI does not support it
+ # with structured response
request_config.pop("stream", None)
if tools is not None:
request_config["tools"] = tools
@@ -238,9 +242,13 @@ class AzureOpenAIModel(BaseModelBackend):
response_format: Type[BaseModel],
tools: Optional[List[Dict[str, Any]]] = None,
) -> ChatCompletion:
- request_config = self.model_config_dict.copy()
+ import copy
+
+ request_config = copy.deepcopy(self.model_config_dict)
request_config["response_format"] = response_format
+ # Remove stream from request config since OpenAI does not support it
+ # with structured response
request_config.pop("stream", None)
if tools is not None:
request_config["tools"] = tools
diff --git a/camel/models/cohere_model.py b/camel/models/cohere_model.py
index eeaebd3ef..544825410 100644
--- a/camel/models/cohere_model.py
+++ b/camel/models/cohere_model.py
@@ -227,7 +227,11 @@ class CohereModel(BaseModelBackend):
response_format: Optional[Type[BaseModel]] = None,
tools: Optional[List[Dict[str, Any]]] = None,
) -> Dict[str, Any]:
- request_config = self.model_config_dict.copy()
+ import copy
+
+ request_config = copy.deepcopy(self.model_config_dict)
+ # Remove strict from each tool's function parameters since Cohere does
+ # not support them
if tools:
for tool in tools:
function_dict = tool.get('function', {})
diff --git a/camel/models/deepseek_model.py b/camel/models/deepseek_model.py
index da702c829..aa1d837f0 100644
--- a/camel/models/deepseek_model.py
+++ b/camel/models/deepseek_model.py
@@ -145,7 +145,11 @@ class DeepSeekModel(BaseModelBackend):
for key, value in request_config.items()
if key not in REASONSER_UNSUPPORTED_PARAMS
}
+ import copy
+ request_config = copy.deepcopy(self.model_config_dict)
+ # Remove strict from each tool's function parameters since DeepSeek
+ # does not support them
if tools:
for tool in tools:
function_dict = tool.get('function', {})
diff --git a/camel/models/gemini_model.py b/camel/models/gemini_model.py
index 948586d79..87328b8de 100644
--- a/camel/models/gemini_model.py
+++ b/camel/models/gemini_model.py
@@ -172,8 +172,11 @@ class GeminiModel(BaseModelBackend):
messages: List[OpenAIMessage],
tools: Optional[List[Dict[str, Any]]] = None,
) -> Union[ChatCompletion, Stream[ChatCompletionChunk]]:
- request_config = self.model_config_dict.copy()
+ import copy
+ request_config = copy.deepcopy(self.model_config_dict)
+ # Remove strict and anyOf from each tool's function parameters since
+ # Gemini does not support them
if tools:
for tool in tools:
function_dict = tool.get('function', {})
@@ -209,8 +212,11 @@ class GeminiModel(BaseModelBackend):
messages: List[OpenAIMessage],
tools: Optional[List[Dict[str, Any]]] = None,
) -> Union[ChatCompletion, AsyncStream[ChatCompletionChunk]]:
- request_config = self.model_config_dict.copy()
+ import copy
+ request_config = copy.deepcopy(self.model_config_dict)
+ # Remove strict and anyOf from each tool's function parameters since
+ # Gemini does not support them
if tools:
for tool in tools:
function_dict = tool.get('function', {})
diff --git a/camel/models/ollama_model.py b/camel/models/ollama_model.py
index c50595472..b61eeafb7 100644
--- a/camel/models/ollama_model.py
+++ b/camel/models/ollama_model.py
@@ -250,8 +250,11 @@ class OllamaModel(BaseModelBackend):
response_format: Type[BaseModel],
tools: Optional[List[Dict[str, Any]]] = None,
) -> ChatCompletion:
- request_config = self.model_config_dict.copy()
+ import copy
+ request_config = copy.deepcopy(self.model_config_dict)
+ # Remove stream from request_config since Ollama does not support it
+ # when structured response is used
request_config["response_format"] = response_format
request_config.pop("stream", None)
if tools is not None:
@@ -269,8 +272,11 @@ class OllamaModel(BaseModelBackend):
response_format: Type[BaseModel],
tools: Optional[List[Dict[str, Any]]] = None,
) -> ChatCompletion:
- request_config = self.model_config_dict.copy()
+ import copy
+ request_config = copy.deepcopy(self.model_config_dict)
+ # Remove stream from request_config since Ollama does not support it
+ # when structured response is used
request_config["response_format"] = response_format
request_config.pop("stream", None)
if tools is not None:
diff --git a/camel/models/openai_compatible_model.py b/camel/models/openai_compatible_model.py
index 096a5b73c..07e39ecb5 100644
--- a/camel/models/openai_compatible_model.py
+++ b/camel/models/openai_compatible_model.py
@@ -177,8 +177,11 @@ class OpenAICompatibleModel(BaseModelBackend):
response_format: Type[BaseModel],
tools: Optional[List[Dict[str, Any]]] = None,
) -> ChatCompletion:
- request_config = self.model_config_dict.copy()
+ import copy
+ request_config = copy.deepcopy(self.model_config_dict)
+ # Remove stream from request_config since OpenAI does not support it
+ # when structured response is used
request_config["response_format"] = response_format
request_config.pop("stream", None)
if tools is not None:
@@ -196,8 +199,11 @@ class OpenAICompatibleModel(BaseModelBackend):
response_format: Type[BaseModel],
tools: Optional[List[Dict[str, Any]]] = None,
) -> ChatCompletion:
- request_config = self.model_config_dict.copy()
+ import copy
+ request_config = copy.deepcopy(self.model_config_dict)
+ # Remove stream from request_config since OpenAI does not support it
+ # when structured response is used
request_config["response_format"] = response_format
request_config.pop("stream", None)
if tools is not None:
diff --git a/camel/models/openai_model.py b/camel/models/openai_model.py
index 9e01ffb2b..a6c9497ba 100644
--- a/camel/models/openai_model.py
+++ b/camel/models/openai_model.py
@@ -247,7 +247,9 @@ class OpenAIModel(BaseModelBackend):
messages: List[OpenAIMessage],
tools: Optional[List[Dict[str, Any]]] = None,
) -> Union[ChatCompletion, Stream[ChatCompletionChunk]]:
- request_config = self.model_config_dict.copy()
+ import copy
+
+ request_config = copy.deepcopy(self.model_config_dict)
if tools:
request_config["tools"] = tools
@@ -265,7 +267,9 @@ class OpenAIModel(BaseModelBackend):
messages: List[OpenAIMessage],
tools: Optional[List[Dict[str, Any]]] = None,
) -> Union[ChatCompletion, AsyncStream[ChatCompletionChunk]]:
- request_config = self.model_config_dict.copy()
+ import copy
+
+ request_config = copy.deepcopy(self.model_config_dict)
if tools:
request_config["tools"] = tools
@@ -284,9 +288,13 @@ class OpenAIModel(BaseModelBackend):
response_format: Type[BaseModel],
tools: Optional[List[Dict[str, Any]]] = None,
) -> ChatCompletion:
- request_config = self.model_config_dict.copy()
+ import copy
+
+ request_config = copy.deepcopy(self.model_config_dict)
request_config["response_format"] = response_format
+ # Remove stream from request config since OpenAI does not support it
+ # with structured response
request_config.pop("stream", None)
if tools is not None:
request_config["tools"] = tools
@@ -305,9 +313,13 @@ class OpenAIModel(BaseModelBackend):
response_format: Type[BaseModel],
tools: Optional[List[Dict[str, Any]]] = None,
) -> ChatCompletion:
- request_config = self.model_config_dict.copy()
+ import copy
+
+ request_config = copy.deepcopy(self.model_config_dict)
request_config["response_format"] = response_format
+ # Remove stream from request config since OpenAI does not support it
+ # with structured response
request_config.pop("stream", None)
if tools is not None:
request_config["tools"] = tools
diff --git a/camel/models/vllm_model.py b/camel/models/vllm_model.py
index e96bf13f0..a076a7c30 100644
--- a/camel/models/vllm_model.py
+++ b/camel/models/vllm_model.py
@@ -235,14 +235,20 @@ class VLLMModel(BaseModelBackend):
request_config["response_format"] = response_format
request_config.pop("stream", None)
if tools is not None:
- request_config["tools"] = tools
- # Remove additionalProperties from each tool's function parameters
+ # Create a deep copy of tools to avoid modifying the original
+ import copy
+
+ request_config["tools"] = copy.deepcopy(tools)
+ # Remove additionalProperties and strict from each tool's function
+ # parameters since vLLM does not support them
if "tools" in request_config:
for tool in request_config["tools"]:
if "function" in tool and "parameters" in tool["function"]:
tool["function"]["parameters"].pop(
"additionalProperties", None
)
+ if "strict" in tool.get("function", {}):
+ tool["function"].pop("strict")
return self._client.beta.chat.completions.parse(
messages=messages,
@@ -261,14 +267,20 @@ class VLLMModel(BaseModelBackend):
request_config["response_format"] = response_format
request_config.pop("stream", None)
if tools is not None:
- request_config["tools"] = tools
- # Remove additionalProperties from each tool's function parameters
+ # Create a deep copy of tools to avoid modifying the original
+ import copy
+
+ request_config["tools"] = copy.deepcopy(tools)
+ # Remove additionalProperties and strict from each tool's function
+ # parameters since vLLM does not support them
if "tools" in request_config:
for tool in request_config["tools"]:
if "function" in tool and "parameters" in tool["function"]:
tool["function"]["parameters"].pop(
"additionalProperties", None
)
+ if "strict" in tool.get("function", {}):
+ tool["function"].pop("strict")
return await self._async_client.beta.chat.completions.parse(
messages=messages,
diff --git a/docs/conf.py b/docs/conf.py
index 481041ff7..2f7707266 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -27,7 +27,7 @@ sys.path.insert(0, os.path.abspath('..'))
project = 'CAMEL'
copyright = '2024, CAMEL-AI.org'
author = 'CAMEL-AI.org'
-release = '0.2.42'
+release = '0.2.43'
html_favicon = (
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'
diff --git a/docs/key_modules/loaders.md b/docs/key_modules/loaders.md
index 4081200e0..42728543f 100644
--- a/docs/key_modules/loaders.md
+++ b/docs/key_modules/loaders.md
@@ -340,14 +340,14 @@ response = jina_reader.read_content("https://docs.camel-ai.org/")
print(response)
```
```markdown
->>>Welcome to CAMEL’s documentation! — CAMEL 0.2.42 documentation
+>>>Welcome to CAMEL’s documentation! — CAMEL 0.2.43 documentation
===============
[Skip to main content](https://docs.camel-ai.org/#main-content)
Back to top Ctrl+K
- [![Image 1](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png) ![Image 2](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png)CAMEL 0.2.42](https://docs.camel-ai.org/#)
+ [![Image 1](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png) ![Image 2](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png)CAMEL 0.2.43](https://docs.camel-ai.org/#)
Search Ctrl+K
diff --git a/pyproject.toml b/pyproject.toml
index 956c31f39..1912ccb38 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "camel-ai"
-version = "0.2.42"
+version = "0.2.43"
description = "Communicative Agents for AI Society Study"
authors = [{ name = "CAMEL-AI.org" }]
requires-python = ">=3.10,<3.13"
diff --git a/uv.lock b/uv.lock
index 72b7df9e0..b258c29ef 100644
--- a/uv.lock
+++ b/uv.lock
@@ -543,7 +543,7 @@ wheels = [
[[package]]
name = "camel-ai"
-version = "0.2.42"
+version = "0.2.43"
source = { editable = "." }
dependencies = [
{ name = "colorama" },