Skip to main content

A Python library for building AI systems that understand pets.

Project description

PawAgent

PawAgent is a Python framework for pet understanding from images and short videos.

It provides a reusable analysis stack for:

  • Emotion analysis
  • Behavior analysis
  • Motivation prediction
  • Expression rendering
  • Pet identity enrollment and verification

PawAgent is a library, not a web service. It is intended to sit underneath a separate runtime or application layer.

Status

  • Core media analysis: implemented
  • Image and short-video task views: implemented
  • Identity verification: implemented
  • Real local identity path (maskrcnn + openclip): implemented
  • Audio: internal extension path, not a primary user-facing workflow
  • Live streaming: out of scope for the current product surface

Why This Project

Most pet-AI demos collapse everything into one opaque caption. PawAgent instead separates:

  • direct observations
  • second-layer inference
  • human-readable rendering

That makes the results easier to cache, explain, reuse, and evaluate.

Core Model

One image or short video produces one unified analysis result:

{
  "emotion": {},
  "behavior": {},
  "motivation": {},
  "expression": {},
  "evidence": []
}

Task-specific agents then read from that shared result instead of re-calling the model.

Result layering:

  • First layer: emotion, behavior
  • Second layer: motivation
  • Expression layer: expression

Feature Matrix

Capability Image Short Video Notes
Emotion Yes Yes First-layer structured result
Behavior Yes Yes Video usually gives stronger behavior cues
Motivation Yes Yes Second-layer inference from emotion + behavior
Expression Yes Yes Stable rendering over structured analysis
Identity Yes No Separate verification pipeline
Audio Internal Internal Not a primary user-facing workflow

Quick Start

Install for development:

pip install -e .

Run the mock provider:

.venv/bin/python -m cli.main analyze-emotion dog.jpg --pet-id pet-1 --pet-name Milo
.venv/bin/python -m cli.main analyze-behavior clip.mp4 --pet-id pet-1 --pet-name Milo --modality video
.venv/bin/python -m cli.main express-pet dog.jpg --pet-id pet-1 --pet-name Milo --locale zh-CN

Install identity extras:

pip install -e ".[identity]"

Run real local identity verification:

.venv/bin/python -m cli.main enroll-identity tests/coconut.jpg --pet-id pet-1 --identity-cropper maskrcnn --identity-embedder openclip
.venv/bin/python -m cli.main verify-identity tests/coconut.jpg --pet-id pet-1 --identity-cropper maskrcnn --identity-embedder openclip

CLI Overview

Task-view commands:

pawagent analyze-emotion <source> --modality image|video
pawagent analyze-behavior <source> --modality image|video
pawagent analyze-motivation <source> --modality image|video
pawagent express-pet <source> --modality image|video

Identity commands:

pawagent enroll-identity <source> --pet-id <pet-id>
pawagent verify-identity <source> --pet-id <pet-id>

Example Commands

Image emotion:

.venv/bin/python -m cli.main analyze-emotion dog.jpg --pet-id pet-1 --pet-name Milo

Short-video behavior:

.venv/bin/python -m cli.main analyze-behavior clip.mp4 --pet-id pet-1 --pet-name Milo --modality video

Localized expression:

.venv/bin/python -m cli.main express-pet dog.jpg --pet-id pet-1 --pet-name Milo --locale zh-CN

HEIC input:

.venv/bin/python -m cli.main analyze-emotion tests/coconut.heic --pet-id pet-1 --pet-name Coconut

Image Formats

Supported image inputs include:

  • JPG
  • PNG
  • WEBP
  • HEIC
  • HEIF

HEIC/HEIF inputs are decoded locally before provider upload or identity fingerprinting.

On macOS, PawAgent can fall back to the system sips converter when pillow-heif is unavailable.

Providers

Built-in provider options:

  • mock
  • openai
  • gemini
  • gemini-cli
  • codex

OpenAI

export OPENAI_API_KEY=your_api_key
.venv/bin/python -m cli.main --provider openai --openai-model gpt-4.1-mini analyze-emotion dog.jpg --pet-id pet-1 --pet-name Milo

