🛠️ Tools

Overview

GEM provides a comprehensive set of tools to enhance agent capabilities and enable sophisticated problem-solving approaches. GEM currently supports python and search tools to enhance agent capabilities and enable more sophisticated problem-solving approaches.

Python Tool

Allows agents to write and execute Python code, enabling computational problem-solving and data manipulation capabilities.

GEM’s python code tool allows the agent to learn to write code. The python tool parses code blocks, runs them, and returns the result.

API Reference

gem.tools.python_code_tool.PythonCodeTool

.execute_action(action: str)
Parses the action to find the first complete code block. If a valid code block is found the code is run and the output is returned.

Parameters

  • action (str)
    The response from the LLM agent.

Returns

  • is_valid (bool)
    Whether a valid code block is found.
  • has_error (bool)
    Whether the code gave an error.
  • observation (str)
    The output of running the code if a valid code block is found, otherwise an empty string.
  • parsed_action (str)
    The action truncated at the end of the first valid code block. If no code block is found then parsed_action is set to the input action.
.instruction_string()
A string for adding to the prompt to instruct the agent that the python code tool is available.

Returns

  • str
    Instruction string for the agent

Search Tool

GEM includes a search tool, enabling the agent to learn to call search engines for information retrieval and knowledge enhancement.

API Reference

gem.tools.search_tool.SearchTool

.execute_action(action: str)
Parses the action to find the first complete extract the <search> content. Returns the result of the search if a valid search call is found.

Parameters

  • action (str)
    The response from the LLM agent.

Returns

  • is_valid (bool)
    Whether a valid <search></search> call is found.
  • has_error (bool)
    Whether the search engine gave an error.
  • observation (str)
    The output of running the search if a valid search call is found, otherwise an empty string.
  • parsed_action (str)
    The action truncated at the end of the first valid search call. If no search call is found then parsed_action is set to the input action.
.instruction_string()
A string for adding to the prompt to instruct the agent that the search tool is available.

Returns

  • str
    Instruction string for the agent

Usage

Agents can use the search tool by including search queries in their responses using the <search></search> tags. The tool will:

  1. Parse the search query from the agent’s response
  2. Execute the search using the configured search engine
  3. Return the search results to the agent
  4. Allow the agent to use this information for better responses