A reference implementation for the tulip agent
, an LLM-backed agent with access to a large number of tools via a tool library.
This approach reduces costs, enables the use of tool sets that exceed API limits or context windows, and increases flexibility with regard to the tool set used.
🔬 Function analysis
Generates OpenAI API compatible tool descriptions for Python functions via introspection
🌷 Tool library
Combines a vector store for semantic search among tools and tool execution
🤖 Agents
Specifying instructions
for an agent completely overrides the base system prompts to avoid contradictions.
You can append custom instructions to the default prompts in tulip_agent.prompts
.
- Baseline, without tool library
BaseAgent
: LLM agent without tool accessNaiveToolAgent
: Includes tool descriptions for all tools availableCotToolAgent
: Extends theNaiveToolAgent
with a planning step that decomposes the user input into subtasks
- Tulip variations with access to a tool library
MinimalTulipAgent
: Minimal implementation; searches for tools based on the user input directlyNaiveTulipAgent
: Naive implementation; searches for tools with a separate tool callCotTulipAgent
: COT implementation; derives a plan for the necessary steps and searches for suitable toolsInformedCotTulipAgent
: Same asCotTulipAgent
, but with a brief description of the tool library's contentsPrimedCotTulipAgent
: Same asCotTulipAgent
, but primed with tool names based on an initial search with the user requestOneShotCotTulipAgent
: Same asCotTulipAgent
, but the system prompt included a brief exampleAutoTulipAgent
: Fully autonomous variant; can use the search tool at any time and modify its tool library with CRUD operationsDfsTulipAgent
: DFS inspired variant that leverages a DAG for keeping track of tasks and suitable tools, can create new tools
📊 Evaluation
math_eval
: Math evaluationrobo_eval
: Robotics evaluation using tools created for AttentiveSupport
📝 Examples
See ./examples
- Make sure to set the environment variables required by the API of your choice. Currently supported:
- OpenAI:
OPENAI_API_KEY
, see the official instructions - Azure:
AZURE_OPENAI_API_KEY
,AZURE_API_VERSION
, andAZURE_OPENAI_ENDPOINT
- OpenAI compatible endpoints:
OAI_COMPATIBLE_BASE_URL
andOAI_COMPATIBLE_API_KEY
for OpenAI compatible endpoints, such as Ollama
- OpenAI:
- Install with
poetry install
orpip install -e .
- Check out the
examples
, the robot evaluation insrc/eval/robo_eval
, andexamples/local_examples.py
for a local setup
- Python v3.10.11 recommended, higher versions may lead to issues with chroma when installing via Poetry
- Pre-commit hooks - install with
(poetry run) pre-commit install
- Linting: ruff
- Formatting: black
- Import sorting: isort
- Tests: Run with
(poetry run) python -m unittest discover tests/
See these troubleshooting instructions
- On Linux install pysqlite3-binary:
poetry add pysqlite3-binary
- Add the following to
lib/python3.10/site-packages/chromadb/__init__.py
in your venv
__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
Make sure to install the package itself, e.g., with poetry install
or pip install -e .
Then run the example with poetry run python examples/calculator_example.py