python agent for inference handling
Project description
org.slashlib.py.agent
A highly decoupled, asynchronous framework for building AI agents in Python.
Core Concept
This package provides a robust infrastructure to connect AI models (Inference Engines) with functional tools. The focus lies on Provider Agnosticism: The agent does not need to know whether it is communicating with Ollama, OpenAI, or a local model—it uses standardized adapters to ensure seamless integration.
Key Features
- Asynchronous Core: Built on
asynciofor non-blocking task execution. - Provider Agnostic: Easily swap the AI engine using the Adapter pattern.
- Automatic Tool Schemas: Automatically transforms Python functions into JSON schemas for LLMs via decorators.
- Multiton Pattern: Ensures unique agent instances by identifier, preventing redundant resource allocation.
- Robust Exception Hierarchy: Clearly separates connection, configuration, and tool execution errors.
Installation
Install the package via pip:
pip install org.slashlib.py.agent
Quick Start
Setting up an agent with a tool and the Ollama adapter is straightforward:
import asyncio
from org.slashlib.py.agent import Agent, OllamaInferenceAdapter, tool
# 1. Define a tool
@tool(description="Adds two numbers.")
async def add_numbers(a: int, b: int) -> int:
return a + b
async def main():
# 2. Configure Adapter and Agent
adapter = OllamaInferenceAdapter()
my_agent = Agent(
identifier="MathExpert",
tools=[add_numbers],
adapter=adapter
)
# 3. Start task (non-blocking)
task = my_agent.run(user_prompt="What is 123 + 456?")
# 4. Retrieve result
response = await task
print(f"Response: {response.get_last_content()}")
if __name__ == "__main__":
asyncio.run(main())
Documentation & Obsidian
The project root is pre-configured as an Obsidian Vault. If you open this folder directly in Obsidian, all settings and documentation links will be available immediately via the included .obsidian directory.
The following community plugins are pre-configured in the vault to enhance the documentation experience:
- File Include: Embed code files directly into your markdown documentation.
- Folder Notes: Add descriptions at the folder level.
- Front Matter Title: Use metadata for descriptive file titles.
- Hide Folders: Keeps the structure clean by hiding internal directories.
- Iconic & Icons: Improved visual navigation.
License
This project is licensed under the MIT License - see the LICENSE file for details.
© 2026 org.slashlib
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file org_slashlib_py_agent-0.1.0.tar.gz.
File metadata
- Download URL: org_slashlib_py_agent-0.1.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f2a1581a0f910dfeb0cf92bc3e07e80521d934548dbee7c66a294ea2a79d165
|
|
| MD5 |
4f2b8a014810ff5f18844f53feb56a40
|
|
| BLAKE2b-256 |
c4a3cd6350e2a0637d2e3b30b0681c21da63e3765315580d5085ff30e00eed9e
|
File details
Details for the file org_slashlib_py_agent-0.1.0-py3-none-any.whl.
File metadata
- Download URL: org_slashlib_py_agent-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2faa6174a23984ce96e8e5d605dbd96c0ac0d6340a1010e03445eb3440f92db
|
|
| MD5 |
a0b4ea7bd7e6765276c66cfac9e8f965
|
|
| BLAKE2b-256 |
c10476cd4f2dfc0f8ff2b133d09d68f33688f7af12bff61cc76e4cc855d7c975
|