Skip to content

Commit

Permalink
fix: llama tool call msg & remove samba fast api (#1120)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendong-Fan authored Oct 25, 2024
1 parent 003f4e3 commit 6a47dcf
Show file tree
Hide file tree
Showing 29 changed files with 73 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.5
placeholder: E.g., 0.2.6
validations:
required: true

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ conda create --name camel python=3.10
conda activate camel
# Clone github repo
git clone -b v0.2.5 https://github.com/camel-ai/camel.git
git clone -b v0.2.6 https://github.com/camel-ai/camel.git
# Change directory into project directory
cd camel
Expand Down
2 changes: 1 addition & 1 deletion camel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========

__version__ = '0.2.5'
__version__ = '0.2.6'

__all__ = [
'__version__',
Expand Down
8 changes: 7 additions & 1 deletion camel/agents/chat_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ def __init__(
self.response_terminators = response_terminators or []
self.init_messages()

self.tool_prompt_added = False

# ruff: noqa: E501
def _generate_tool_prompt(self, tool_schema_list: List[Dict]) -> str:
tool_prompts = []
Expand Down Expand Up @@ -448,7 +450,10 @@ def step(
)

if "llama" in self.model_type.lower():
if self.model_backend.model_config_dict.get("tools", None):
if (
self.model_backend.model_config_dict.get("tools", None)
and not self.tool_prompt_added
):
tool_prompt = self._generate_tool_prompt(self.tool_schema_list)

tool_sys_msg = BaseMessage.make_assistant_message(
Expand All @@ -457,6 +462,7 @@ def step(
)

self.update_memory(tool_sys_msg, OpenAIBackendRole.SYSTEM)
self.tool_prompt_added = True

self.update_memory(input_message, OpenAIBackendRole.USER)

Expand Down
4 changes: 0 additions & 4 deletions camel/configs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
from .reka_config import REKA_API_PARAMS, RekaConfig
from .samba_config import (
SAMBA_CLOUD_API_PARAMS,
SAMBA_FAST_API_PARAMS,
SAMBA_VERSE_API_PARAMS,
SambaCloudAPIConfig,
SambaFastAPIConfig,
SambaVerseAPIConfig,
)
from .togetherai_config import TOGETHERAI_API_PARAMS, TogetherAIConfig
Expand Down Expand Up @@ -54,8 +52,6 @@
'MISTRAL_API_PARAMS',
'RekaConfig',
'REKA_API_PARAMS',
'SambaFastAPIConfig',
'SAMBA_FAST_API_PARAMS',
'SambaVerseAPIConfig',
'SAMBA_VERSE_API_PARAMS',
'SambaCloudAPIConfig',
Expand Down
39 changes: 1 addition & 38 deletions camel/configs/samba_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,14 @@
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
from __future__ import annotations

from typing import Any, Dict, Optional, Sequence, Union
from typing import Any, Optional, Sequence, Union

from pydantic import Field

from camel.configs.base_config import BaseConfig
from camel.types import NOT_GIVEN, NotGiven


class SambaFastAPIConfig(BaseConfig):
r"""Defines the parameters for generating chat completions using the
SambaNova Fast API.
Args:
max_tokens (Optional[int], optional): the maximum number of tokens to
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.
(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 Fast API only support stream mode.
(default: :obj:`True`)
stream_options (Optional[Dict]): Additional options for streaming.
(default: :obj:`{"include_usage": True}`)
"""

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

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_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.
Expand Down
2 changes: 1 addition & 1 deletion camel/models/samba_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def check_model_config(self):
def run( # type: ignore[misc]
self, messages: List[OpenAIMessage]
) -> Union[ChatCompletion, Stream[ChatCompletionChunk]]:
r"""Runs SambaNova's FastAPI service.
r"""Runs SambaNova's service.
Args:
messages (List[OpenAIMessage]): Message list with the chat history
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
project = 'CAMEL'
copyright = '2024, CAMEL-AI.org'
author = 'CAMEL-AI.org'
release = '0.2.5'
release = '0.2.6'

html_favicon = (
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_message.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai==0.2.5\""
"!pip install \"camel-ai==0.2.6\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_prompting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai==0.2.5\""
"!pip install \"camel-ai==0.2.6\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_society.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai==0.2.5\""
"!pip install \"camel-ai==0.2.6\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_tracking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"outputs": [],
"source": [
"%pip install camel-ai[all]==0.2.5\n",
"%pip install camel-ai[all]==0.2.6\n",
"%pip install agentops==0.3.10"
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_with_memory.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai[all]==0.2.5\""
"!pip install \"camel-ai[all]==0.2.6\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_with_rag.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai[all]==0.2.5\""
"!pip install \"camel-ai[all]==0.2.6\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_with_tools.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai[all]==0.2.5\""
"!pip install \"camel-ai[all]==0.2.6\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/create_your_first_agent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
{
"cell_type": "code",
"source": [
"!pip install \"camel-ai[all]==0.2.5\""
"!pip install \"camel-ai[all]==0.2.6\""
],
"metadata": {
"id": "UtcC3c-KVZmU"
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/create_your_first_agents_society.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
{
"cell_type": "code",
"source": [
"!pip install \"camel-ai==0.2.5\""
"!pip install \"camel-ai==0.2.6\""
],
"metadata": {
"id": "RiwfwyyLYYxo"
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/critic_agents_and_tree_search.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
{
"cell_type": "code",
"source": [
"%pip install \"camel-ai==0.2.5\""
"%pip install \"camel-ai==0.2.6\""
],
"metadata": {
"id": "UtcC3c-KVZmU"
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/embodied_agents.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
{
"cell_type": "code",
"source": [
"%pip install \"camel-ai==0.2.5\""
"%pip install \"camel-ai==0.2.6\""
],
"metadata": {
"id": "UtcC3c-KVZmU"
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/knowledge_graph.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
},
"outputs": [],
"source": [
"pip install \"camel-ai[all]==0.2.5\""
"pip install \"camel-ai[all]==0.2.6\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/model_speed_comparison.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
{
"cell_type": "code",
"source": [
"!pip install \"camel-ai==0.2.5\""
"!pip install \"camel-ai==0.2.6\""
],
"metadata": {
"id": "UtcC3c-KVZmU"
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/roleplaying_scraper.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai[all]==0.2.5\""
"!pip install \"camel-ai[all]==0.2.6\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/task_generation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai==0.2.5\""
"!pip install \"camel-ai==0.2.6\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/video_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"outputs": [],
"source": [
"%pip install \"camel-ai[all]==0.2.5\""
"%pip install \"camel-ai[all]==0.2.6\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/workforce_judge_committee.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"outputs": [],
"source": [
"%pip install \"camel-ai[all]==0.2.5\""
"%pip install \"camel-ai[all]==0.2.6\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/get_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ conda create --name camel python=3.10
conda activate camel
# Clone github repo
git clone -b v0.2.5 https://github.com/camel-ai/camel.git
git clone -b v0.2.6 https://github.com/camel-ai/camel.git
# Change directory into project directory
cd camel
Expand Down
Loading

0 comments on commit 6a47dcf

Please sign in to comment.