Skip to main content

An extensible Python toolkit for AI capabilities, starting with a structured OpenAI interface.

Project description

polimind

An extensible Python toolkit for AI capabilities. Its current public OpenAI interface lives under polimind.api.openai and preserves the existing chat, history, multimodal, and metrics workflow.

Features

  • Centralized Client: Use a single Client to manage your connection and spawn multiple chat sessions.
  • Variadic Chat Interface: Send multiple message components directly: chat.chat("Text", Image("local.png"), "More text").
  • Node-Based History: Every interaction is a node with an incremental ID.
  • Context Control: Activate or deactivate conversation nodes by their ID to manage the model's window.
  • Enhanced Metrics: Track token usage, models, and active nodes per request with built-in Pandas integration.
  • Multimodal Support: Handle local images (auto-base64 encoding) and remote URLs seamlessly.
  • State Persistence: Save Chat states and load them via the Client to resume sessions.
  • Deep Copy: Create independent clones of your chat session.

Installation

# Via Pip (once published)
pip install polimind

# From source
git clone https://github.com/artitzco/openai-api.git
cd openai-api
pip install .

Quick Start

from polimind.api.openai import Client, Image

# Initialize the main client
client = Client(api_key="your-api-key") # or use OPENAI_API_KEY env var

# Start a new chat session
chat = client.chat(model="gpt-4o-mini", system_prompt="You are a helpful assistant.")

# Basic Chat
response = chat.chat("Hello! What can you do?")
print(response)

# Multimodal Chat (Local and URL)
chat.chat(
    "Analyze these images:",
    Image("path/to/local_image.png"),
    "and also this one:",
    Image("https://example.com/image.jpg")
)

# Manage History
df_history = chat.history.to_dataframe()
chat.history.toggle(node_id=1, active=False) # Context management

# Persistence
chat.save("my_session.json")
new_chat_recovered = client.load_chat("my_session.json")

Project Structure

  • src/polimind/: Root package for the project.
  • src/polimind/api/openai/: OpenAI integration exposed by the package.
    • __init__.py: Contains the Client factory and exports.
    • core.py: Contains the Chat session manager.
    • history.py: Logic for node-based conversation management.
    • metrics.py: Token usage and request tracking.
    • content.py: Multimodal data builders (Images, etc.).
  • notebooks/: Interactive guides and testing playgrounds.
  • img/: Storage for sample assets.
  • output/: Default location for saved session JSONs.

License

MIT

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

polimind-0.1.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

polimind-0.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file polimind-0.1.0.tar.gz.

File metadata

  • Download URL: polimind-0.1.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for polimind-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7f54d7d9e5b26626584f9f07f946a5da1dde952ad8ff72da75a06da194fa2a12
MD5 0a90587364aba00eaacb4a67360749aa
BLAKE2b-256 dc0d26bf3a1b291631054a39d37244692ee79226441c714c380235898b4f214c

See more details on using hashes here.

File details

Details for the file polimind-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: polimind-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for polimind-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 04bfe438c91101079f47142f5f9af4964b8bb181645407d09acacf9137674b3d
MD5 289594d6d40b8c57040c96f4b5e0564f
BLAKE2b-256 7c52cce1a0cb9d800afbdc6f3a0e7043a94b87667cf4a6d5655ed7b33311cc0e

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