RetrievalModule

class oscopilot.modules.retriever.vector_retriever.FridayRetriever(prompt, tool_manager)[source]

Bases: BaseModule

A modules within the system responsible for retrieving and managing available tools from the tool library.

The RetrievalModule extends the BaseModule class, focusing on the retrieval of tools based on specific prompts or queries. It interacts with a language learning model (LLM) and utilizes the execution environments and tool library to fulfill its responsibilities.

delete_tool(tool)[source]

Deletes the specified tool from the tool library.

This method calls the tool library’s delete method to remove an tool by its name. It encompasses deleting the tool’s code, description, parameters, and any other associated information.

Parameters:

tool (str) – The name of the tool to be deleted.

retrieve_tool_code(tool_name)[source]

Retrieves the code for a specified tool from the tool library.

This method accesses the tool library to get the executable code associated with an tool identified by its name. This code defines how the tool is performed.

Parameters:

tool_name (str) – The name of the tool whose code is to be retrieved.

Returns:

The code of the specified tool.

Return type:

str

retrieve_tool_code_pair(retrieve_tool_name)[source]

Retrieves a mapping of tool names to their respective codes for a list of tools.

This method processes a list of tool names, retrieving the code for each and compiling a dictionary that maps each tool name to its code. This is useful for tasks that require both the identification and the execution details of tools.

Parameters:

retrieve_tool_name (list[str]) – A list of tool names for which codes are to be retrieved.

Returns:

A dictionary mapping each tool name to its code.

Return type:

dict

retrieve_tool_description(tool_name)[source]

Retrieves the description for a specified tool from the tool library.

This method queries the tool library for the description of an tool identified by its name. It is designed to fetch detailed descriptions that explain what the tool does.

Parameters:

tool_name (str) – The name of the tool whose description is to be retrieved.

Returns:

The description of the specified tool.

Return type:

str

retrieve_tool_description_pair(retrieve_tool_name)[source]

Retrieves a mapping of tool names to their descriptions for a list of tools.

By processing a list of tool names, this method fetches their descriptions and forms a dictionary that associates each tool name with its description. This facilitates understanding the purpose and functionality of multiple tools at once.

Parameters:

retrieve_tool_name (list[str]) – A list of tool names for which descriptions are to be retrieved.

Returns:

A dictionary mapping each tool name to its description.

Return type:

dict

retrieve_tool_name(task, k=10)[source]

Retrieves a list of tool names relevant to the specified task.

This method interacts with the tool library to retrieve names of tools that are most relevant to a given task. The number of tool names returned is limited by the parameter k.

Parameters:
  • task (str) – The task for which relevant tool names are to be retrieved.

  • k (int, optional) – The maximum number of tool names to retrieve. Defaults to 10.

Returns:

A list of the top k tool names relevant to the specified task.

Return type:

list[str]

tool_code_filter(tool_code_pair, task)[source]

Filters and retrieves the code for an tool relevant to the specified task.

This method formats a message for filtering tool codes based on a given task, sends the message to the tool library for processing, and retrieves the filtered tool’s code. If an tool name is successfully identified, its corresponding code is fetched from the tool library.

Parameters:
  • tool_code_pair (dict) – A dictionary mapping tool names to their codes.

  • task (str) – The task based on which the tool code needs to be filtered.

Returns:

The code of the tool relevant to the specified task, or an empty string if no relevant tool is found.