ThinAgents
A lightweight, pluggable AI Agent framework for Python.
Build LLM-powered agents that can use tools, remember conversations, and connect to external resources with minimal code. ThinAgents leverages litellm under the hood for its language model interactions.
Installation
pip install thinagents
Basic Usage
Create an agent and interact with an LLM in just a few lines:
from thinagents import Agent
agent = Agent(
name="Greeting Agent",
model="openai/gpt-4o-mini",
)
response = await agent.arun("Hello, how are you?")
print(response.content)
Tools
Agents can use Python functions as tools to perform actions or fetch data.
from thinagents import Agent
def get_weather(city: str) -> str:
return f"The weather in {city} is sunny."
agent = Agent(
name="Weather Agent",
model="openai/gpt-4o-mini",
tools=[get_weather],
)
response = await agent.arun("What is the weather in Tokyo?")
print(response.content)
Tools with Decorator
For richer metadata and parameter validation, use the @tool decorator:
from thinagents import Agent, tool
@tool(name="get_weather")
def get_weather(city: str) -> str:
"""Get the weather for a city."""
return f"The weather in {city} is sunny."
agent = Agent(
name="Weather Pro",
model="openai/gpt-4o-mini",
tools=[get_weather],
)
You can also use Pydantic models for parameter schemas:
from pydantic import BaseModel, Field
from thinagents import tool
class MultiplyInputSchema(BaseModel):
a: int = Field(description="First operand")
b: int = Field(description="Second operand")
@tool(name="multiply_tool", pydantic_schema=MultiplyInputSchema)
def multiply(a: int, b: int) -> int:
return a * b
Returning Content and Artifact
Sometimes, a tool should return both a summary (for the LLM) and a large artifact (for downstream use):
from thinagents import tool
@tool(return_type="content_and_artifact")
def summarize_and_return_data(query: str) -> tuple[str, dict]:
data = {"rows": list(range(10000))}
summary = f"Found {len(data['rows'])} rows for query: {query}"
return summary, data
response = await agent.arun("Summarize the data for X")
print(response.content) # Sent to LLM
print(response.artifact) # Available for downstream use
Async Usage
ThinAgents is async by design. You can stream responses or await the full result:
# Streaming
async for chunk in agent.astream("List files and get weather", conversation_id="1"):
print(chunk.content, end="", flush=True)
# Or get the full response at once (non-streaming)
response = await agent.arun("List files and get weather", conversation_id="1")
print(response.content)
Memory
Agents can remember previous messages and tool results by attaching a memory backend.
from thinagents.memory import InMemoryStore
agent = Agent(
name="Memory Demo",
model="openai/gpt-4o-mini",
memory=InMemoryStore(), # Fast, in-memory storage
)
conv_id = "demo-1"
print(await agent.arun("Hi, I'm Alice!", conversation_id=conv_id))
print(await agent.arun("What is my name?", conversation_id=conv_id))
# → "Your name is Alice."
Persistent Memory
from thinagents.memory import FileMemory, SQLiteMemory
file_agent = Agent(
name="File Mem Agent",
model="openai/gpt-4o-mini",
memory=FileMemory(storage_dir="./agent_mem"),
)
db_agent = Agent(
name="SQLite Mem Agent",
model="openai/gpt-4o-mini",
memory=SQLiteMemory(db_path="./agent_mem.db"),
)
Storing Tool Artifacts
Enable artifact storage in memory:
agent = Agent(
...,
memory=InMemoryStore(store_tool_artifacts=True),
)
Model Context Protocol (MCP) Integration
Connect your agent to external resources (files, APIs, etc.) using MCP.
agent = Agent(
name="MCP Agent",
model="openai/gpt-4o-mini",
mcp_servers=[
{
"transport": "sse",
"url": "http://localhost:8100/sse"
},
{
"transport": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/path/to/dir"
]
},
],
)
Web UI
Launch a beautiful web interface for your agents with a single line:
from thinagents import Agent
from thinagents.web import WebUI
agent = Agent(
name="My Agent",
model="openai/gpt-4o-mini",
)
WebUI(agent).run() # Opens browser automatically
The WebUI provides:
- 🎨 Beautiful, modern chat interface
- 🚀 Real-time streaming responses
- 💬 Full conversation history
- 🛠️ Works with any agent configuration
- 📱 Mobile-friendly responsive design
See Web UI Documentation for more details.
License
MIT
Release files for ThinAgents-Web 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| thinagents_web-0.0.1.tar.gz | 141.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| thinagents_web-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 332.6 kB
Release files / thinagents_web-0.0.1.tar.gz
| Download URL | thinagents_web-0.0.1.tar.gz |
|---|---|
| Size | 141.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96a57469aceb1e0ed91a467678e4534b35c335fe12c280c7fc0d9ad26fd07274
|
|
BLAKE2b-256 checksum How to use checksums |
63e6dc1e9f2f3b2956d53e84ca7bdfd7435eed677317cafe01524b647c9bf1e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2025.
Transparency logRelease files / thinagents_web-0.0.1-py3-none-any.whl
| Download URL | thinagents_web-0.0.1-py3-none-any.whl |
|---|---|
| Size | 191.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0268da9f6b8a2bb79c916e7df6a55bd106d468d39e34f5df9d46b1fe801cdd44
|
|
BLAKE2b-256 checksum How to use checksums |
35fcf18965c56efc4f7f35f5c4fa502bce8c22276000335dc400df1a002f325e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2025.
Transparency log