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), Anthropic 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:
openaiaiohttptiktokenrich
Usage (CLI)
After installing:
interactor
Command-line options:
--model: Model in formatprovider: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
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 ai_interactor-0.1.2.1.tar.gz.
File metadata
- Download URL: ai_interactor-0.1.2.1.tar.gz
- Upload date:
- Size: 185.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c48e7351f5f815d589709f62281ee39125fa50e9f56e1c95e5ae55a6b6158b1
|
|
| MD5 |
f03c1b2352e24fc84d7b5b0377ce4512
|
|
| BLAKE2b-256 |
2f41dbac527b0d7e4fbaddd2307883fa24f68f9d0fed21052745b6a7e9dac6ed
|
File details
Details for the file ai_interactor-0.1.2.1-py3-none-any.whl.
File metadata
- Download URL: ai_interactor-0.1.2.1-py3-none-any.whl
- Upload date:
- Size: 35.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52caa608bd4004c0b56f5be5b6fc5ebbf66ef867b6fb6e8c3ae3bca04f13fed5
|
|
| MD5 |
a58f870974098e95a676555985dfe8a6
|
|
| BLAKE2b-256 |
679645888e5d58390561196ba0b3a54098a0b18b3bb292b704beacd54271d499
|