This directory contains offchain tools for LLM inference and other functionalities.
Model inference currently relies on ollama through the server/main.py route /predict
, which runs inference
of the defined ollama models.
Available tools are defined in server/tools/tools.py. Current supported tools are listed
below and any desired tools can be added by following the instructions in Adding Tools.
Tools are executed through the server/main.py route /tool/use
.
Note: to use the OpenAI, Gemini, Scenexplain, or Tavily tools, equivalent api keys must be set in the .env
and can be obtained here:
The above tools can also be deleted if not desired for simplicity.
In server/tools/tools.py, each tool has a defined argument structure which inherits from pydantic
BaseModel
,
and a ToolCallBody
which consists of their name and the argument substructure.
TOOL_ARGS_MAPPING
is a dictionary of available tools and their args, and TOOLS
is a dictionary of available tools
and their actual executables, wrapped by the create_clusterai_tool
function which allows for any lambda
function to be defined as a tool. This setup was intended towards support of definition of tools from onchain.
search
: Web search using DuckDuckGo.wikipedia
: Query Wikipedia for information.arxiv
: Search academic papers on arXiv.pubmed
: Search medical and life sciences literature.scene_explain
: Explain the contents of an image.shell
: Execute shell commands.tavily_search
: Perform searches using Tavily.python_repl
: Execute Python code.read_file
: Read the contents of a file.list_directory
: List the contents of a directory.gpt4_vision
: Analyze images using GPT-4 Vision.dalle3
: Generate images based on text prompts.openai_embeddings
: Create text embeddings using OpenAI's API.browser
: Scrape and summarize website content.instagram_search
: Search for Instagram-specific content.
Note: Each tool accepts specific arguments as defined in the TOOL_ARGS_MAPPING
in the tools.py
file. The AI model can use these tools by specifying the tool name and providing the required arguments.
To run the tests:
pip3 install pytest
PYTHONPATH=src pytest tests