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 Document Processing

# Upload a file for document processing
file_response = client.files.create("document.pdf", purpose="assistant")
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 document processing
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 document processing
        {"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="assistant")

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

# Upload from file object
with open("file.pdf", "rb") as f:
    response = client.files.create(f, purpose="assistant", 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 Document Processing

# 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, document processing
  • 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 document processing
  • 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 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.5.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.5-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: svector_sdk-1.0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 4aa1d9fe30694c01a3797d447ccef76bc6c0e4b8af4f1d21bbdb5f8a9bb323d1
MD5 d51f0b68c9a19d228837893ddf958edf
BLAKE2b-256 01730a1fb4b3faf13856b60768f47ea9bd22a0df11cd8aa1b70b6dedc2cde44a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: svector_sdk-1.0.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6465863817b34c5960622244262c34092df90f91c5e303fc909c859f08d2ba78
MD5 e165424f17db02c327ed5fdf637c17da
BLAKE2b-256 86b31da4787e91b33b5933c7d6aa0b5157f3c5958895e4e85ac1986656b8df84

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