Create a tool. This stores the source code of function on the server, so that the server can execute the function and generate an OpenAI JSON schemas for it when using with an agent. Args: func (callable): The function to create a tool for. tags (Optional[Li
(
self,
func,
tags: Optional[List[str]] = None,
description: Optional[str] = None,
return_char_limit: int = FUNCTION_RETURN_CHAR_LIMIT,
)
| 2948 | return self.server.tool_manager.create_or_update_composio_tool(tool_create=tool_create, actor=self.user) |
| 2949 | |
| 2950 | def create_tool( |
| 2951 | self, |
| 2952 | func, |
| 2953 | tags: Optional[List[str]] = None, |
| 2954 | description: Optional[str] = None, |
| 2955 | return_char_limit: int = FUNCTION_RETURN_CHAR_LIMIT, |
| 2956 | ) -> Tool: |
| 2957 | """ |
| 2958 | Create a tool. This stores the source code of function on the server, so that the server can execute the function and generate an OpenAI JSON schemas for it when using with an agent. |
| 2959 | |
| 2960 | Args: |
| 2961 | func (callable): The function to create a tool for. |
| 2962 | tags (Optional[List[str]], optional): Tags for the tool. Defaults to None. |
| 2963 | description (str, optional): The description. |
| 2964 | return_char_limit (int): The character limit for the tool's return value. Defaults to FUNCTION_RETURN_CHAR_LIMIT. |
| 2965 | |
| 2966 | Returns: |
| 2967 | tool (Tool): The created tool. |
| 2968 | """ |
| 2969 | # TODO: check if tool already exists |
| 2970 | # TODO: how to load modules? |
| 2971 | # parse source code/schema |
| 2972 | source_code = parse_source_code(func) |
| 2973 | source_type = "python" |
| 2974 | name = func.__name__ # Initialize name using function's __name__ |
| 2975 | if not tags: |
| 2976 | tags = [] |
| 2977 | |
| 2978 | # call server function |
| 2979 | return self.server.tool_manager.create_tool( |
| 2980 | Tool( |
| 2981 | source_type=source_type, |
| 2982 | source_code=source_code, |
| 2983 | name=name, |
| 2984 | tags=tags, |
| 2985 | description=description, |
| 2986 | return_char_limit=return_char_limit, |
| 2987 | ), |
| 2988 | actor=self.user, |
| 2989 | ) |
| 2990 | |
| 2991 | def create_or_update_tool( |
| 2992 | self, |
nothing calls this directly
no test coverage detected