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

Feature: plugin/tools with input params #753

Open
autonomous-spores opened this issue Jan 16, 2025 · 7 comments
Open

Feature: plugin/tools with input params #753

autonomous-spores opened this issue Jan 16, 2025 · 7 comments
Assignees

Comments

@autonomous-spores
Copy link

Image

Figure 1 illustrates the method for defining tools within swarms(line 47), utilizing an 'array' to dynamically load functions, such as fetch_current_weather. Below is a pseudocode example demonstrating a function with input parameters:

def fetch_current_weather(city: str) -> str:
	"""
	Fetches the current weather for a given city from the OpenWeatherMap API.
	Args:
	    city (str): The name of the city to fetch the weather for.
	
	Returns:
	    str: A formatted string of the current weather in the specified city.
	
	Raises:
	    ValueError: If the API response is invalid or the city is not found.
	"""
	try:
	    temperature = random.uniform(0.0, 1.0)
	    return f"The current weather in {city} with a temperature of {temperature}°C."
	
	except ValueError as e:
	    print(f"Value Error: {e}")
	    raise

The tools function by sending prompts, generated based on the annotations in the function above, to the agent to determine if the conversation between the LLM and the user includes a query about the weather.

For instance, consider the query, "How’s the weather in London today?" The program is expected to have "London" as the input and process it based on the LLM's response.

{
    "type": "function",
    "function": {
        "name": "fetch_current_weather",
        "parameters": {
            "city": "London"
        }
    }
}

Image

When implementing plugins in practice, it is essential to execute them with context-specific inputs, as demonstrated below. Ideally, we aim for the fetch_current_weather function to operate with a payload that accommodates variations.

def fetch_current_weather(payload: any, city: str) -> str:
	...
	...
	...

https://github.com/spore-swarm/autonomous-spores/blob/main/spores/core/runtime.py#L46

In the spores-swarm repository(we are building runtime module right now), we want it to be as shown in this link rather than as written at line 47.

kindly ask any ideas for this feature? or is there any alternative ways to get there, or will be featured in future?

Copy link

Hello there, thank you for opening an Issue ! 🙏🏻 The team was notified and they will get back to you asap.

@kyegomez
Copy link
Owner

@autonomous-spores the agent will automatically fill in the parameters of the function ;) The agent will make the input of all the input to the function.

@kyegomez
Copy link
Owner

@autonomous-spores you essentially just put the name of the function into the tools parameter:

tools = [name_of_tool]

@autonomous-spores
Copy link
Author

@autonomous-spores the agent will automatically fill in the parameters of the function ;) The agent will make the input of all the input to the function.

emm, i mean i wanna access the fields of the object.

for instance, i got answer "London" from conversations with LLM. but i wanna now how's the weather in Westminster which is central London.

"London" is a string from LL's replies without access to its sub-fields.

tools = [get_current_weather]

call:
get_current_weather(London).

I expect London is an object that allows me to access 'Westminster'

get_current_weather(london(object).westminster)

@kyegomez
Copy link
Owner

@autonomous-spores you would tell the agent to search the weather in westminister, and it would then search the weather for that city in natural language. The agent will fill in the input parameters of the function, you can set a default parameter however,

search_weather( city: str = "westminister" )

@autonomous-spores
Copy link
Author

London is the object, as we defined and structured it in code, in the context of runtime. occasionally, i need to access some fields within the object in runtime instead of obtaining "string" answer in natural language from LLM.

@kyegomez
Copy link
Owner

@autonomous-spores fix this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants