Skip to main content

Create an agent that can handle a large number of tools with persistence support.

Project description

AgentAmi

AgentAmi is a flexible agentic framework built using LangGraph, designed to scale with large numbers of tools and intelligently select the most relevant ones for a given user query. It helps with decreasing token size significantly.

It supports:

  • Dynamic tool selection via inbuilt runtime RAG (very efficient) with an option to easily replace it with your own tool_selector.
  • Pruner to limit context length and improve performance (it's inbuilt, you don't have to do anything).

Quick start

Refer the main.py file for a complete sample usage.

pip install agentami
from agentami import AgentAmi
from langchain.chat_models import ChatOpenAI
from langgraph.checkpoint.memory import InMemorySaver
from agentami.agents.ami import AgentAmi

# Replace ... (ellipsis) with the commented instructions

tools = [...]  # List of LangChain-compatible tools
agent = AgentAmi(
    model=ChatOpenAI(model="gpt-4o"),
    tools=tools,  # List of LangChain-compatible tools
    checkpointer=InMemorySaver(),  # Optional. No persistence if omitted.

    # Optional parameters:
    tool_selector=...,  # Custom function to select relevant tools. Defaults to internal tool_selector.
    top_k=...,  # Number of top tools to use. Defaults to 3.
    context_size=...,  # Number of past user prompts to retain. Defaults to 7.
    disable_pruner=...,  # If True, disables pruning & will increase token usage. Defaults to False
    prompt_template=...  # Custom prompt template. Defaults to a generic bot template.
)
agent_ami = agent.graph # Your regular langgraph's graph.

Things you should be aware about:

  • Running for the first time will take time as it installs the dependencies (models used by internal tool_selector).
  • Your first agent_ami.invoke() or agent_agent_ami.astream() may take time if you have hundreds of tools, because it initialises a vector store and embeds the tool descriptions at runtime for each AgentAmi() object
  • Your eventual prompts' response time would be fine.
  • Checkout ROADMAP.md file for future features.

How to integrate your own tool selector?

Just make a function that accepts (query: str, top_k: int) and parameters and returns List[str] #List of tool names.

from typing import List


# function template:
def my_own_tool_selector(query: str, top_k: int) -> List[str]:
    # Your logic to select tools based on the query
    return ["tool1", "tool2", "tool3"]  # Return top_k selected tool names

AgentAmi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentami-1.0.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentami-1.0.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file agentami-1.0.1.tar.gz.

File metadata

  • Download URL: agentami-1.0.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for agentami-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b79b6e72975070dd9f0f5e0c82e8b20f46af0c4c941ccab22c2f1a99b029dc13
MD5 004cba6b30aa76d58c7d5747a38b33b9
BLAKE2b-256 daa27c18e8d2b701ca582e9983228165c565596fb5067699d7f64c44b9be3b27

See more details on using hashes here.

File details

Details for the file agentami-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: agentami-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for agentami-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0fd2e5607c3fed53a8d40b03988a5b5ddbc3a4182872922ed112c1caab2023d6
MD5 9b6313a2837c186471811218d9e774a7
BLAKE2b-256 51e827eeeccea5ed9cc47cdce0ebd6c12ad1083e54881b22df0ecaabc5a6c526

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page