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

feat: SambaVerse API support (#920)

Wendong-Fand3d63fdee466
diff --git a/camel/agents/chat_agent.py b/camel/agents/chat_agent.py
index 9c1bf181f..f65b0c27a 100644
--- a/camel/agents/chat_agent.py
+++ b/camel/agents/chat_agent.py
@@ -998,7 +998,10 @@ class ChatAgent(BaseAgent):
Returns:
dict: Usage dictionary.
"""
- encoding = get_model_encoding(self.model_type.value_for_tiktoken)
+ if isinstance(self.model_type, ModelType):
+ encoding = get_model_encoding(self.model_type.value_for_tiktoken)
+ else:
+ encoding = get_model_encoding("gpt-4o-mini")
completion_tokens = 0
for message in output_messages:
completion_tokens += len(encoding.encode(message.content))
diff --git a/camel/configs/__init__.py b/camel/configs/__init__.py
index 3d443be09..59ffda397 100644
--- a/camel/configs/__init__.py
+++ b/camel/configs/__init__.py
@@ -20,7 +20,12 @@ from .mistral_config import MISTRAL_API_PARAMS, MistralConfig
from .ollama_config import OLLAMA_API_PARAMS, OllamaConfig
from .openai_config import OPENAI_API_PARAMS, ChatGPTConfig, OpenSourceConfig
from .reka_config import REKA_API_PARAMS, RekaConfig
-from .samba_config import SAMBA_API_PARAMS, SambaConfig
+from .samba_config import (
+ SAMBA_FAST_API_PARAMS,
+ SAMBA_VERSE_API_PARAMS,
+ SambaFastAPIConfig,
+ SambaVerseAPIConfig,
+)
from .togetherai_config import TOGETHERAI_API_PARAMS, TogetherAIConfig
from .vllm_config import VLLM_API_PARAMS, VLLMConfig
from .zhipuai_config import ZHIPUAI_API_PARAMS, ZhipuAIConfig
@@ -48,8 +53,10 @@ __all__ = [
'MISTRAL_API_PARAMS',
'RekaConfig',
'REKA_API_PARAMS',
- 'SambaConfig',
- 'SAMBA_API_PARAMS',
+ 'SambaFastAPIConfig',
+ 'SAMBA_FAST_API_PARAMS',
+ 'SambaVerseAPIConfig',
+ 'SAMBA_VERSE_API_PARAMS',
'TogetherAIConfig',
'TOGETHERAI_API_PARAMS',
]
diff --git a/camel/configs/samba_config.py b/camel/configs/samba_config.py
index 6b0780a25..dbfc8dc38 100644
--- a/camel/configs/samba_config.py
+++ b/camel/configs/samba_config.py
@@ -18,24 +18,27 @@ from typing import Any, Dict, Optional, Union
from camel.configs.base_config import BaseConfig
-class SambaConfig(BaseConfig):
+class SambaFastAPIConfig(BaseConfig):
r"""Defines the parameters for generating chat completions using the
- SambaNova API.
+ SambaNova Fast API.
Args:
max_tokens (Optional[int], optional): the maximum number of tokens to
- generate, e.g. 100. Defaults to `None`.
+ generate, e.g. 100.
+ (default: :obj:`2048`)
stop (Optional[Union[str,list[str]]]): Stop generation if this token
is detected. Or if one of these tokens is detected when providing
- a string list. Defaults to `None`.
+ a string list.
+ (default: :obj:`None`)
stream (Optional[bool]): If True, partial message deltas will be sent
as data-only server-sent events as they become available.
- Currently SambaNova only support stream mode. Defaults to `True`.
+ Currently SambaNova Fast API only support stream mode.
+ (default: :obj:`True`)
stream_options (Optional[Dict]): Additional options for streaming.
- Defaults to `{"include_usage": True}`.
+ (default: :obj:`{"include_usage": True}`)
"""
- max_tokens: Optional[int] = None
+ max_tokens: Optional[int] = 2048
stop: Optional[Union[str, list[str]]] = None
stream: Optional[bool] = True
stream_options: Optional[Dict] = {"include_usage": True} # noqa: RUF012
@@ -47,4 +50,60 @@ class SambaConfig(BaseConfig):
return config_dict
-SAMBA_API_PARAMS = {param for param in SambaConfig().model_fields.keys()}
+SAMBA_FAST_API_PARAMS = {
+ param for param in SambaFastAPIConfig().model_fields.keys()
+}
+
+
+class SambaVerseAPIConfig(BaseConfig):
+ r"""Defines the parameters for generating chat completions using the
+ SambaVerse API.
+
+ Args:
+ temperature (float, optional): Sampling temperature to use, between
+ :obj:`0` and :obj:`2`. Higher values make the output more random,
+ while lower values make it more focused and deterministic.
+ (default: :obj:`0.7`)
+ top_p (float, optional): An alternative to sampling with temperature,
+ called nucleus sampling, where the model considers the results of
+ the tokens with top_p probability mass. So :obj:`0.1` means only
+ the tokens comprising the top 10% probability mass are considered.
+ (default: :obj:`0.95`)
+ top_k (int, optional): Only sample from the top K options for each
+ subsequent token. Used to remove "long tail" low probability
+ responses.
+ (default: :obj:`50`)
+ max_tokens (Optional[int], optional): The maximum number of tokens to
+ generate, e.g. 100.
+ (default: :obj:`2048`)
+ repetition_penalty (Optional[float], optional): The parameter for
+ repetition penalty. 1.0 means no penalty.
+ (default: :obj:`1.0`)
+ stop (Optional[Union[str,list[str]]]): Stop generation if this token
+ is detected. Or if one of these tokens is detected when providing
+ a string list.
+ (default: :obj:`""`)
+ stream (Optional[bool]): If True, partial message deltas will be sent
+ as data-only server-sent events as they become available.
+ Currently SambaVerse API doesn't support stream mode.
+ (default: :obj:`False`)
+ """
+
+ temperature: Optional[float] = 0.7
+ top_p: Optional[float] = 0.95
+ top_k: Optional[int] = 50
+ max_tokens: Optional[int] = 2048
+ repetition_penalty: Optional[float] = 1.0
+ stop: Optional[Union[str, list[str]]] = ""
+ stream: Optional[bool] = False
+
+ def as_dict(self) -> dict[str, Any]:
+ config_dict = super().as_dict()
+ if "tools" in config_dict:
+ del config_dict["tools"] # SambaNova does not support tool calling
+ return config_dict
+
+
+SAMBA_VERSE_API_PARAMS = {
+ param for param in SambaVerseAPIConfig().model_fields.keys()
+}
diff --git a/camel/models/model_factory.py b/camel/models/model_factory.py
index cb09f9626..34a0635ad 100644
--- a/camel/models/model_factory.py
+++ b/camel/models/model_factory.py
@@ -96,8 +96,6 @@ class ModelFactory:
model_class = MistralModel
elif model_platform.is_reka and model_type.is_reka:
model_class = RekaModel
- elif model_platform.is_samba and model_type.is_samba:
- model_class = SambaModel
elif model_type == ModelType.STUB:
model_class = StubModel
else:
@@ -117,6 +115,8 @@ class ModelFactory:
model_class = LiteLLMModel
elif model_platform.is_openai_compatibility_model:
model_class = OpenAICompatibilityModel
+ elif model_platform.is_samba:
+ model_class = SambaModel
elif model_platform.is_together:
model_class = TogetherAIModel
return model_class(
diff --git a/camel/models/ollama_model.py b/camel/models/ollama_model.py
index c5f367609..f7df7e740 100644
--- a/camel/models/ollama_model.py
+++ b/camel/models/ollama_model.py
@@ -111,7 +111,7 @@ class OllamaModel:
@property
def token_limit(self) -> int:
- """Returns the maximum token limit for the given model.
+ r"""Returns the maximum token limit for the given model.
Returns:
int: The maximum token limit for the given model.
diff --git a/camel/models/samba_model.py b/camel/models/samba_model.py
index 4d9db897d..2172e45f3 100644
--- a/camel/models/samba_model.py
+++ b/camel/models/samba_model.py
@@ -11,14 +11,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
+import json
import os
+import time
+import uuid
from typing import Any, Dict, List, Optional, Union
+import httpx
from openai import OpenAI, Stream
-from camel.configs import SAMBA_API_PARAMS
+from camel.configs import SAMBA_FAST_API_PARAMS, SAMBAVERSE_API_PARAMS
from camel.messages import OpenAIMessage
-from camel.types import ChatCompletion, ChatCompletionChunk, ModelType
+from camel.types import (
+ ChatCompletion,
+ ChatCompletionChunk,
+ CompletionUsage,
+ ModelType,
+)
from camel.utils import (
BaseTokenCounter,
OpenAITokenCounter,
@@ -31,7 +40,7 @@ class SambaModel:
def __init__(
self,
- model_type: ModelType,
+ model_type: str,
model_config_dict: Dict[str, Any],
api_key: Optional[str] = None,
url: Optional[str] = None,
@@ -40,21 +49,29 @@ class SambaModel:
r"""Constructor for SambaNova backend.
Args:
- model_type (ModelType): Model for which a SambaNova backend is
- created.
+ model_type (str): Model for which a SambaNova backend is
+ created. Supported models via Fast API: `https://sambanova.ai/
+ fast-api?api_ref=128521`. Supported models via SambaVerse API
+ is listed in `https://sambaverse.sambanova.ai/models`.
model_config_dict (Dict[str, Any]): A dictionary that will
be fed into API request.
api_key (Optional[str]): The API key for authenticating with the
SambaNova service. (default: :obj:`None`)
- url (Optional[str]): The url to the SambaNova service. (default:
- :obj:`"https://fast-api.snova.ai/v1/chat/completions"`)
+ url (Optional[str]): The url to the SambaNova service. Current
+ support SambaNova Fast API: :obj:`"https://fast-api.snova.ai/
+ v1/chat/ completions"` and SambaVerse API: :obj:`"https://
+ sambaverse.sambanova.ai/api/predict"`. (default::obj:`"https://
+ fast-api.snova.ai/v1/chat/completions"`)
token_counter (Optional[BaseTokenCounter]): Token counter to use
for the model. If not provided, `OpenAITokenCounter(ModelType.
GPT_4O_MINI)` will be used.
"""
self.model_type = model_type
self._api_key = api_key or os.environ.get("SAMBA_API_KEY")
- self._url = url or os.environ.get("SAMBA_API_BASE_URL")
+ self._url = url or os.environ.get(
+ "SAMBA_API_BASE_URL",
+ "https://fast-api.snova.ai/v1/chat/completions",
+ )
self._token_counter = token_counter
self.model_config_dict = model_config_dict
self.check_model_config()
@@ -79,12 +96,26 @@ class SambaModel:
ValueError: If the model configuration dictionary contains any
unexpected arguments to SambaNova API.
"""
- for param in self.model_config_dict:
- if param not in SAMBA_API_PARAMS:
- raise ValueError(
- f"Unexpected argument `{param}` is "
- "input into SambaNova model backend."
- )
+ if self._url == "https://fast-api.snova.ai/v1/chat/completions":
+ for param in self.model_config_dict:
+ if param not in SAMBA_FAST_API_PARAMS:
+ raise ValueError(
+ f"Unexpected argument `{param}` is "
+ "input into SambaNova Fast API."
+ )
+ elif self._url == "https://sambaverse.sambanova.ai/api/predict":
+ for param in self.model_config_dict:
+ if param not in SAMBAVERSE_API_PARAMS:
+ raise ValueError(
+ f"Unexpected argument `{param}` is "
+ "input into SambaVerse API."
+ )
+
+ else:
+ raise ValueError(
+ f"{self._url} is not supported, please check the url to the"
+ " SambaNova service"
+ )
@api_keys_required("SAMBA_API_KEY")
def run( # type: ignore[misc]
@@ -125,38 +156,44 @@ class SambaModel:
RuntimeError: If the HTTP request fails.
"""
- import httpx
-
- headers = {
- "Authorization": f"Basic {self._api_key}",
- "Content-Type": "application/json",
- }
-
- data = {
- "messages": messages,
- "max_tokens": self.token_limit,
- "stop": self.model_config_dict.get("stop"),
- "model": self.model_type.value,
- "stream": True,
- "stream_options": self.model_config_dict.get("stream_options"),
- }
-
- try:
- with httpx.stream(
- "POST",
- self._url or "https://fast-api.snova.ai/v1/chat/completions",
- headers=headers,
- json=data,
- ) as api_response:
- stream = Stream[ChatCompletionChunk](
- cast_to=ChatCompletionChunk,
- response=api_response,
- client=OpenAI(),
- )
- for chunk in stream:
- yield chunk
- except httpx.HTTPError as e:
- raise RuntimeError(f"HTTP request failed: {e!s}")
+ # Handle SambaNova's Fast API
+ if self._url == "https://fast-api.snova.ai/v1/chat/completions":
+ headers = {
+ "Authorization": f"Basic {self._api_key}",
+ "Content-Type": "application/json",
+ }
+
+ data = {
+ "messages": messages,
+ "max_tokens": self.token_limit,
+ "stop": self.model_config_dict.get("stop"),
+ "model": self.model_type,
+ "stream": True,
+ "stream_options": self.model_config_dict.get("stream_options"),
+ }
+
+ try:
+ with httpx.stream(
+ "POST",
+ self._url,
+ headers=headers,
+ json=data,
+ ) as api_response:
+ stream = Stream[ChatCompletionChunk](
+ cast_to=ChatCompletionChunk,
+ response=api_response,
+ client=OpenAI(api_key="required_but_not_used"),
+ )
+ for chunk in stream:
+ yield chunk
+ except httpx.HTTPError as e:
+ raise RuntimeError(f"HTTP request failed: {e!s}")
+
+ elif self._url == "https://sambaverse.sambanova.ai/api/predict":
+ raise ValueError(
+ "https://sambaverse.sambanova.ai/api/predict doesn't support"
+ " stream mode"
+ )
def _run_non_streaming(
self, messages: List[OpenAIMessage]
@@ -177,62 +214,138 @@ class SambaModel:
expected data.
"""
- import json
-
- import httpx
-
- headers = {
- "Authorization": f"Basic {self._api_key}",
- "Content-Type": "application/json",
- }
-
- data = {
- "messages": messages,
- "max_tokens": self.token_limit,
- "stop": self.model_config_dict.get("stop"),
- "model": self.model_type.value,
- "stream": True,
- "stream_options": self.model_config_dict.get("stream_options"),
- }
-
- try:
- with httpx.stream(
- "POST",
- self._url or "https://fast-api.snova.ai/v1/chat/completions",
- headers=headers,
- json=data,
- ) as api_response:
- samba_response = []
- for chunk in api_response.iter_text():
- if chunk.startswith('data: '):
- chunk = chunk[6:]
- if '[DONE]' in chunk:
- break
- json_data = json.loads(chunk)
- samba_response.append(json_data)
- return self._to_openai_response(samba_response)
- except httpx.HTTPError as e:
- raise RuntimeError(f"HTTP request failed: {e!s}")
- except json.JSONDecodeError as e:
- raise ValueError(f"Failed to decode JSON response: {e!s}")
-
- def _to_openai_response(
+ # Handle SambaNova's Fast API
+ if self._url == "https://fast-api.snova.ai/v1/chat/completions":
+ headers = {
+ "Authorization": f"Basic {self._api_key}",
+ "Content-Type": "application/json",
+ }
+
+ data = {
+ "messages": messages,
+ "max_tokens": self.token_limit,
+ "stop": self.model_config_dict.get("stop"),
+ "model": self.model_type,
+ "stream": True,
+ "stream_options": self.model_config_dict.get("stream_options"),
+ }
+
+ try:
+ with httpx.stream(
+ "POST",
+ self._url,
+ headers=headers,
+ json=data,
+ ) as api_response:
+ samba_response = []
+ for chunk in api_response.iter_text():
+ if chunk.startswith('data: '):
+ chunk = chunk[6:]
+ if '[DONE]' in chunk:
+ break
+ json_data = json.loads(chunk)
+ samba_response.append(json_data)
+ return self._fastapi_to_openai_response(samba_response)
+ except httpx.HTTPError as e:
+ raise RuntimeError(f"HTTP request failed: {e!s}")
+ except json.JSONDecodeError as e:
+ raise ValueError(f"Failed to decode JSON response: {e!s}")
+
+ # Handle SambaNova's Sambaverse API
+ else:
+ headers = {
+ "Content-Type": "application/json",
+ "key": str(self._api_key),
+ "modelName": self.model_type,
+ }
+
+ data = {
+ "instance": json.dumps(
+ {
+ "conversation_id": str(uuid.uuid4()),
+ "messages": messages,
+ }
+ ),
+ "params": {
+ "do_sample": {"type": "bool", "value": "true"},
+ "max_tokens_to_generate": {
+ "type": "int",
+ "value": str(self.model_config_dict.get("max_tokens")),
+ },
+ "process_prompt": {"type": "bool", "value": "true"},
+ "repetition_penalty": {
+ "type": "float",
+ "value": str(
+ self.model_config_dict.get("repetition_penalty")
+ ),
+ },
+ "return_token_count_only": {
+ "type": "bool",
+ "value": "false",
+ },
+ "select_expert": {
+ "type": "str",
+ "value": self.model_type.split('/')[1],
+ },
+ "stop_sequences": {
+ "type": "str",
+ "value": self.model_config_dict.get("stop_sequences"),
+ },
+ "temperature": {
+ "type": "float",
+ "value": str(
+ self.model_config_dict.get("temperature")
+ ),
+ },
+ "top_k": {
+ "type": "int",
+ "value": str(self.model_config_dict.get("top_k")),
+ },
+ "top_p": {
+ "type": "float",
+ "value": str(self.model_config_dict.get("top_p")),
+ },
+ },
+ }
+
+ try:
+ # Send the request and handle the response
+ with httpx.Client() as client:
+ response = client.post(
+ self._url, # type: ignore[arg-type]
+ headers=headers,
+ json=data,
+ )
+
+ raw_text = response.text
+ # Split the string into two dictionaries
+ dicts = raw_text.split('}\n{')
+
+ # Keep only the last dictionary
+ last_dict = '{' + dicts[-1]
+
+ # Parse the dictionary
+ last_dict = json.loads(last_dict)
+ return self._sambaverse_to_openai_response(last_dict) # type: ignore[arg-type]
+
+ except httpx.HTTPStatusError:
+ raise RuntimeError(f"HTTP request failed: {raw_text}")
+
+ def _fastapi_to_openai_response(
self, samba_response: List[Dict[str, Any]]
) -> ChatCompletion:
- r"""Converts SambaNova response chunks into an OpenAI-compatible
- response.
+ r"""Converts SambaNova Fast API response chunks into an
+ OpenAI-compatible response.
Args:
samba_response (List[Dict[str, Any]]): A list of dictionaries
- representing partial responses from the SambaNova API.
+ representing partial responses from the SambaNova Fast API.
Returns:
ChatCompletion: A `ChatCompletion` object constructed from the
aggregated response data.
-
- Raises:
- ValueError: If the response data is invalid or incomplete.
"""
+
# Step 1: Combine the content from each chunk
full_content = ""
for chunk in samba_response:
@@ -268,17 +381,64 @@ class SambaModel:
return obj
+ def _sambaverse_to_openai_response(
+ self, samba_response: Dict[str, Any]
+ ) -> ChatCompletion:
+ r"""Converts SambaVerse API response into an OpenAI-compatible
+ response.
+
+ Args:
+ samba_response (Dict[str, Any]): A dictionary representing
+ responses from the SambaVerse API.
+
+ Returns:
+ ChatCompletion: A `ChatCompletion` object constructed from the
+ aggregated response data.
+ """
+ choices = [
+ dict(
+ index=0,
+ message={
+ "role": 'assistant',
+ "content": samba_response['result']['responses'][0][
+ 'completion'
+ ],
+ },
+ finish_reason=samba_response['result']['responses'][0][
+ 'stop_reason'
+ ],
+ )
+ ]
+
+ obj = ChatCompletion.construct(
+ id=None,
+ choices=choices,
+ created=int(time.time()),
+ model=self.model_type,
+ object="chat.completion",
+ # SambaVerse API only provide `total_tokens`
+ usage=CompletionUsage(
+ completion_tokens=0,
+ prompt_tokens=0,
+ total_tokens=int(
+ samba_response['result']['responses'][0][
+ 'total_tokens_count'
+ ]
+ ),
+ ),
+ )
+
+ return obj
+
@property
def token_limit(self) -> int:
- r"""Returns the maximum token limit for a given model.
+ r"""Returns the maximum token limit for the given model.
Returns:
int: The maximum token limit for the given model.
"""
- return (
- self.model_config_dict.get("max_tokens")
- or self.model_type.token_limit
- )
+ max_tokens = self.model_config_dict["max_tokens"]
+ return max_tokens
@property
def stream(self) -> bool:
diff --git a/camel/types/enums.py b/camel/types/enums.py
index a1151c7c5..4f7d6384d 100644
--- a/camel/types/enums.py
+++ b/camel/types/enums.py
@@ -86,16 +86,11 @@ class ModelType(Enum):
REKA_FLASH = "reka-flash"
REKA_EDGE = "reka-edge"
- # SambaNova Model
- SAMBA_LLAMA_3_1_405B = "llama3-405b"
- SAMBA_LLAMA_3_1_70B = "llama3-70b"
- SAMBA_LLAMA_3_1_8B = "llama3-8b"
-
@property
def value_for_tiktoken(self) -> str:
if self.is_openai:
return self.value
- return "gpt-3.5-turbo"
+ return "gpt-4o-mini"
@property
def is_openai(self) -> bool:
@@ -218,14 +213,6 @@ class ModelType(Enum):
ModelType.REKA_FLASH,
}
- @property
- def is_samba(self) -> bool:
- return self in {
- ModelType.SAMBA_LLAMA_3_1_405B,
- ModelType.SAMBA_LLAMA_3_1_70B,
- ModelType.SAMBA_LLAMA_3_1_8B,
- }
-
@property
def token_limit(self) -> int:
r"""Returns the maximum token limit for a given model.
@@ -288,9 +275,6 @@ class ModelType(Enum):
ModelType.GROQ_LLAMA_3_1_8B,
ModelType.GROQ_LLAMA_3_1_70B,
ModelType.GROQ_LLAMA_3_1_405B,
- ModelType.SAMBA_LLAMA_3_1_405B,
- ModelType.SAMBA_LLAMA_3_1_70B,
- ModelType.SAMBA_LLAMA_3_1_8B,
}:
return 131_072
elif self in {
diff --git a/examples/models/samba_model_example.py b/examples/models/samba_model_example.py
index 72f0bae8f..42c6855d4 100644
--- a/examples/models/samba_model_example.py
+++ b/examples/models/samba_model_example.py
@@ -12,15 +12,25 @@
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
from camel.agents import ChatAgent
-from camel.configs import SambaConfig
+from camel.configs import SambaFastAPIConfig, SambaVerseAPIConfig
from camel.messages import BaseMessage
from camel.models import ModelFactory
-from camel.types import ModelPlatformType, ModelType
+from camel.types import ModelPlatformType
-model = ModelFactory.create(
+samba_fast_api_model = ModelFactory.create(
model_platform=ModelPlatformType.SAMBA,
- model_type=ModelType.SAMBA_LLAMA_3_1_405B,
- model_config_dict=SambaConfig(max_tokens=800).as_dict(),
+ model_type="llama3-70b",
+ model_config_dict=SambaFastAPIConfig(max_tokens=800).as_dict(),
+ api_key="Your Fast API Key",
+ url="https://fast-api.snova.ai/v1/chat/completions",
+)
+
+sambaverse_api_model = ModelFactory.create(
+ model_platform=ModelPlatformType.SAMBA,
+ model_type="Mistral/Mistral-7B-Instruct-v0.2",
+ model_config_dict=SambaVerseAPIConfig(max_tokens=800).as_dict(),
+ api_key="Your SambaVerse API Key",
+ url="https://sambaverse.sambanova.ai/api/predict",
)
# Define system message
@@ -29,17 +39,23 @@ sys_msg = BaseMessage.make_assistant_message(
content="You are a helpful assistant.",
)
-# Set agent
-camel_agent = ChatAgent(system_message=sys_msg, model=model)
-
+# Define user message
user_msg = BaseMessage.make_user_message(
role_name="User",
content="""Say hi to CAMEL AI, one open-source community dedicated to the
study of autonomous and communicative agents.""",
)
+# Set agent
+camel_agent_fast_api = ChatAgent(
+ system_message=sys_msg, model=samba_fast_api_model
+)
+camel_agent_sambaverse_api = ChatAgent(
+ system_message=sys_msg, model=sambaverse_api_model
+)
+
# Get response information
-response = camel_agent.step(user_msg)
+response = camel_agent_fast_api.step(user_msg)
print(response.msgs[0].content)
'''
===============================================================================
@@ -54,3 +70,16 @@ challenges or areas where I can offer assistance or provide information? I'm
here to help and support your endeavors!
===============================================================================
'''
+
+
+# Get response information
+response = camel_agent_sambaverse_api.step(user_msg)
+print(response.msgs[0].content)
+
+'''
+===============================================================================
+Hi CAMEL AI community! I'm here to help answer any questions you may have
+related to autonomous and communicative agents. Let me know how I can be
+of assistance.
+===============================================================================
+'''
diff --git a/test/models/test_samba_model.py b/test/models/test_samba_model.py
index 38f87f778..7f8ad1880 100644
--- a/test/models/test_samba_model.py
+++ b/test/models/test_samba_model.py
@@ -15,9 +15,11 @@ import re
import pytest
-from camel.configs import OpenSourceConfig, SambaConfig
+from camel.configs import (
+ OpenSourceConfig,
+ SambaFastAPIConfig,
+)
from camel.models import SambaModel
-from camel.types import ModelType
from camel.utils import OpenAITokenCounter
@@ -25,22 +27,20 @@ from camel.utils import OpenAITokenCounter
@pytest.mark.parametrize(
"model_type",
[
- ModelType.SAMBA_LLAMA_3_1_405B,
+ "llama3-70b",
],
)
def test_samba_model(model_type):
- model_config_dict = SambaConfig().as_dict()
+ model_config_dict = SambaFastAPIConfig().as_dict()
model = SambaModel(model_type, model_config_dict)
assert model.model_type == model_type
assert model.model_config_dict == model_config_dict
assert isinstance(model.token_counter, OpenAITokenCounter)
- assert isinstance(model.model_type.value_for_tiktoken, str)
- assert isinstance(model.model_type.token_limit, int)
@pytest.mark.model_backend
def test_samba_model_unexpected_argument():
- model_type = ModelType.SAMBA_LLAMA_3_1_405B
+ model_type = "llama3-70b"
model_config = OpenSourceConfig(
model_path="vicuna-7b-v1.5",
server_url="http://localhost:8000/v1",
@@ -52,7 +52,7 @@ def test_samba_model_unexpected_argument():
match=re.escape(
(
"Unexpected argument `model_path` is "
- "input into SambaNova model backend."
+ "input into SambaNova Fast API."
)
),
):