Skip to main content

A lightweight Python client for Ollama with context management and streaming support.

Project description

🐪 Camel-py

A lightweight Python client for Ollama with built-in agentic capabilities and tool calling support.


🚀 Installation

pip install camel-py

⚡ Quickstart

Basic Chat

from camel import CamelClient

with CamelClient(model="llama3") as client:
    resp = client.chat("Hello, who are you?")
    print(resp.text)
    
    # Streaming
    print("Assistant: ", end="")
    client.stream("Tell me a joke about camels")

AI Agent with Tool Calling

from camel import CamelClient, Agent, Tool

def get_weather(location: str) -> str:
    return f"Weather in {location}: 72°F, sunny"

weather_tool = Tool(
    name="get_weather",
    description="Gets current weather for any location",
    schema={
        "type": "object",
        "properties": {
            "location": {"type": "string", "description": "City name"}
        },
        "required": ["location"]
    },
    function=get_weather
)

client = CamelClient(model="llama3")
agent = Agent(client, tools=[weather_tool])

result = agent.run("What's the weather in Paris?")
print(result)

🔧 Features

  • AI Agents: Built-in tool calling via FunctionGemma (auto-installed)
  • Dual-model architecture: Specialized tool detection + your choice for responses
  • Streaming: Real-time token streaming
  • Context management: Save/load/clear conversation history
  • Model management: List, pull, delete Ollama models
  • Embeddings: Generate text embeddings

📂 Examples

🛠️ How It Works

The Agent uses a two-model approach:

  1. FunctionGemma detects when tools are needed
  2. Your chosen model generates natural responses

This provides reliable tool calling while maintaining conversation quality.

📦 Requirements

  • Python ≥3.12
  • Ollama running locally

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

camel_py-0.2.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

camel_py-0.2.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file camel_py-0.2.0.tar.gz.

File metadata

  • Download URL: camel_py-0.2.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for camel_py-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9193aaba02f0b1c184a218f6b2550555e9667c8cb21be55a0313d350477074f6
MD5 f7270a1a331cf2a4515ab8d5465d1b0f
BLAKE2b-256 a166f4e165bf11332d871de00dc7881c0f94dfefaa5130a2d391519aa77c2c1e

See more details on using hashes here.

File details

Details for the file camel_py-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: camel_py-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for camel_py-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb30ddf2071948090e4fa46aa2d10e27e7aa049f0779c85f722320ec9edc5012
MD5 68482086826fdae2566b42cd0d584bcb
BLAKE2b-256 f6bcfbea970d59f53d9b30065caa16cd2b308d5f9ee591c0a32bd19445be79d8

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