OpenAI Platform API integration uses API keys for server-side model calls.

Gemini

export GEMINI_API_KEY=your_api_key
.venv/bin/python -m cli.main --provider gemini --gemini-model gemini-2.5-flash analyze-emotion dog.jpg --pet-id pet-1 --pet-name Milo

Codex CLI

codex login
.venv/bin/python -m cli.main --provider codex --codex-model gpt-5.4 analyze-emotion dog.jpg --pet-id pet-1 --pet-name Milo

This provider shells out to the local codex CLI and reuses its existing login state.

Gemini CLI

gemini
.venv/bin/python -m cli.main --provider gemini-cli --gemini-model gemini-2.5-flash analyze-emotion dog.jpg --pet-id pet-1 --pet-name Milo

Identity

Identity is separate from emotion and behavior analysis. It uses its own profile store and should be treated as probabilistic verification, not biometric certainty.

Implementation paths:

  • Fallback path: noop cropper + hash embedder
  • Intended local path: maskrcnn cropper + openclip embedder

Identity enrollment is append-only. Repeated enroll-identity calls for the same pet-id add new reference views instead of overwriting the profile.

Real Local Identity Notes

  • the first openclip run may download files into .pawagent/hf-cache and .pawagent/torch-cache
  • a Hugging Face unauthenticated-request warning during first download is expected
  • HF_TOKEN is optional for public models and only improves download rate limits
  • verification compares against all enrolled references for the target pet-id

Architecture

Task Views
  -> Unified Analysis
  -> Capability Layer (vision / video)
  -> Provider Layer

Supporting layers:
  - Memory / cache
  - Identity
  - Shared models

Key design rules:

  • one source item should map to one unified analysis result
  • repeated task-view requests should reuse cached analysis
  • localized expression may use a lightweight second pass and is cached separately
  • identity should never reuse emotion/behavior memory as its source of truth

Repository Layout

pawagent/
├── cli/
├── docs/
├── examples/
├── pawagent/
│   ├── agents/
│   ├── core/
│   ├── expression/
│   ├── identity/
│   ├── memory/
│   ├── models/
│   ├── personality/
│   ├── providers/
│   ├── video/
│   └── vision/
├── tests/
└── pyproject.toml

Library Example

from pathlib import Path

from pawagent.agents.mood_agent import PetEmotionAgent
from pawagent.memory.store import InMemoryAnalysisStore
from pawagent.personality.profiler import PersonalityProfiler
from pawagent.providers.mock_provider import MockProvider

memory = InMemoryAnalysisStore()
agent = PetEmotionAgent(
    provider=MockProvider(),
    memory_store=memory,
    profiler=PersonalityProfiler(memory),
)

result = agent.analyze_image(
    image_path=Path("dog.jpg"),
    pet_id="pet-1",
    pet_name="Milo",
    species="unknown",
)

print(result.mood.primary)

Documentation

Contributing

Useful contribution areas:

  • vision and video analysis
  • behavior and motivation quality
  • identity verification quality
  • provider integrations
  • documentation and benchmarks

License

MIT License. See 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

pawagent-0.1.1.tar.gz (46.5 kB view details)

Uploaded Source

Built Distribution

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

pawagent-0.1.1-py3-none-any.whl (53.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pawagent-0.1.1.tar.gz
  • Upload date:
  • Size: 46.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pawagent-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8dce3f5c96b6fa88fe00fac495e320d967c282d295238031aaa21b4957efdcd3
MD5 79f0e6b759a80902469d1f01f5109e7e
BLAKE2b-256 45864004252d1b87c15849aff38358665e83a4eb676671cd30eb16a20e408958

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pawagent-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 53.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pawagent-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a6e9723a7fe7ce13a2fa7697bba9e778d9c7757c7f2bbb707165bf795cd9c779
MD5 47889140d65adb984c1e4534d408f539
BLAKE2b-256 3b47b2a4f85dc7a140561ba33b4b51870a78a1bdee6da38f8d50b14f4d41c5b3

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