From b158e04ab8a3ce824171ad4c1a8a757193d26f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Je=C5=BEek?= Date: Wed, 13 Nov 2024 12:43:11 +0100 Subject: [PATCH] fix: update custom tool example to use string instead of code --- examples/custom_tool.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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())