Skip to main content

A lightweight Python framework for adding agent capabilities (tools calling, memory, structured outputs) to single custom LLM functions

Project description

AgenticWrapper

English | 简体中文

AgenticWrapper is an extremely lightweight Python Agent framework that wraps your custom LLM function, enabling it with Agent capabilities, including tool calling, memory management, and structured output.

AgenticWrapper has no runtime dependencies.

Quick Start

Installation

pip install AgenticWrapper

Basic Usage

from AgenticWrapper import Agent

async def llm_func(messages: list[dict[str, str]]) -> str:
    # Assume this is your custom LLM function
    return "Hello, I'm AgenticWrapper."

agent = Agent(llm_func)
response = await agent.query("Hello")
print(response)
agent.clear_memory()

Structured Output

Use Python dataclass to define the output structure:

@dataclass
class SearchResult:
    query: str
    results: List[str]
    total_count: int

response = await agent.query("Search for relevant content", structured_output_type=SearchResult)
assert isinstance(response, SearchResult)

Tool Calling

Define a tool function, preferably with function documentation:

async def get_weather(location: str) -> str:
    """Get weather information"""
    # Simulate an API call
    await asyncio.sleep(0.1)
    if location.lower() == "london":
        return "The weather is clear, with a temperature of 15°C."
    elif location.lower() == "paris":
        return "The weather is clear, with a temperature of 18°C."
    else:
        return f"I don't know the weather for {location}."

Use the tool in the Agent:

agent = Agent(llm_interaction_func=mock_llm_func, tools=[get_weather])
response = await agent.query("Check the weather in london")
print(response)

Tool function parameters and return types must be str. If your tool function has complex parameters, you need to define a new wrapper function to handle serialization/deserialization and communicate the format to the LLM.

More Examples

More examples can be found in example.py.

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

agenticwrapper-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

agenticwrapper-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file agenticwrapper-0.1.0.tar.gz.

File metadata

  • Download URL: agenticwrapper-0.1.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.9

File hashes

Hashes for agenticwrapper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e367ef1b1aea3bcbfecd1810dbdb1afa170d346ae172392d0f2cf6562712221
MD5 4c269e6e53cd04aaa367d30538efc4e6
BLAKE2b-256 19785471a76d1367eb59e606cfc9c3da5572286c92d2e1fa80b71c72402b5d73

See more details on using hashes here.

File details

Details for the file agenticwrapper-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agenticwrapper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7e1761489b31c9fe40dab5760caf51156e92c3efaeb6542be3ebf32b4313d11
MD5 378443cf0fbccc0f545249b3e453c5d7
BLAKE2b-256 b117ec0ca82abc67f9a347609f6930917c1aeb7ff0f135a78441e951169396e3

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