Skip to main content

Python client for WeyCP API - Advanced AI chat completions service

Project description

WeyCP Python Client

PyPI version Python 3.8+ License: MIT

The official Python client for WeyCP API chat completions created by Weycop.


🚀 Features

  • Familiar API Interface – Easy-to-use chat completions API.
  • Sync & Async support – Use synchronous or asynchronous clients.
  • Built-in error handling – Comprehensive exception handling.
  • Usage tracking – Monitor token usage and costs.
  • Type hints – Full type annotation support.
  • High performance – Optimized for concurrent requests.

📦 Installation

pip install weycop

⚡ Quick Start

Synchronous Client

from weycop import WeycopClient

# Initialize client
client = WeycopClient(api_key="your-api-key")

# Simple chat
response = client.chat(
    message="Hello, how are you?",
    model="llama3.2:3b",
    system_prompt="You are a helpful assistant"
)
print(response)

Asynchronous Client

import asyncio
from weycop import AsyncWeycopClient

async def main():
    async with AsyncWeycopClient(api_key="your-api-key") as client:
        response = await client.chat(
            message="What is machine learning?",
            model="llama3.1:8b-8k"
        )
        print(response)

asyncio.run(main())

🧠 Supported Models

  • llama3.2:3b – Fast, lightweight model (~4 GB VRAM).
  • llama3.1:8b-8k – Advanced model with 8K context (~8.9 GB VRAM).

🛡️ Error Handling

from weycop import WeycopClient, AuthenticationError, RateLimitError, APIError

client = WeycopClient(api_key="your-key")

try:
    response = client.chat("Hello", model="llama3.2:3b")
    print(response)
except AuthenticationError:
    print("Invalid API key")
except RateLimitError:
    print("Rate limit exceeded")
except APIError as e:
    print(f"API error: {e}")

🔄 Examples

System Prompts

from weycop import Message

completion = client.chat_completions_create(
    model="llama3.1:8b",
    messages=[
        Message("system", "You are a SQL expert. Only respond with SQL code."),
        Message("user", "Get all users created in the last 30 days")
    ]
)

Multi-turn Conversation

messages = [
    Message("system", "You are a helpful math tutor."),
    Message("user", "What is 15 + 27?"),
]

completion = client.chat_completions_create(model="llama3.2:3b", messages=messages)
assistant_response = completion.choices[0].message.content
messages.append(Message("assistant", assistant_response))

messages.append(Message("user", "Now multiply that by 3"))
completion = client.chat_completions_create(model="llama3.2:3b", messages=messages)
print(completion.choices[0].message.content)

Context Management

with WeycopClient(api_key="your-key") as client:
    response = client.chat("Hello!")
    print(response)
# Client is automatically closed


Support


📜 License

MIT License - see LICENSE file for details.

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

weycop-1.0.3.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

weycop-1.0.3-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file weycop-1.0.3.tar.gz.

File metadata

  • Download URL: weycop-1.0.3.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for weycop-1.0.3.tar.gz
Algorithm Hash digest
SHA256 1ce5975d34accbced76a9d77b3a923b65bac667a91794cf822ebbd03f67479d7
MD5 8e13eca5b02c9ecf16cdb03c3a702734
BLAKE2b-256 e20beb6d149b76ce4eebbf76bf0170b678ac9259e0f911b8927255e9852c16b1

See more details on using hashes here.

File details

Details for the file weycop-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: weycop-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for weycop-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d0844eb32d0cd9a4fe9993969a46218c4cd62ccf132476986f2d4b7d9006c80e
MD5 9aa9b30638d8df0928e4e747bffd2222
BLAKE2b-256 eb7e04aed0996cc164e33af4c97f363561949f558c4a86410509b00b3145d284

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