Skip to main content

Universal AI interaction library with session and tool support

Project description

Interactor

A modular AI interaction framework with streaming, tool calling, context history, session management, retry/backoff logic, multi-provider support, and optional real-time logging.

Built for testability, extensibility, and CLI or programmatic use.

Features

  • Supports OpenAI, Ollama, NVIDIA, Google (Gemini) out-of-the-box
  • Streamed output with markdown rendering
  • Tool calling with auto-registration from Python functions
  • Token-aware message cycling (to respect context limits)
  • Persistent sessions with metadata and CRUD via session.py
  • Optional per-instance logging of all interactions
  • Retry logic for rate-limiting and transient failures
  • CLI runner with interactive loop and safe shell command execution

Installation

To install directly from GitHub:

pip install git+https://github.com/woodyk/interactor.git#egg=interactor

Or clone locally and install for development:

git clone https://github.com/woodyk/interactor.git
cd interactor
pip install -e .

Requirements

Defined in requirements.txt:

  • openai
  • aiohttp
  • tiktoken
  • rich

Usage (CLI)

After installing:

interactor

Command-line options:

  • --model: Model in format provider:model (e.g., openai:gpt-4o)
  • --api-key: Optional override (default uses env var)
  • --base-url: Optional custom API base
  • --tools: Enable tool calling
  • --stream: Stream assistant replies
  • --markdown: Render streamed output as markdown

Use /exit or /quit to end the session.

Usage (Python)

from interactor import Interactor, Session

inter = Interactor(
    model="openai:gpt-4o",
    session_enabled=True,
    session_path="~/.interactor_sessions",
    log_path="~/interactor.log"
)

def say_hello(name: str) -> str:
    return f"Hello, {name}!"

inter.add_function(say_hello)

reply = inter.interact("Please greet Ada.")
print(reply)

Session Support

Sessions are JSON files stored on disk.

You can:

  • List and load sessions
  • Create branches from message midpoints
  • Search and update content
  • Automatically summarize a session with interactor.summarize()

Logging

To enable logging:

inter = Interactor(..., log_path="~/my_session.log")

Logs include:

  • User and assistant messages
  • Tool call arguments and results
  • Model switches, session transitions
  • Retry events and exceptions

License

Copyright (c) Wadih Khairallah. All rights reserved.

Licensed for use and modification under the 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

ai_interactor-0.1.1.tar.gz (158.5 kB view details)

Uploaded Source

Built Distribution

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

ai_interactor-0.1.1-py3-none-any.whl (31.7 kB view details)

Uploaded Python 3

File details

Details for the file ai_interactor-0.1.1.tar.gz.

File metadata

  • Download URL: ai_interactor-0.1.1.tar.gz
  • Upload date:
  • Size: 158.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for ai_interactor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 766e54d3ce52d11db48977e92fc62fc67902dcfbe0a0bb41d39a39bed7da4402
MD5 5b9929ae2397b1e81593c1b619eb7476
BLAKE2b-256 62a14b9a2c81b66fad06668cb49fbfde122e6ddcd51b4b72aa90bf256b5fccaf

See more details on using hashes here.

File details

Details for the file ai_interactor-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ai_interactor-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 31.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for ai_interactor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d4d7e4e405052ad9549b13013e9617f3bb050f53ebea4808b9743f774033d03
MD5 50a4653bc3c41b51ed35da5ef405eed5
BLAKE2b-256 63d3c504cd97a997f201beb808e05f4456c964336dd420b59f7bc651d524711f

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