🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
chore: Rename tool call instances (#1492)
JINO ROHIT73519c34e9ad
diff --git a/camel/agents/chat_agent.py b/camel/agents/chat_agent.pyindex 49c8ea650..72743bb8a 100644--- a/camel/agents/chat_agent.py+++ b/camel/agents/chat_agent.py@@ -86,18 +86,18 @@ except (ImportError, AttributeError):from camel.utils import track_agent-class FunctionCallingRecord(BaseModel):- r"""Historical records of functions called in the conversation.+class ToolCallingRecord(BaseModel):+ r"""Historical records of tools called in the conversation.Attributes:- func_name (str): The name of the function being called.+ tool_name (str): The name of the tool being called.args (Dict[str, Any]): The dictionary of arguments passed to- the function.- result (Any): The execution result of calling this function.+ the tools.+ result (Any): The execution result of calling this tool.tool_call_id (str): The ID of the tool call, if available."""- func_name: str+ tool_name: strargs: Dict[str, Any]result: Anytool_call_id: str@@ -106,10 +106,10 @@ class FunctionCallingRecord(BaseModel):r"""Overridden version of the string function.Returns:- str: Modified string to represent the function calling.+ str: Modified string to represent the tool calling."""return (- f"Function Execution: {self.func_name}\n"+ f"Tool Execution: {self.tool_name}\n"f"\tArgs: {self.args}\n"f"\tResult: {self.result}\n")@@ -489,7 +489,7 @@ class ChatAgent(BaseAgent):usage: Optional[Dict[str, int]],termination_reasons: List[str],num_tokens: int,- tool_calls: List[FunctionCallingRecord],+ tool_calls: List[ToolCallingRecord],external_tool_request: Optional[ChatCompletionMessageToolCall] = None,) -> Dict[str, Any]:r"""Returns a dictionary containing information about the chat session.@@ -501,7 +501,7 @@ class ChatAgent(BaseAgent):termination_reasons (List[str]): The reasons for the terminationof the chat session.num_tokens (int): The number of tokens used in the chat session.- tool_calls (List[FunctionCallingRecord]): The list of function+ tool_calls (List[ToolCallingRecord]): The list of functioncalling records, containing the information of called tools.external_tool_request(Optional[ChatCompletionMessageToolCall], optional):@@ -645,7 +645,7 @@ class ChatAgent(BaseAgent):)# Record function calls made during the session- tool_call_records: List[FunctionCallingRecord] = []+ tool_call_records: List[ToolCallingRecord] = []external_tool_request = None@@ -885,7 +885,7 @@ class ChatAgent(BaseAgent):self.update_memory(input_message, OpenAIBackendRole.USER)- tool_call_records: List[FunctionCallingRecord] = []+ tool_call_records: List[ToolCallingRecord] = []while True:try:openai_messages, num_tokens = self.memory.get_context()@@ -970,7 +970,7 @@ class ChatAgent(BaseAgent):def _step_tool_call_and_update(self, response: ChatCompletion- ) -> FunctionCallingRecord:+ ) -> ToolCallingRecord:r"""Processes a function call within the chat completion response,records the function call in the provided list of tool calls andupdates the memory of the current agent.@@ -980,7 +980,7 @@ class ChatAgent(BaseAgent):completion.Returns:- FunctionCallingRecord: The record of calling the function.+ ToolCallingRecord: The record of calling the function."""# Perform function calling@@ -996,7 +996,7 @@ class ChatAgent(BaseAgent):async def _step_tool_call_and_update_async(self, response: ChatCompletion- ) -> FunctionCallingRecord:+ ) -> ToolCallingRecord:(func_assistant_msg,func_result_msg,@@ -1015,7 +1015,7 @@ class ChatAgent(BaseAgent):List[str],Dict[str, int],str,- FunctionCallingRecord,+ ToolCallingRecord,int,]:r"""Internal function of structuring the output of the agent based on@@ -1027,7 +1027,7 @@ class ChatAgent(BaseAgent):Returns:Tuple[List[BaseMessage], List[str], Dict[str, int], str,- FunctionCallingRecord, int]:+ ToolCallingRecord, int]:A tuple containing the output messages, finish reasons, usagedictionary, response ID, function calling record, and number oftokens.@@ -1141,7 +1141,7 @@ class ChatAgent(BaseAgent):finish_reasons: List[str],usage_dict: Dict[str, int],response_id: str,- tool_calls: List[FunctionCallingRecord],+ tool_calls: List[ToolCallingRecord],num_tokens: int,external_tool_request: Optional[ChatCompletionMessageToolCall] = None,) -> Dict[str, Any]:@@ -1160,7 +1160,7 @@ class ChatAgent(BaseAgent):usage_dict (Dict[str, int]): Dictionary containing token usageinformation.response_id (str): The ID of the response from the model.- tool_calls (List[FunctionCallingRecord]): Records of function calls+ tool_calls (List[ToolCallingRecord]): Records of function callsmade during this step.num_tokens (int): The number of tokens used in this step.external_tool_request (Optional[ChatCompletionMessageToolCall]):@@ -1335,7 +1335,7 @@ class ChatAgent(BaseAgent):def _step_token_exceed(self,num_tokens: int,- tool_calls: List[FunctionCallingRecord],+ tool_calls: List[ToolCallingRecord],termination_reason: str,) -> ChatAgentResponse:r"""Return trivial response containing number of tokens and information@@ -1343,7 +1343,7 @@ class ChatAgent(BaseAgent):Args:num_tokens (int): Number of tokens in the messages.- tool_calls (List[FunctionCallingRecord]): List of information+ tool_calls (List[ToolCallingRecord]): List of informationobjects of functions called in the current step.termination_reason (str): String of termination reason.@@ -1372,7 +1372,7 @@ class ChatAgent(BaseAgent):self,response: ChatCompletion,) -> Tuple[- FunctionCallingMessage, FunctionCallingMessage, FunctionCallingRecord+ FunctionCallingMessage, FunctionCallingMessage, ToolCallingRecord]:r"""Execute the function with arguments following the model's response.@@ -1418,8 +1418,8 @@ class ChatAgent(BaseAgent):)# Record information about this function call- func_record = FunctionCallingRecord(- func_name=func_name,+ func_record = ToolCallingRecord(+ tool_name=func_name,args=args,result=result,tool_call_id=tool_call_id,@@ -1442,7 +1442,7 @@ class ChatAgent(BaseAgent):self,response: ChatCompletion,) -> Tuple[- FunctionCallingMessage, FunctionCallingMessage, FunctionCallingRecord+ FunctionCallingMessage, FunctionCallingMessage, ToolCallingRecord]:r"""Execute the async function with arguments following the model'sresponse.@@ -1488,8 +1488,8 @@ class ChatAgent(BaseAgent):)# Record information about this function call- func_record = FunctionCallingRecord(- func_name=func_name,+ func_record = ToolCallingRecord(+ tool_name=func_name,args=args,result=result,tool_call_id=tool_call_id,diff --git a/examples/models/openai_o3_mini_example.py b/examples/models/openai_o3_mini_example.pyindex d2d89f77e..3ee7bbf95 100644--- a/examples/models/openai_o3_mini_example.py+++ b/examples/models/openai_o3_mini_example.py@@ -40,7 +40,7 @@ response = camel_agent.step(user_msg)print(str(response.info['tool_calls'])[:1000])'''===============================================================================-[FunctionCallingRecord(func_name='search_duckduckgo', args={'query': 'what is+[ToolCallingRecord(func_name='search_duckduckgo', args={'query': 'what isdeepseek r1, and do a comparison between deepseek r1 and openai o3 mini','source': 'text', 'max_results': 5}, result=[{'result_id': 1, 'title':'DeepSeek R1 vs OpenAI o1: Which One is Better? - Analytics Vidhya',diff --git a/examples/models/role_playing_with_cohere.py b/examples/models/role_playing_with_cohere.pyindex ff93313d0..89770e94f 100644--- a/examples/models/role_playing_with_cohere.py+++ b/examples/models/role_playing_with_cohere.py@@ -15,7 +15,7 @@ from typing import Listfrom colorama import Fore-from camel.agents.chat_agent import FunctionCallingRecord+from camel.agents.chat_agent import ToolCallingRecordfrom camel.configs import CohereConfigfrom camel.models import ModelFactoryfrom camel.societies import RolePlaying@@ -120,8 +120,8 @@ def main(# Print output from the assistant, including any function# execution informationprint_text_animated(Fore.GREEN + "AI Assistant:")- tool_calls: List[FunctionCallingRecord] = [- FunctionCallingRecord(**call.as_dict())+ tool_calls: List[ToolCallingRecord] = [+ ToolCallingRecord(**call.as_dict())for call in assistant_response.info['tool_calls']]for func_record in tool_calls:diff --git a/examples/models/role_playing_with_mistral.py b/examples/models/role_playing_with_mistral.pyindex e92ade930..5ef2217d6 100644--- a/examples/models/role_playing_with_mistral.py+++ b/examples/models/role_playing_with_mistral.py@@ -16,7 +16,7 @@ from typing import Listfrom colorama import Fore-from camel.agents.chat_agent import FunctionCallingRecord+from camel.agents.chat_agent import ToolCallingRecordfrom camel.configs import MistralConfigfrom camel.models import ModelFactoryfrom camel.societies import RolePlaying@@ -120,8 +120,8 @@ def main(# Print output from the assistant, including any function# execution informationprint_text_animated(Fore.GREEN + "AI Assistant:")- tool_calls: List[FunctionCallingRecord] = [- FunctionCallingRecord(**call.as_dict())+ tool_calls: List[ToolCallingRecord] = [+ ToolCallingRecord(**call.as_dict())for call in assistant_response.info['tool_calls']]for func_record in tool_calls:diff --git a/examples/models/role_playing_with_ollama.py b/examples/models/role_playing_with_ollama.pyindex 77eaeec33..fe58c5a44 100644--- a/examples/models/role_playing_with_ollama.py+++ b/examples/models/role_playing_with_ollama.py@@ -16,7 +16,7 @@ from typing import Listfrom colorama import Fore-from camel.agents.chat_agent import FunctionCallingRecord+from camel.agents.chat_agent import ToolCallingRecordfrom camel.models import ModelFactoryfrom camel.societies import RolePlayingfrom camel.types import ModelPlatformType@@ -100,8 +100,8 @@ def main(# Print output from the assistant, including any function# execution informationprint_text_animated(Fore.GREEN + "AI Assistant:")- tool_calls: List[FunctionCallingRecord] = [- FunctionCallingRecord(**call.as_dict())+ tool_calls: List[ToolCallingRecord] = [+ ToolCallingRecord(**call.as_dict())for call in assistant_response.info['tool_calls']]for func_record in tool_calls:diff --git a/examples/models/role_playing_with_sambanova.py b/examples/models/role_playing_with_sambanova.pyindex 2cbba7342..9b8834fe2 100644--- a/examples/models/role_playing_with_sambanova.py+++ b/examples/models/role_playing_with_sambanova.py@@ -17,7 +17,7 @@ from typing import Listimport agentopsfrom colorama import Fore-from camel.agents.chat_agent import FunctionCallingRecord+from camel.agents.chat_agent import ToolCallingRecordfrom camel.configs import SambaCloudAPIConfigfrom camel.models import ModelFactoryfrom camel.societies import RolePlaying@@ -128,8 +128,8 @@ def main(# Print output from the assistant, including any function# execution informationprint_text_animated(Fore.GREEN + "AI Assistant:")- tool_calls: List[FunctionCallingRecord] = [- FunctionCallingRecord(**call.as_dict())+ tool_calls: List[ToolCallingRecord] = [+ ToolCallingRecord(**call.as_dict())for call in assistant_response.info['tool_calls']]for func_record in tool_calls:diff --git a/examples/observability/agentops_track_roleplaying_with_function.py b/examples/observability/agentops_track_roleplaying_with_function.pyindex 800ddfcf3..4570ae4f6 100644--- a/examples/observability/agentops_track_roleplaying_with_function.py+++ b/examples/observability/agentops_track_roleplaying_with_function.py@@ -17,7 +17,7 @@ from typing import Listimport agentopsfrom colorama import Fore-from camel.agents.chat_agent import FunctionCallingRecord+from camel.agents.chat_agent import ToolCallingRecordfrom camel.configs import ChatGPTConfigfrom camel.models import ModelFactoryfrom camel.societies import RolePlaying@@ -125,8 +125,8 @@ while n < chat_turn_limit:# Print output from the assistant, including any function# execution informationprint_text_animated(Fore.GREEN + "AI Assistant:")- tool_calls: List[FunctionCallingRecord] = [- FunctionCallingRecord(**call.as_dict())+ tool_calls: List[ToolCallingRecord] = [+ ToolCallingRecord(**call.as_dict())for call in assistant_response.info['tool_calls']]for func_record in tool_calls:diff --git a/examples/toolkits/arxiv_toolkit.py b/examples/toolkits/arxiv_toolkit.pyindex ddf3a89dd..57e2ba99f 100644--- a/examples/toolkits/arxiv_toolkit.py+++ b/examples/toolkits/arxiv_toolkit.py@@ -55,7 +55,7 @@ response = camel_agent.step(usr_msg)print(str(response.info['tool_calls'])[:1000])'''===============================================================================-[FunctionCallingRecord(func_name='search_papers', args={'query': 'attention is+[ToolCallingRecord(func_name='search_papers', args={'query': 'attention isall you need'}, result=[{'title': "Attention Is All You Need But You Don'tNeed All Of It For Inference of Large Language Models", 'published_date':'2024-07-22', 'authors': ['Georgy Tyukin', 'Gbetondji J-S Dovonon', 'Jean@@ -85,7 +85,7 @@ response = camel_agent.step(usr_msg)print(str(response.info['tool_calls'])[:1000])'''===============================================================================-[FunctionCallingRecord(func_name='download_papers', args={'query': 'attention+[ToolCallingRecord(func_name='download_papers', args={'query': 'attentionis all you need', 'output_dir': '/Users/enrei/Desktop/camel0826/camel/examples/tool_call', 'paper_ids': ['2407.15516v1', '2107.08000v1', '2306.01926v1','2112.05993v1', '1912.11959v2']}, result='papers downloaded successfully')]diff --git a/examples/toolkits/google_scholar_toolkit.py b/examples/toolkits/google_scholar_toolkit.pyindex b00a50353..75137d6fc 100644--- a/examples/toolkits/google_scholar_toolkit.py+++ b/examples/toolkits/google_scholar_toolkit.py@@ -58,7 +58,7 @@ response = camel_agent.step(usr_msg)print(str(response.info['tool_calls'])[:1000])"""===============================================================================-[FunctionCallingRecord(func_name='get_author_detailed_info', args={}, result=+[ToolCallingRecord(func_name='get_author_detailed_info', args={}, result={'container_type': 'Author', 'filled': ['basics', 'indices', 'counts','coauthors', 'publications', 'public_access'], 'scholar_id': 'JicYPdAAAAAJ','source': <AuthorSource.AUTHOR_PROFILE_PAGE: 'AUTHOR_PROFILE_PAGE'>, 'name':@@ -98,7 +98,7 @@ response = camel_agent.step(usr_msg)print(str(response.info['tool_calls'])[:1000])"""===============================================================================-[FunctionCallingRecord(func_name='get_author_publications', args={}, result=+[ToolCallingRecord(func_name='get_author_publications', args={}, result=['Imagenet classification with deep convolutional neural networks', 'Deeplearning', 'Learning internal representations by error-propagation', 'Dropout:a simple way to prevent neural networks from overfitting', 'Visualizing data@@ -127,7 +127,7 @@ response = camel_agent.step(usr_msg)print(response.info['tool_calls'])"""===============================================================================-[FunctionCallingRecord(func_name='get_publication_by_title', args=+[ToolCallingRecord(func_name='get_publication_by_title', args={'publication_title': 'Camel: Communicative agents for" mind" exploration oflarge language model society'}, result={'container_type': 'Publication','source': <PublicationSource.AUTHOR_PUBLICATION_ENTRY:@@ -175,7 +175,7 @@ response = camel_agent.step(usr_msg)print((response.info['tool_calls'])[:1000])"""===============================================================================-[FunctionCallingRecord(func_name='get_full_paper_content_by_link', args=+[ToolCallingRecord(func_name='get_full_paper_content_by_link', args={'pdf_url': 'https://hal.science/hal-04206682/document'}, result='Deeplearning\nYann Lecun, Yoshua Bengio, Geoffrey Hinton\n\nTo cite thisversion:\n\nYann Lecun, Yoshua Bengio, Geoffrey Hinton. Deep learning. Nature,diff --git a/examples/toolkits/notion_toolkit.py b/examples/toolkits/notion_toolkit.pyindex b57e6c7bd..a59451b64 100644--- a/examples/toolkits/notion_toolkit.py+++ b/examples/toolkits/notion_toolkit.py@@ -55,7 +55,7 @@ response = camel_agent.step(usr_msg)print(str(response.info['tool_calls'])[:1000])"""==========================================================================-[FunctionCallingRecord(func_name='list_all_pages', args={}, result=[{'id':+[ToolCallingRecord(func_name='list_all_pages', args={}, result=[{'id':'12684f56-4caa-8080-be91-d7fb1a5834e3', 'title': 'test page'},{'id': '47a4fb54-e34b-4b45-9928-aa2802982eb8', 'title': 'Aigentbot'}])]"""@@ -71,7 +71,7 @@ response = camel_agent.step(usr_msg)print(str(response.info['tool_calls'])[:1000])"""==========================================================================-[FunctionCallingRecord(func_name='get_notion_block_text_content', args=+[ToolCallingRecord(func_name='get_notion_block_text_content', args={'block_id': '12684f56-4caa-8080-be91-d7fb1a5834e3'}, result='hellonihaobuhao this is a test par [Needs case added] another par [Needs case added]A cute cat: https://www.google.com/imgres?q=cat&imgurl=https%3A%2F%2Fi.@@ -92,7 +92,7 @@ response = camel_agent.step(usr_msg)print(str(response.info['tool_calls'])[:1000])"""==========================================================================-[FunctionCallingRecord(func_name='list_all_users', args={}, result=[{'type':+[ToolCallingRecord(func_name='list_all_users', args={}, result=[{'type':'person', 'name': 'user a', 'workspace': ''}, {'type': 'bot', 'name':'test', 'workspace': "user a's Notion"}])]==========================================================================diff --git a/examples/toolkits/openapi_toolkit.py b/examples/toolkits/openapi_toolkit.pyindex 81d32b25a..bfb13477e 100644--- a/examples/toolkits/openapi_toolkit.py+++ b/examples/toolkits/openapi_toolkit.py@@ -53,7 +53,7 @@ response = camel_agent.step(usr_msg)print(response.info['tool_calls'])"""===============================================================================-[FunctionCallingRecord(func_name='klarna_productsUsingGET', args={+[ToolCallingRecord(func_name='klarna_productsUsingGET', args={'q_in_query': 'basketball'}, result={'products': [{'name': 'Wilson Evolution', 'url': 'https://www.klarna.com/us/shopping/pl/cl1220/3203801266/Basketball/Wilson-Evolution/?utm_source=openai&ref-site=openai_plugin', 'price':diff --git a/examples/toolkits/role_playing_with_functions.py b/examples/toolkits/role_playing_with_functions.pyindex b51652332..157ea4bf1 100644--- a/examples/toolkits/role_playing_with_functions.py+++ b/examples/toolkits/role_playing_with_functions.py@@ -16,7 +16,7 @@ from typing import Listfrom colorama import Fore-from camel.agents.chat_agent import FunctionCallingRecord+from camel.agents.chat_agent import ToolCallingRecordfrom camel.configs import ChatGPTConfigfrom camel.models import ModelFactoryfrom camel.societies import RolePlaying@@ -122,8 +122,8 @@ def main(# Print output from the assistant, including any function# execution informationprint_text_animated(Fore.GREEN + "AI Assistant:")- tool_calls: List[FunctionCallingRecord] = [- FunctionCallingRecord(**call.as_dict())+ tool_calls: List[ToolCallingRecord] = [+ ToolCallingRecord(**call.as_dict())for call in assistant_response.info['tool_calls']]for func_record in tool_calls:diff --git a/test/agents/test_chat_agent.py b/test/agents/test_chat_agent.pyindex 3586b7ba1..29f63819b 100644--- a/test/agents/test_chat_agent.py+++ b/test/agents/test_chat_agent.py@@ -30,7 +30,7 @@ from PIL import Imagefrom pydantic import BaseModel, Fieldfrom camel.agents import ChatAgent-from camel.agents.chat_agent import FunctionCallingRecord+from camel.agents.chat_agent import ToolCallingRecordfrom camel.configs import ChatGPTConfigfrom camel.generators import SystemMessageGeneratorfrom camel.memories import MemoryRecord@@ -857,16 +857,16 @@ def test_tool_calling_sync(step_call_count=3):for i in range(step_call_count):agent_response = agent.step(user_msg)- tool_calls: List[FunctionCallingRecord] = [+ tool_calls: List[ToolCallingRecord] = [call for call in agent_response.info['tool_calls']]assert len(tool_calls) > 0, f"Error in calling round {i+1}"assert str(tool_calls[0]).startswith(- "Function Execution"+ "Tool Execution"), f"Error in calling round {i+1}"assert (- tool_calls[0].func_name == "multiply"+ tool_calls[0].tool_name == "multiply"), f"Error in calling round {i+1}"assert tool_calls[0].args == {"a": 2,@@ -985,7 +985,7 @@ async def test_tool_calling_math_async(step_call_count=3):tool_calls = agent_response.info['tool_calls']assert (- tool_calls[0].func_name == "multiply"+ tool_calls[0].tool_name == "multiply"), f"Error in calling round {i+1}"assert tool_calls[0].args == {"a": 2,@@ -1074,11 +1074,11 @@ async def test_tool_calling_async(step_call_count=3):assert tool_calls, f"Error in calling round {i+1}"assert str(tool_calls[0]).startswith(- "Function Execution"+ "Tool Execution"), f"Error in calling round {i+1}"assert (- tool_calls[0].func_name == "async_sleep"+ tool_calls[0].tool_name == "async_sleep"), f"Error in calling round {i+1}"assert tool_calls[0].args == {'second': 1