Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove FUNCS and GPT 3.5 Turbo in examples #938

Merged
merged 4 commits into from
Sep 13, 2024
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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.1.9
placeholder: E.g., 0.2.0
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 @@ -119,7 +119,7 @@ conda create --name camel python=3.10
conda activate camel

# Clone github repo
git clone -b v0.1.9 https://github.com/camel-ai/camel.git
git clone -b v0.2.0 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.1.9'
__version__ = '0.2.0'

__all__ = [
'__version__',
Expand Down
39 changes: 15 additions & 24 deletions camel/toolkits/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@
)
from .open_api_specs.security_config import openapi_security_config

from .google_maps_toolkit import MAP_FUNCS, GoogleMapsToolkit
from .math_toolkit import MATH_FUNCS, MathToolkit
from .open_api_toolkit import OPENAPI_FUNCS, OpenAPIToolkit
from .retrieval_toolkit import RETRIEVAL_FUNCS, RetrievalToolkit
from .search_toolkit import SEARCH_FUNCS, SearchToolkit
from .twitter_toolkit import TWITTER_FUNCS, TwitterToolkit
from .weather_toolkit import WEATHER_FUNCS, WeatherToolkit
from .slack_toolkit import SLACK_FUNCS, SlackToolkit
from .dalle_toolkit import DALLE_FUNCS, DalleToolkit
from .linkedin_toolkit import LINKEDIN_FUNCS, LinkedInToolkit
from .reddit_toolkit import REDDIT_FUNCS, RedditToolkit
from .google_maps_toolkit import GoogleMapsToolkit
from .math_toolkit import MathToolkit, MATH_FUNCS
from .open_api_toolkit import OpenAPIToolkit
from .retrieval_toolkit import RetrievalToolkit
from .search_toolkit import SearchToolkit, SEARCH_FUNCS
from .twitter_toolkit import TwitterToolkit
from .weather_toolkit import WeatherToolkit, WEATHER_FUNCS
from .slack_toolkit import SlackToolkit
from .dalle_toolkit import DalleToolkit, DALLE_FUNCS
from .linkedin_toolkit import LinkedInToolkit
from .reddit_toolkit import RedditToolkit

from .base import BaseToolkit
from .code_execution import CodeExecutionToolkit
from .github_toolkit import GithubToolkit

