Skip to main content

specific.ai python sdk

Project description

Specific.ai SDK

Installation

pip install specific-ai

Quick Start

from specific_ai import OpenAI

# Initialize the client
client = OpenAI(
    specific_ai_url="<your-specific-ai-service-URL>",
    api_key="<your-openai-api-key>",
    use_specific_ai_inference=False,
)

# Use like regular OpenAI client with the SpecificAI additional field
response = client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=[
        {"role": "user", "content": "Hello!"}
    ],
    specific_ai={
        "task_name": "greeting",
    }
)

Features

  • 🎯 Custom-tailored models optimized for your specific use cases
  • 🚀 Drop-in replacement for OpenAI's official Python client
  • 📊 Automatic request and response logging
  • 🎯 Response optimization capabilities
  • 📈 Advanced analytics integration

Core Features Explained

Model Inference Options

The SDK offers two approaches to model inference, controlled by use_specific_ai_inference:

client = OpenAI(
    api_key="your-key",
    use_specific_ai_inference=True  # Enable SpecificAI's optimized models
)
  • Standard Inference (use_specific_ai_inference=False):

    • Uses OpenAI's models directly
    • Standard pricing and performance
    • No optimization layer
  • SpecificAI Inference (use_specific_ai_inference=True):

    • Uses task-specific models optimized for your use cases
    • Potential improvements in performance and cost
    • Automatic fallback to standard OpenAI models if needed
    • Requires prior data collection for model training

Best Practices

  1. Start with Data Collection:

    • Keep use_specific_ai_inference=False initially
    • This builds up training data for your use cases
  2. Transition to Optimized Models:

    • Once sufficient data is collected
    • Enable use_specific_ai_inference=True
    • Monitor performance improvements
  3. Testing New Features:

    • Use A/B testing between standard and optimized models
    • Compare performance metrics
    • Gradually roll out optimization to production

Logging

This SDK uses Python's standard logging module. To capture logs from the SDK, configure logging in your application:

import logging

# Basic console logging
logging.basicConfig(level=logging.INFO)

# Or for more detailed logs
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)

Support

Need help? Contact our support team at support@specifc.ai

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

specific_ai-0.1.2.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

specific_ai-0.1.2-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file specific_ai-0.1.2.tar.gz.

File metadata

  • Download URL: specific_ai-0.1.2.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for specific_ai-0.1.2.tar.gz
Algorithm Hash digest
SHA256 146864838be4b546d1b1bdd32e23766508be0997e578d53acc8d04b88b8132ff
MD5 411ed7d6300a6b68e76797078eefed30
BLAKE2b-256 b2df0d2c0c22e8b0b09ac2d921c76752d4176a7c65fef5976dcd0694723d6358

See more details on using hashes here.

File details

Details for the file specific_ai-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: specific_ai-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for specific_ai-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1de346e68edde8ee4d67fdcb9a6b309a8ae605fdc9cfd753f9e12b2b40c19e1c
MD5 5021d48daea737c5901433372f8b8014
BLAKE2b-256 b791d9455040a3d14c1ecc9685fb4f5cd85e1f92dd7bd874ac529adb971cfc38

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