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://api.svector.co.in",  # 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.3.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.3-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: svector_sdk-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 ddb25c62750052850c8e127d3c10091c4aea91575a066c7cf05b47dfb3c3eef9
MD5 2c4b5c6b09f435ed46973c717a9f58a9
BLAKE2b-256 5be3cf2f96374fb5f6f9af110b0516f1797ef36e4dc453d3907efb127bd011c9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: svector_sdk-1.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 68e83058aedf0675eacd63dc046dc8398e92df58e1785071245faa301f89fab9
MD5 9fa2c7698b734afacf3c3f03eb8f1ec3
BLAKE2b-256 46304f1bb593a2b49388802550f02c09fec81f34e992640ba8321a1430be2d9d

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