Skip to main content

The highest-level interface for various LLM APIs.

Project description

Chatterer

Simplified, Structured AI Assistant Framework

chatterer is a Python library designed as a type-safe LangChain wrapper for interacting with various language models (OpenAI, Anthropic, Gemini, Ollama, etc.). It supports structured outputs via Pydantic models, plain text responses, and asynchronous calls.

The structured reasoning in chatterer is inspired by the Atom-of-Thought pipeline.


Quick Install

pip install chatterer

Quickstart Example

Generate text quickly using OpenAI:

from chatterer import Chatterer

chat = Chatterer.openai("gpt-4o-mini")
response = chat.generate("What is the meaning of life?")
print(response)

Messages can be input as plain strings or structured lists:

response = chat.generate([{ "role": "user", "content": "What's 2+2?" }])
print(response)

Structured Output with Pydantic

from pydantic import BaseModel

class AnswerModel(BaseModel):
    question: str
    answer: str

response = chat.generate_pydantic(AnswerModel, "What's the capital of France?")
print(response.question, response.answer)

Async Example

import asyncio

async def main():
    response = await chat.agenerate("Explain async in Python briefly.")
    print(response)

asyncio.run(main())

Atom-of-Thought Pipeline (AoT)

AoTPipeline provides structured reasoning by:

  • Detecting question domains (general, math, coding, philosophy, multihop).
  • Decomposing questions recursively.
  • Generating direct, decomposition-based, and simplified answers.
  • Combining answers via ensemble.

AoT Usage Example

from chatterer import Chatterer
from chatterer.strategies import AoTStrategy, AoTPipeline

pipeline = AoTPipeline(chatterer=Chatterer.openai(), max_depth=2)
strategy = AoTStrategy(pipeline=pipeline)

question = "What would Newton discover if hit by an apple falling from 100 meters?"
answer = strategy.invoke(question)
print(answer)

Supported Models

  • OpenAI
  • Anthropic
  • Google Gemini
  • Ollama (local models)

Initialize models easily:

openai_chat = Chatterer.openai("gpt-4o-mini")
anthropic_chat = Chatterer.anthropic("claude-3-7-sonnet-20250219")
gemini_chat = Chatterer.google("gemini-2.0-flash")
ollama_chat = Chatterer.ollama("deepseek-r1:1.5b")

Advanced Features

  • Streaming responses
  • Async/Await support
  • Structured outputs with Pydantic models

Logging

Built-in logging for easy debugging:

import logging
logging.basicConfig(level=logging.DEBUG)

Contributing

Feel free to open an issue or pull request.


License

MIT License

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

chatterer-0.1.6.tar.gz (31.3 kB view details)

Uploaded Source

Built Distribution

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

chatterer-0.1.6-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

Details for the file chatterer-0.1.6.tar.gz.

File metadata

  • Download URL: chatterer-0.1.6.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.2

File hashes

Hashes for chatterer-0.1.6.tar.gz
Algorithm Hash digest
SHA256 758ecf765b186af9052c7c7ebeec79a4a9e18a8c3551f5cc8aa42a7e5c43d8ce
MD5 38460e12f6b0b8da0b1cf6850f0ba3ac
BLAKE2b-256 3ea57c69228c8f7fdb90e7e2d1cfa676597ee7db740af1c8ed2fb6a7f77cca30

See more details on using hashes here.

File details

Details for the file chatterer-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: chatterer-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 32.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.2

File hashes

Hashes for chatterer-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7f78f8da6f36f8471ff86b4d32c7d70d9cca0fcfd4a93a08a9435aa503f91629
MD5 3d2164145733f45d3a95880b626a01d9
BLAKE2b-256 c6c58b107511fbeabe7354e032e9af97d97a73e4f1899db916159a1621fe4761

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