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.7.tar.gz (27.2 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.7-py3-none-any.whl (31.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: multimodal_agent-0.2.7.tar.gz
  • Upload date:
  • Size: 27.2 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.7.tar.gz
Algorithm Hash digest
SHA256 8edd8864d0fecca2f86eed5f0670511fd802711f8f3e289f572fdf18f3f7b6c4
MD5 e71cf86fa42edf60874a29f8378a5786
BLAKE2b-256 88bf3cd04d2ee7f60f205279da9ee0a826710297d071dada1b70e2dfe926d0ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for multimodal_agent-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4e4bcd06fe4c4a21577bac1d6764b3d82c89f90afcbd117b3a479f0f2dc915cb
MD5 d0f6ab10cd4f203a5622e72aeffc155b
BLAKE2b-256 71df67d4b175df75add3b0a101194edfbaae0fa2d3ef731fa91253f442ab4bce

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