A lightweight, dependency-free LLM agent framework with direct HTTP-based provider integration
Project description
nagents
A lightweight LLM agent framework with direct HTTP-based provider integration.
Features
- Multi-Provider Support: OpenAI, Anthropic Claude, and Google Gemini APIs
- Streaming Events: Real-time text chunks, tool calls, and usage statistics
- Tool Execution: Register Python functions as tools with automatic schema generation
- Session Management: SQLite-based conversation persistence
- Batch Processing: Process multiple requests efficiently
- Minimal Dependencies: Only
aiohttpandaiosqliterequired
Installation
pip install nagents
Quick Start
import asyncio
from nagents import Agent, Provider, ProviderType
async def main():
# Create a provider
provider = Provider(
provider_type=ProviderType.OPENAI_COMPATIBLE,
api_key="your-api-key",
model="gpt-4o-mini",
)
# Create an agent
agent = Agent(provider=provider)
# Run a conversation
async for event in agent.run("Hello, how are you?"):
if hasattr(event, 'chunk'):
print(event.chunk, end="")
await agent.close()
asyncio.run(main())
Providers
nagents supports three provider types:
| Provider | Type | Models |
|---|---|---|
| OpenAI | ProviderType.OPENAI_COMPATIBLE |
gpt-4o, gpt-4o-mini, etc. |
| Anthropic | ProviderType.ANTHROPIC |
claude-3-5-sonnet, claude-3-opus, etc. |
ProviderType.GEMINI_NATIVE |
gemini-2.0-flash, gemini-1.5-pro, etc. |
With Tools
def get_weather(city: str) -> str:
"""Get the current weather for a city."""
return f"Weather in {city}: Sunny, 22°C"
agent = Agent(
provider=provider,
tools=[get_weather],
)
async for event in agent.run("What's the weather in Paris?"):
...
With Session Persistence
from pathlib import Path
from nagents import SessionManager
session_manager = SessionManager(Path("sessions.db"))
agent = Agent(
provider=provider,
session_manager=session_manager,
)
# Use a specific session ID for conversation continuity
async for event in agent.run("Remember my name is Alice", session_id="user-123"):
...
Documentation
License
MIT
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 nagents-0.2.6.tar.gz.
File metadata
- Download URL: nagents-0.2.6.tar.gz
- Upload date:
- Size: 85.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24a8e1e42619f0fc7a26bea9b2c63fc086b32cf13f5961ec73dd00709f2d89d0
|
|
| MD5 |
15b751ab5b6a0054283eed8731942a13
|
|
| BLAKE2b-256 |
be49c3c956335f208fcd3eb704ee7224a91b24e83eb4f44cd7f42fc49b3b9564
|
Provenance
The following attestation bundles were made for nagents-0.2.6.tar.gz:
Publisher:
ci.yml on abi-jey/nagents
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nagents-0.2.6.tar.gz -
Subject digest:
24a8e1e42619f0fc7a26bea9b2c63fc086b32cf13f5961ec73dd00709f2d89d0 - Sigstore transparency entry: 993306435
- Sigstore integration time:
-
Permalink:
abi-jey/nagents@37f21d691e11a59cf2b967ffeafb092f8fc5ce6c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/abi-jey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@37f21d691e11a59cf2b967ffeafb092f8fc5ce6c -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file nagents-0.2.6-py3-none-any.whl.
File metadata
- Download URL: nagents-0.2.6-py3-none-any.whl
- Upload date:
- Size: 67.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59b9fc3530f461d128626be640701d64624996ac331421c3ea48f42c926d06c9
|
|
| MD5 |
566602e487a50360f1f7ed6582d08aa2
|
|
| BLAKE2b-256 |
d8d885fc05f2ae237de29017024f507c039d824e251a9c204e493da670e7dd8d
|
Provenance
The following attestation bundles were made for nagents-0.2.6-py3-none-any.whl:
Publisher:
ci.yml on abi-jey/nagents
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nagents-0.2.6-py3-none-any.whl -
Subject digest:
59b9fc3530f461d128626be640701d64624996ac331421c3ea48f42c926d06c9 - Sigstore transparency entry: 993306509
- Sigstore integration time:
-
Permalink:
abi-jey/nagents@37f21d691e11a59cf2b967ffeafb092f8fc5ce6c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/abi-jey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@37f21d691e11a59cf2b967ffeafb092f8fc5ce6c -
Trigger Event:
workflow_dispatch
-
Statement type: