Skip to main content

Official Python SDK for SVECTOR AI Models - Advanced conversational AI and language models

Project description

SVECTOR Python SDK

PyPI version Python Support License: MIT

The official Python SDK for SVECTOR AI Models. Build powerful AI applications with advanced conversational AI and language models.

🚀 Installation

pip install svector

🎯 Quick Start

Basic Usage

from svector import SVECTOR

# Initialize the client
client = SVECTOR(api_key="your-api-key-here")

# Simple chat completion
response = client.chat.create(
    model="spec-3-turbo:latest",
    messages=[
        {"role": "user", "content": "What is artificial intelligence?"}
    ]
)

print(response["choices"][0]["message"]["content"])

Streaming Responses

# Stream responses in real-time
stream = client.chat.create(
    model="spec-3-turbo:latest",
    messages=[
        {"role": "user", "content": "Write a poem about technology"}
    ],
    stream=True
)

for event in stream:
    if event.get("choices") and event["choices"][0].get("delta", {}).get("content"):
        print(event["choices"][0]["delta"]["content"], end="", flush=True)

File Upload and RAG

# Upload a file for RAG
file_response = client.files.create("document.pdf", purpose="rag")
file_id = file_response["file_id"]

# Ask questions about the uploaded file
response = client.chat.create(
    model="spec-3-turbo:latest",
    messages=[
        {"role": "user", "content": "Summarize this document"}
    ],
    files=[{"type": "file", "id": file_id}]
)

print(response["choices"][0]["message"]["content"])

🖥️ Command Line Interface

SVECTOR also provides a powerful CLI:

# Set up your API key
svector config set-key your-api-key-here

# Start chatting
svector chat "Hello, SVECTOR!"

# Stream responses
svector stream "Write a poem about AI"

# List available models
svector models

# Upload files for RAG
svector file upload document.pdf

# Ask questions about files
svector ask "Summarize this document" --file file-123

📚 API Reference

SVECTOR Client

client = SVECTOR(
    api_key="your-api-key",           # Required: Your SVECTOR API key
    base_url="https://spec-chat.tech",  # Optional: Custom API base URL
    timeout=30,                       # Optional: Request timeout in seconds
    max_retries=3                     # Optional: Max retry attempts
)

Chat Completions

response = client.chat.create(
    model="spec-3-turbo:latest",      # Required: Model name
    messages=[                        # Required: List of messages
        {"role": "user", "content": "Hello"}
    ],
    temperature=0.7,                  # Optional: 0.0 to 2.0
    max_tokens=150,                   # Optional: Max tokens to generate
    files=[                           # Optional: Files for RAG
        {"type": "file", "id": "file-123"}
    ],
    stream=False                      # Optional: Enable streaming
)

Models API

# List available models
models = client.models.list()
print(models["models"])

Files API

# Upload from file path
response = client.files.create("path/to/file.pdf", purpose="rag")

# Upload from bytes
with open("file.pdf", "rb") as f:
    response = client.files.create(f.read(), purpose="rag", filename="file.pdf")

# Upload from file object
with open("file.pdf", "rb") as f:
    response = client.files.create(f, purpose="rag", filename="file.pdf")

🔧 Advanced Examples

Multi-turn Conversation

conversation = [
    {"role": "system", "content": "You are a helpful programming assistant."},
    {"role": "user", "content": "How do I create a function in Python?"},
]

response = client.chat.create(
    model="spec-3-turbo:latest",
    messages=conversation,
    temperature=0.3
)

# Add the AI response to conversation history
conversation.append({
    "role": "assistant", 
    "content": response["choices"][0]["message"]["content"]
})

# Continue the conversation
conversation.append({
    "role": "user", 
    "content": "Can you show me an example?"
})

response = client.chat.create(
    model="spec-3-turbo:latest",
    messages=conversation
)

Multi-file RAG

# Upload multiple files
file1 = client.files.create("technical_specs.pdf")
file2 = client.files.create("user_manual.pdf")

# Query across multiple documents
response = client.chat.create(
    model="spec-3-turbo:latest",
    messages=[
        {"role": "user", "content": "Compare the technical specifications with the user manual"}
    ],
    files=[
        {"type": "file", "id": file1["file_id"]},
        {"type": "file", "id": file2["file_id"]}
    ]
)

Error Handling

from svector import SVECTOR, AuthenticationError, RateLimitError, APIError

try:
    client = SVECTOR(api_key="invalid-key")
    response = client.chat.create(
        model="spec-3-turbo:latest",
        messages=[{"role": "user", "content": "Hello"}]
    )
except AuthenticationError:
    print("Invalid API key")
except RateLimitError:
    print("Rate limit exceeded")
except APIError as e:
    print(f"API error: {e}")

🌟 Features

  • ✅ Complete API Coverage: Chat completions, streaming, file upload, RAG
  • ✅ Type Safety: Full type hints for better development experience
  • ✅ Error Handling: Comprehensive error types and retry logic
  • ✅ Streaming Support: Real-time response streaming
  • ✅ File Upload: Support for various file formats and RAG
  • ✅ CLI Interface: Command-line tool for quick interactions
  • ✅ Production Ready: Robust error handling and retry mechanisms

🔑 Authentication

Get your API key from the SVECTOR Dashboard.

Set it as an environment variable:

export SVECTOR_API_KEY="your-api-key-here"

Or pass it directly to the client:

client = SVECTOR(api_key="your-api-key-here")

🌍 Supported Models

  • spec-3-turbo:latest - General purpose model with excellent performance
  • spec-3-pro:latest - Advanced reasoning model for complex tasks

Get the latest list:

models = client.models.list()

📋 Requirements

  • Python 3.8+
  • requests library (automatically installed)

🤝 Support

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

🚀 Getting Started

  1. Install the package:

    pip install svector
    
  2. Get your API key: Visit https://www.svector.co.in

  3. Start building:

    from svector import SVECTOR
    
    client = SVECTOR(api_key="your-key")
    response = client.chat.create(
        model="spec-3-turbo:latest",
        messages=[{"role": "user", "content": "Hello, SVECTOR!"}]
    )
    

Built with ❤️ by the SVECTOR 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

svector_sdk-1.0.4.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

svector_sdk-1.0.4-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file svector_sdk-1.0.4.tar.gz.

File metadata

  • Download URL: svector_sdk-1.0.4.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for svector_sdk-1.0.4.tar.gz
Algorithm Hash digest
SHA256 005468cebc85c4434b8a1b52467b39e91b34acb729a7251a691906395b19c87b
MD5 707af7de2626c02ff46a0a0d62b5af48
BLAKE2b-256 7ee717902337d7c2f9a125b44be161d2840e66b401b8d5a9486ec5f4d07f5ed1

See more details on using hashes here.

File details

Details for the file svector_sdk-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: svector_sdk-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for svector_sdk-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8e6f38893c3156bede2a9d6f8ec2a95630a4bfa086af82c9839e46c20750207f
MD5 f02459bce0d1f1b19816d5665ca04e54
BLAKE2b-256 d4415dd97bc2c0f5df65b536f14e74e206249307fa06a2eaf91376e07f7d8d7b

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