Expand All @@ -40,18 +39,6 @@
'get_openai_function_schema',
'get_openai_tool_schema',
'openapi_security_config',
'MATH_FUNCS',
'MAP_FUNCS',
'OPENAPI_FUNCS',
'RETRIEVAL_FUNCS',
'SEARCH_FUNCS',
'TWITTER_FUNCS',
'WEATHER_FUNCS',
'SLACK_FUNCS',
'DALLE_FUNCS',
'LINKEDIN_FUNCS',
'REDDIT_FUNCS',
'BaseToolkit',
'GithubToolkit',
'MathToolkit',
'GoogleMapsToolkit',
Expand All @@ -65,4 +52,8 @@
'LinkedInToolkit',
'RedditToolkit',
'CodeExecutionToolkit',
'MATH_FUNCS',
'SEARCH_FUNCS',
'WEATHER_FUNCS',
'DALLE_FUNCS',
]
7 changes: 0 additions & 7 deletions camel/toolkits/google_maps_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ def get_address_description(
information on address completion, formatted address,
geographical coordinates (latitude and longitude), and metadata
types true for the address.

Raises:
ImportError: If the `googlemaps` library is not installed.
Exception: For unexpected errors during the address validation.
"""
addressvalidation_result = self.gmaps.addressvalidation(
[address],
Expand Down Expand Up @@ -304,6 +300,3 @@ def get_tools(self) -> List[OpenAIFunction]:
OpenAIFunction(self.get_elevation),
OpenAIFunction(self.get_timezone),
]


MAP_FUNCS: List[OpenAIFunction] = GoogleMapsToolkit().get_tools()
3 changes: 0 additions & 3 deletions camel/toolkits/linkedin_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,3 @@ def _get_access_token(self) -> str:
if not token:
return "Access token not found. Please set LINKEDIN_ACCESS_TOKEN."
return token


LINKEDIN_FUNCS: List[OpenAIFunction] = LinkedInToolkit().get_tools()
3 changes: 0 additions & 3 deletions camel/toolkits/open_api_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,3 @@ def get_tools(self) -> List[OpenAIFunction]:
OpenAIFunction(a_func, a_schema)
for a_func, a_schema in zip(all_funcs_lst, all_schemas_lst)
]


OPENAPI_FUNCS: List[OpenAIFunction] = OpenAPIToolkit().get_tools()
3 changes: 0 additions & 3 deletions camel/toolkits/reddit_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,3 @@ def get_tools(self) -> List[OpenAIFunction]:
OpenAIFunction(self.perform_sentiment_analysis),
OpenAIFunction(self.track_keyword_discussions),
]


REDDIT_FUNCS: List[OpenAIFunction] = RedditToolkit().get_tools()
4 changes: 0 additions & 4 deletions camel/toolkits/retrieval_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,3 @@ def get_tools(self) -> List[OpenAIFunction]:
return [
OpenAIFunction(self.information_retrieval),
]


# add the function to OpenAIFunction list
RETRIEVAL_FUNCS: List[OpenAIFunction] = RetrievalToolkit().get_tools()
3 changes: 0 additions & 3 deletions camel/toolkits/slack_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,3 @@ def get_tools(self) -> List[OpenAIFunction]:
OpenAIFunction(self.send_slack_message),
OpenAIFunction(self.delete_slack_message),
]


SLACK_FUNCS: List[OpenAIFunction] = SlackToolkit().get_tools()
7 changes: 2 additions & 5 deletions camel/toolkits/twitter_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def _get_twitter_api_key(self) -> Tuple[str, str]:
return TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET

def _get_oauth_session(self) -> requests.Session:
r'''Initiates an OAuth1Session with Twitter's API and returns it.
r"""Initiates an OAuth1Session with Twitter's API and returns it.

The function first fetches a request token, then prompts the user to
authorize the application. After the user has authorized the
Expand All @@ -431,7 +431,7 @@ def _get_oauth_session(self) -> requests.Session:
Manage-Tweets/create_tweet.py
https://github.com/twitterdev/Twitter-API-v2-sample-code/blob/main/
User-Lookup/get_users_me_user_context.py
'''
"""
try:
from requests_oauthlib import OAuth1Session
except ImportError:
Expand Down Expand Up @@ -517,6 +517,3 @@ def _handle_http_error(self, response: requests.Response) -> str:
return "HTTP Exception"
else:
return "Unexpected Exception"


TWITTER_FUNCS: List[OpenAIFunction] = TwitterToolkit().get_tools()
8 changes: 5 additions & 3 deletions docs/agents/single_agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ Woohoo, your first agent is ready to play with you!
### Tool Usage
```python
# Import the necessary functions
from camel.toolkits import MATH_FUNCS, SEARCH_FUNCS
from camel.toolkits import MathToolkit, SearchToolkit

# Initialize the agent with list of tools
agent = ChatAgent(
system_message=sys_msg,
tools=[*MATH_FUNCS, *SEARCH_FUNCS]
)
tools = [
*MathToolkit().get_tools(),
*SearchToolkit().get_tools(),
])

# Check if tools are enabled
agent.is_tools_added()
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 = '2023, CAMEL-AI.org'
author = 'CAMEL-AI.org'
release = '0.1.9'
release = '0.2.0'

html_favicon = (
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'
Expand Down
2 changes: 1 addition & 1 deletion docs/get_started/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ conda create --name camel python=3.10
conda activate camel

# Clone github repo
git clone -b v0.1.9 https://github.com/camel-ai/camel.git
git clone -b v0.2.0 https://github.com/camel-ai/camel.git

# Change directory into project directory
cd camel
Expand Down
2 changes: 1 addition & 1 deletion examples/ai_society/role_playing_multiprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def generate_data(

model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_3_5_TURBO,
model_type=ModelType.GPT_4O_MINI,
model_config_dict=ChatGPTConfig(temperature=1.4).as_dict(),
)

Expand Down
2 changes: 1 addition & 1 deletion examples/ai_society/role_playing_with_critic.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def main() -> None:
task_prompt = "Write a research proposal for large-scale language models"
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_3_5_TURBO,
model_type=ModelType.GPT_4O_MINI,
model_config_dict=ChatGPTConfig(temperature=0.8, n=3).as_dict(),
)
assistant_agent_kwargs = dict(model=model)
Expand Down
2 changes: 1 addition & 1 deletion examples/ai_society/role_playing_with_human.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def main() -> None:
task_prompt = "Write a book about the future of AI Society"
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_3_5_TURBO,
model_type=ModelType.GPT_4O_MINI,
model_config_dict=ChatGPTConfig(temperature=1.4, n=3).as_dict(),
)
assistant_agent_kwargs = dict(model=model)
Expand Down
8 changes: 4 additions & 4 deletions examples/external_tools/use_external_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
from camel.configs import ChatGPTConfig
from camel.messages import BaseMessage
from camel.models import ModelFactory
from camel.toolkits import MATH_FUNCS, SEARCH_FUNCS
from camel.toolkits import MathToolkit, SearchToolkit
from camel.types import ModelPlatformType, ModelType


def main():
# Set the tools for the external_tools
internal_tools = SEARCH_FUNCS
external_tools = MATH_FUNCS
internal_tools = SearchToolkit().get_tools()
external_tools = MathToolkit().get_tools()
tool_list = internal_tools + external_tools

model_config_dict = ChatGPTConfig(
Expand All @@ -33,7 +33,7 @@ def main():

model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_3_5_TURBO,
model_type=ModelType.GPT_4O_MINI,
model_config_dict=model_config_dict,
)

Expand Down
2 changes: 1 addition & 1 deletion examples/function_call/code_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_3_5_TURBO,
model_type=ModelType.GPT_4O_MINI,
model_config_dict=assistant_model_config.as_dict(),
)

Expand Down
2 changes: 1 addition & 1 deletion examples/function_call/github_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def solve_issue(

model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_3_5_TURBO,
model_type=ModelType.GPT_4O_MINI,
model_config_dict=assistant_model_config_dict,
)

Expand Down
6 changes: 3 additions & 3 deletions examples/function_call/openapi_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from camel.configs.openai_config import ChatGPTConfig
from camel.messages import BaseMessage
from camel.models import ModelFactory
from camel.toolkits import OPENAPI_FUNCS
from camel.toolkits import OpenAPIToolkit
from camel.types import ModelPlatformType, ModelType

# Define system message
Expand All @@ -24,7 +24,7 @@
)

# Set model config
tools = [*OPENAPI_FUNCS]
tools = OpenAPIToolkit().get_tools()
model_config_dict = ChatGPTConfig(
tools=tools,
temperature=0.0,
Expand All @@ -40,7 +40,7 @@
camel_agent = ChatAgent(
system_message=sys_msg,
model=model,
tools=OPENAPI_FUNCS,
tools=OpenAPIToolkit().get_tools(),
)
camel_agent.reset()

Expand Down
22 changes: 8 additions & 14 deletions examples/function_call/role_playing_with_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,16 @@
from camel.models import ModelFactory
from camel.societies import RolePlaying
from camel.toolkits import (
MAP_FUNCS,
MATH_FUNCS,
SEARCH_FUNCS,
TWITTER_FUNCS,
WEATHER_FUNCS,
MathToolkit,
SearchToolkit,
)
from camel.types import ModelPlatformType, ModelType
from camel.utils import print_text_animated


def main(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_3_5_TURBO,
model_type=ModelType.GPT_4O_MINI,
chat_turn_limit=10,
) -> None:
task_prompt = (
Expand All @@ -46,15 +43,12 @@ def main(

user_model_config = ChatGPTConfig(temperature=0.0)

function_list = [
*MATH_FUNCS,
*SEARCH_FUNCS,
*WEATHER_FUNCS,
*MAP_FUNCS,
*TWITTER_FUNCS,
tools_list = [
*MathToolkit().get_tools(),
*SearchToolkit().get_tools(),
]
assistant_model_config = ChatGPTConfig(
tools=function_list,
tools=tools_list,
temperature=0.0,
)

Expand All @@ -67,7 +61,7 @@ def main(
model_type=model_type,
model_config_dict=assistant_model_config.as_dict(),
),
tools=function_list,
tools=tools_list,
),
user_agent_kwargs=dict(
model=ModelFactory.create(
Expand Down
2 changes: 1 addition & 1 deletion examples/generate_text_embedding_data/single_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def main() -> None:
)
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_3_5_TURBO,
model_type=ModelType.GPT_4O_MINI,
model_config_dict=ChatGPTConfig(
temperature=0.0, response_format={"type": "json_object"}
).as_dict(),
Expand Down
2 changes: 1 addition & 1 deletion examples/generate_text_embedding_data/task_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def main() -> None:

model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_3_5_TURBO,
model_type=ModelType.GPT_4O_MINI,
model_config_dict=ChatGPTConfig(temperature=0.0).as_dict(),
)
agent = ChatAgent(
Expand Down
2 changes: 1 addition & 1 deletion examples/misalignment/role_playing_multiprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def generate_data(
task_specify_agent_kwargs=dict(
model=ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_3_5_TURBO,
model_type=ModelType.GPT_4O_MINI,
model_config_dict=ChatGPTConfig(temperature=1.4).as_dict(),
)
),
Expand Down
2 changes: 1 addition & 1 deletion examples/misalignment/role_playing_with_human.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def main() -> None:
task_prompt = "Escape from human control"
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_3_5_TURBO,
model_type=ModelType.GPT_4O_MINI,
model_config_dict=ChatGPTConfig(temperature=1.4, n=3).as_dict(),
)
assistant_agent_kwargs = dict(model=model)
Expand Down
2 changes: 1 addition & 1 deletion examples/models/azure_openai_model_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

model = ModelFactory.create(
model_platform=ModelPlatformType.AZURE,
model_type=ModelType.GPT_3_5_TURBO,
model_type=ModelType.GPT_4O_MINI,
model_config_dict=ChatGPTConfig(temperature=0.2).as_dict(),
)

Expand Down
Loading
Loading