camel-ai / camel

🐫 CAMEL: Finding the Scaling Law of Agents. The first and the best multi-agent framework. https://www.camel-ai.org
https://docs.camel-ai.org/
Apache License 2.0
5.72k stars 698 forks source link

[Feature Request] Tools search #569

Open Wendong-Fan opened 6 months ago

Wendong-Fan commented 6 months ago

Required prerequisites

Motivation

Feature to let agent search & choose tools from provided schema. Potentially we can use semantic search on tasks with the json schema / docstring.

def retrieve_tools(query: str, tools: List[OpenAIFunction], k: int = 3) -> List[OpenAIFunction]:
    ...
    # Using semantic search to retrieve relevent tools
    # OpenAI / Open source Embedding models to embed the query and the schemas / docstring of `OpenAIFunction`
    # Find the most relevent ones based on their embedding vectors
    return retrieved_tools

# An example:
retrieved_tools = retrieve_tools('how is the weather today', tools=[get_weather, google_search, send_tweet, create_pull_request], k=2)
# get_weather, google_search

# We can put the implementation here: https://github.com/camel-ai/camel/tree/master/camel/functions

@Hither1 will be the main developer for this PR. @yiyiyi0817 and @Wendong-Fan can help her along the way. Targeted deadline is May 30.

Solution

No response

Alternatives

No response

Additional context

No response

Hither1 commented 6 months ago

@lightaime @Wendong-Fan @yiyiyi0817 I was wondering do we assume the functions/tools list is always all other functions implemented in the Camel framework? And what should the function return when there is no tool that may be relevant to the query?

yiyiyi0817 commented 6 months ago

@lightaime @Wendong-Fan @yiyiyi0817 I was wondering do we assume the functions/tools list is always all other functions implemented in the Camel framework? And what should the function return when there is no tool that may be relevant to the query?

My idea is that we can apply a filter to the function_list passed in (which may be all of the functions now, or some of the functions selected by the user, or none at all), but the filter should not be too strict, just remove completely irrelevant functions. Just a suggestion

lightaime commented 6 months ago

@lightaime @Wendong-Fan @yiyiyi0817 I was wondering do we assume the functions/tools list is always all other functions implemented in the Camel framework? And what should the function return when there is no tool that may be relevant to the query?

  1. We can let users to specify the functions/tools
  2. We can apply a threshold on the similarity to the search. If all the tools are lower than the threshold, we can return None.