diff --git a/examples/custom_tool.py b/examples/custom_tool.py index e07433c..9bbb71d 100644 --- a/examples/custom_tool.py +++ b/examples/custom_tool.py @@ -7,7 +7,6 @@ https://github.com/i-am-bee/bee-code-interpreter/blob/main/executor/requirements.txt """ -import inspect import os import warnings from datetime import datetime @@ -28,6 +27,9 @@ def heading(text: str) -> str: # Define hosted function, all requirements must be available in the hosted executor environment. # Docstring must be defined and satisfy the following format: +ip_info_code = ''' +import requests + def ip_info(ip: str) -> dict: """ Get information about an IP address, such as location, company, and carrier name. @@ -35,11 +37,10 @@ def ip_info(ip: str) -> dict: :param ip: IP address in the 255.255.255.255 format :return: Information about the IP address """ - import requests - response = requests.get(f"https://ipinfo.io/{ip}/geo") response.raise_for_status() return response.json() +''' # Get existing tools using Bee API extension @@ -67,7 +68,7 @@ class SourceCodeTool(openai.BaseModel): "/tools", cast_to=SourceCodeTool, # You can also pass the source code directly as a string without python definition - body={"source_code": inspect.getsource(ip_info)}, + body={"source_code": ip_info_code}, ) print("Tool:") pprint(custom_tool.model_dump())