Skip to main content

Official Python SDK for Plimver AI Platform - Unified LLM, RAG, and Memory API

Project description

Plimver Python SDK

Official Python SDK for the Plimver AI Platform - Unified LLM, RAG, and Memory API.

Installation

pip install plimver

Quick Start

from plimver import Plimver

client = Plimver(
    api_key="pk_live_your_api_key",
    workspace_id="ws_your_workspace_id"
)

response = client.chat("What is machine learning?")
print(response.text)

Features

  • Type hints - Full type annotations with dataclasses
  • Sync & Async - Both synchronous and async clients
  • Streaming - Generator-based streaming responses
  • Multimodal - Images, audio, and video support
  • RAG - Document upload and vector search
  • Memory - Conversation history management
  • Retries - Built-in retry with exponential backoff
  • 22+ LLM Providers - OpenAI, Anthropic, Google, Groq, and more

Usage Examples

Basic Chat

# Simple message
response = client.chat("Hello!")
print(response.text)

# With options
response = client.chat(
    "Explain quantum computing",
    mode="chat_and_rag",  # Use RAG for context
    model="gpt-4o",       # Specific model
    temperature=0.5,
    user_id="user-123"    # Isolate conversation
)

Conversation History

from plimver import Message

response = client.chat_with_messages([
    Message(role="user", content="My name is Alice"),
    Message(role="assistant", content="Nice to meet you, Alice!"),
    Message(role="user", content="What is my name?"),
])

print(response.text)  # "Your name is Alice"

Streaming

# Stream response token by token
for chunk in client.stream("Tell me a story"):
    print(chunk.content or "", end="", flush=True)

# With options
for chunk in client.stream("Write a poem", mode="chat_only"):
    if chunk.done:
        print(f"\n\nDone!")
    else:
        print(chunk.content or "", end="", flush=True)

Async Client

from plimver import AsyncPlimver
import asyncio

async def main():
    async with AsyncPlimver(
        api_key="pk_live_...",
        workspace_id="ws_..."
    ) as client:
        response = await client.chat("Hello!")
        print(response.text)
        
        # Async streaming
        async for chunk in client.stream("Tell me a joke"):
            print(chunk.content or "", end="", flush=True)

asyncio.run(main())

Vision (Images)

# Analyze an image
response = client.vision(
    "What do you see in this image?",
    "https://example.com/photo.jpg"
)

# With base64
response = client.vision(
    "Describe this diagram",
    "data:image/png;base64,iVBORw0KGgo..."
)

Audio

# Transcribe or analyze audio (requires Gemini 1.5 Pro+)
response = client.audio(
    "Transcribe this audio and summarize it",
    "https://example.com/audio.mp3",
    model="gemini-1.5-pro"
)

Video

# Analyze video (requires Gemini 1.5 Pro+)
response = client.video(
    "What happens in this video?",
    "https://example.com/video.mp4",
    model="gemini-1.5-pro"
)

RAG Documents

# Upload a document
doc = client.documents.upload(
    "Plimver is an AI platform that provides unified LLM access...",
    source="about-plimver.txt"
)

# Upload a file
doc = client.documents.upload_file("document.pdf")

# List documents
docs = client.documents.list()
print(f"{len(docs)} documents indexed")

# Search documents
results = client.documents.search("what is plimver", limit=5)
for r in results:
    print(f"{r.source}: {r.score:.2f}")

# Delete a document
client.documents.delete("about-plimver.txt")

Memory Management

# Get conversation history for a user
messages = client.memory.get("user-123", limit=50)

# Clear user's history
client.memory.clear("user-123")

# Clear all history (danger!)
client.memory.clear_all()

Routing Modes

# Auto (smart routing based on query)
client.chat("Hello", mode="auto")

# Chat only (no RAG, no memory)
client.chat("Hello", mode="chat_only")

# RAG only (search documents, no memory)
client.chat("What is in my docs?", mode="rag_only")

# Chat + RAG (full context)
client.chat("Summarize my documents", mode="chat_and_rag")

Error Handling

from plimver import Plimver, PlimverError

try:
    response = client.chat("Hello")
except PlimverError as e:
    print(f"API Error {e.status}: {e.message}")

Context Manager

# Automatically closes connection
with Plimver(api_key="...", workspace_id="...") as client:
    response = client.chat("Hello!")
    print(response.text)

Configuration

client = Plimver(
    # Required
    api_key="pk_live_...",
    workspace_id="ws_...",
    
    # Optional
    base_url="https://api.plimvr.tech",  # Custom API URL
    timeout=30.0,                         # Request timeout (seconds)
    max_retries=2,                        # Retry on failure
)

Response Objects

ChatResponse

@dataclass
class ChatResponse:
    text: str           # AI response
    model: str          # Model used
    provider: str       # Provider used
    mode: str           # Routing mode
    usage: Usage        # Token usage
    sources: List[Source]  # RAG sources
    metadata: dict      # Extra metadata

Usage

@dataclass
class Usage:
    prompt_tokens: int
    completion_tokens: int
    total_tokens: int

Supported Models

Provider Models
OpenAI gpt-4o, gpt-4o-mini, gpt-4-turbo
Anthropic claude-3-5-sonnet, claude-3-opus
Google gemini-2.0-flash, gemini-1.5-pro
Groq llama-3.1-70b, mixtral-8x7b
DeepSeek deepseek-chat, deepseek-coder
xAI grok-beta
+ 15 more...

License

MIT © Plimver Team

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

plimver-1.0.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

plimver-1.0.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file plimver-1.0.0.tar.gz.

File metadata

  • Download URL: plimver-1.0.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for plimver-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ed8734b5bdd68d9822216946d7aa4d4b1afc7256f76e7ededb9e782937d4d821
MD5 28fd4ea1cadb8365137b4e285b73a54b
BLAKE2b-256 7191813b29445071ee7391a39d032264bbe4a15927371c721f75f9fd8de28091

See more details on using hashes here.

File details

Details for the file plimver-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: plimver-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for plimver-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a3293a2c245bbf54114e30495b214e1bcf5d6e87284a000a2fa023b4a7b14a0
MD5 51880aa01ca58973181d4d9f7bb127db
BLAKE2b-256 90c22ce1477faf7f3f8d4f46ccae85168988dbecc42ef05768f4497a4b14f14c

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