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: stream bugs and update siliconflow_model_example.py (#2358)

Tao Sun633ca5febb03
diff --git a/camel/agents/chat_agent.py b/camel/agents/chat_agent.py
index 57995b67f..fe9caa48c 100644
--- a/camel/agents/chat_agent.py
+++ b/camel/agents/chat_agent.py
@@ -1311,7 +1311,9 @@ class ChatAgent(BaseAgent):
response_id: str = ""
# All choices in one response share one role
for chunk in response:
- response_id = chunk.id
+ # Some model platforms like siliconflow may return None for the
+ # chunk.id
+ response_id = chunk.id if chunk.id else str(uuid.uuid4())
self._handle_chunk(
chunk, content_dict, finish_reasons_dict, output_messages
)
@@ -1351,7 +1353,9 @@ class ChatAgent(BaseAgent):
response_id: str = ""
# All choices in one response share one role
async for chunk in response:
- response_id = chunk.id
+ # Some model platforms like siliconflow may return None for the
+ # chunk.id
+ response_id = chunk.id if chunk.id else str(uuid.uuid4())
self._handle_chunk(
chunk, content_dict, finish_reasons_dict, output_messages
)
diff --git a/camel/types/enums.py b/camel/types/enums.py
index 8a8389597..35f15554b 100644
--- a/camel/types/enums.py
+++ b/camel/types/enums.py
@@ -15,8 +15,11 @@ import os
from enum import Enum, EnumMeta
from typing import cast
+from camel.logger import get_logger
from camel.types.unified_model_type import UnifiedModelType
+logger = get_logger(__name__)
+
class RoleType(Enum):
ASSISTANT = "assistant"
@@ -1200,7 +1203,11 @@ class ModelType(UnifiedModelType, Enum):
}:
return 10_000_000
else:
- raise ValueError("Unknown model type")
+ logger.warning(
+ f"Unknown model type {self}, set maximum token limit "
+ f"to 999_999_999"
+ )
+ return 999_999_999
class EmbeddingModelType(Enum):
diff --git a/examples/models/siliconflow_model_example.py b/examples/models/siliconflow_model_example.py
index f60c45442..140f7f29f 100644
--- a/examples/models/siliconflow_model_example.py
+++ b/examples/models/siliconflow_model_example.py
@@ -19,7 +19,9 @@ from camel.types import ModelPlatformType
model = ModelFactory.create(
model_platform=ModelPlatformType.SILICONFLOW,
model_type="deepseek-ai/DeepSeek-R1",
- model_config_dict=SiliconFlowConfig(temperature=0.2).as_dict(),
+ model_config_dict=SiliconFlowConfig(
+ temperature=0.2, stream=True
+ ).as_dict(),
)
# Define system message