Skip to main content

A Python multimodal agent for interacting with Gemini models via text, images, and CLI.

Project description

Multimodal-Agent

A lightweight, production-ready multimodal wrapper for Google Gemini โ€” with RAG memory, session-based chat, embeddings, retry logic, and a clean CLI.


Features (v0.2.7)

Core

  • ๐Ÿ”น RAG Memory (SQLite vector store, embedding retrieval)

  • ๐Ÿ”น Session-based chat (agent chat --session <id>)

  • ๐Ÿ”น Cross-session RAG retrieval

  • ๐Ÿ”น History management CLI

    (show / delete / clear / summary)

  • ๐Ÿ”น Text + Image multimodal generation

Engine

  • ๐Ÿ”น Token-safe chunking (sentence-aware, fallback for long text)
  • ๐Ÿ”น Exponential backoff retry logic
  • ๐Ÿ”น Custom exception hierarchy
  • ๐Ÿ”น Production logging
  • ๐Ÿ”น Extensible & test-covered architecture

Tooling

  • ๐Ÿ”น Minimal CLI: agent
  • ๐Ÿ”น 94% unit test coverage

Installation

From PyPI (recommended)

pip install multimodal-agent

From source

git clone https://github.com/yourname/multimodal-agent.git cd multimodal-agent pip install -e .

Requirements

  • Python 3.9+
  • GOOGLE_API_KEY set in .env file:
GOOGLE_API_KEY=your_key_here

Dependencies (google-genai, google-adk) are installed automatically.


CLI Usage

Ask a question

agent ask "Explain quantum tunneling"

Ask about an image

agent image cat.jpg "Describe this"

Interactive chat (stateful)

agent chat

Chat with a custom session

agent chat --session project-x

Each session stores its own memory and embeddings.


RAG Memory (0.2.6+)

Multimodal-Agent now includes a Retrieval-Augmented Generation (RAG) engine powered by an internal SQLite vector store.

What RAG does:

  • Stores all user and assistant messages in a database
  • Splits large messages into normalized chunks before embedding (0.2.7+)
  • Generates embeddings for each chunk
  • Retrieves the most relevant past chunks during answers
  • Uses both current session and cross-session memory
  • Improves contextual accuracy

Disable RAG:

agent chat --no-rag agent ask "hello" --no-rag

Chunk Tokenization (0.2.7+)

Multimodal-Agent now includes a robust token-safe chunking engine to improve embedding quality and RAG retrieval.

What this adds:

  • Sentence-aware splitting (split_into_chunks)
  • Paragraph + sentence windowing (chunk_text)
  • Safe handling of long unbroken strings
  • Ensures embeddings stay within expected token limits
  • More consistent similarity search results

Tokenization happens automatically whenever text is added to the RAG store.


History Commands (RAG-backed)

Show recent stored chunks

agent history show --limit 20

Show history for a specific session

agent history show--session project-x

Delete a specific chunk

agent history delete12

Clear the entire database

agent historyclear

Summarize all history using the LLM

agent history summary

Python API

Text

from multimodal_agent import MultiModalAgent agent = MultiModalAgent() print(agent.ask("What is recursion?"))

Image + text

from multimodal_agent import MultiModalAgent from multimodal_agent.utils import load_image_as_part agent = MultiModalAgent() img = load_image_as_part("car.jpg") response = agent.ask_with_image("What model is this?", img) print(response)

Chunking Utilities (0.2.7+)

from multimodal_agent.tokenizer import split_into_chunks from multimodal_agent.chunking import chunk_text print(split_into_chunks("very long text...", max_tokens=200)) print(chunk_text("paragraphs and sentences...", max_chars=800))

Project Structure

multimodal-agent/ โ”‚ โ”œโ”€โ”€ src/multimodal_agent/ โ”‚ โ”œโ”€โ”€ agent_core.py # Core agent logic (RAG, chat, ask) โ”‚ โ”œโ”€โ”€ rag_store.py # SQLite vector store (chunks + embeddings) โ”‚ โ”œโ”€โ”€ embedding.py # Embedding client wrapper โ”‚ โ”œโ”€โ”€ tokenizer.py # Token-safe chunk splitting (v0.2.7) โ”‚ โ”œโ”€โ”€ chunking.py # Paragraph/sentence chunking (v0.2.7) โ”‚ โ”œโ”€โ”€ cli.py # CLI entrypoint โ”‚ โ”œโ”€โ”€ utils.py # Helpers (images, history) โ”‚ โ”œโ”€โ”€ logger.py # Logging setup โ”‚ โ”œโ”€โ”€ errors.py # Custom exceptions โ”‚ โ””โ”€โ”€ VERSION โ”‚ โ”œโ”€โ”€ tests/ # 90%+ coverage โ””โ”€โ”€ README.md

Tests

pytest --cov

Coverage is enforced in CI.


Roadmap

  • RAG Memory (0.2.6)
  • Token-safe chunking (0.2.7)
  • Token usage logging
  • Async agent (AsyncMultiModalAgent)
  • Plugin system (tools, external modules)
  • Flutter extension (planned)
  • IDE extensions (later)
  • Streaming support

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

multimodal_agent-0.2.8.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

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

multimodal_agent-0.2.8-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file multimodal_agent-0.2.8.tar.gz.

File metadata

  • Download URL: multimodal_agent-0.2.8.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for multimodal_agent-0.2.8.tar.gz
Algorithm Hash digest
SHA256 a2b59c63aa2fd1fa6091dac66cc6804fef34fea9f3aafc59f5b29c9c4469de48
MD5 061b92c7dd6e050f9a74824bcaec92a3
BLAKE2b-256 917156a49a9bf3269ea5596b89a955241b8bc33e4be4b73deb85c2207b99076f

See more details on using hashes here.

File details

Details for the file multimodal_agent-0.2.8-py3-none-any.whl.

File metadata

File hashes

Hashes for multimodal_agent-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 44c731f6f47af65fd1ea5e948c1ecc7b92833112c9326284e5c00fee3118a58e
MD5 7236e347d4c1090bc7270fde4cc517ea
BLAKE2b-256 172bad9ccbe1d7725c537bd05591162055e67c3c296ab5654d61b59f57ea51ea

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