Skip to main content

IronaAI Python SDK

Project description

API vs SDK

  • Client side LLM invocation.
    • Our API endpoint of model-router, only recommends the model to use.
    • The sdk invokes the "recommended model" for the given prompt, gets the response back.

SDK also provides the following features which API endpoint doesn't via a common interface.

Features:
  • Model routing functionality using the IronaAI API endpoints
  • [] Support for async & sync requests of LLM-invocation.
  • [] function calling,
  • [] Tool binding using LiteLLM's function calling capabilities
  • [] Error handling and retries
  • [] Support for streaming,
  • [] and JSON mode (i.e. structured output)
  • [] Detailed latency tracking and reporting - TBD
  • [] Creation of preference IDs - TBD
  • Retry logic (invocation or model-router)
  • Unified Interface
  • Tool binding

Export keys for provider you will use:

IRONAAI_API_KEY = "OUR_IRONAI_API_KEY"
OPENAI_API_KEY = "YOUR_OPENAI_API_KEY"
ANTHROPIC_API_KEY = "YOUR_ANTHROPIC_API_KEY"

To use this client, you would initialize it like this:

client = IronaAI(
    models=["openai/gpt-3.5-turbo", "openai/gpt-4", "anthropic/claude-2"],
)

You can then use it for completions, function calling, and tool binding:

# Regular completion
response = client.completion(
    messages=[{"role": "user", "content": "Hello, how are you?"}],
    models=["openai/gpt-3.5-turbo", "openai/gpt-4", "anthropic/claude-2"],)

# Function calling
functions = [
    {
        "name": "get_current_weather",
        "description": "Get the current weather in a given location",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"},
                "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
            },
            "required": ["location"]
        }
    }
]
response = client.function_call(
    messages=[{"role": "user", "content": "What's the weather like in San Francisco?"}],
    functions=functions
)

# Tool binding
def get_current_weather(location: str, unit: str = "fahrenheit"):
    """Get the current weather in a given location"""
    # Implementation here
    pass

tool_bound_client = client.bind_tools([get_current_weather])
response = tool_bound_client(messages=[{"role": "user", "content": "What's the weather like in San Francisco?"}])

Install Instructions

poetry install .

Push this to PyPi

poetry build
poetry publish

Then users can simply install the package using pip:

pip install ironaai

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

ironaai-0.0.2.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

ironaai-0.0.2-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file ironaai-0.0.2.tar.gz.

File metadata

  • Download URL: ironaai-0.0.2.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.4 Darwin/24.2.0

File hashes

Hashes for ironaai-0.0.2.tar.gz
Algorithm Hash digest
SHA256 50f75ff6cfb3e8948dc7913e10c6181110b7520a421be52b714a4f716546125f
MD5 7447e1297f443b3ed03a458b74f3ab14
BLAKE2b-256 103b6a9eca85a8da5ccfd55e9fa57163efa6b538c9924366531c0e563a4280dd

See more details on using hashes here.

File details

Details for the file ironaai-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: ironaai-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.4 Darwin/24.2.0

File hashes

Hashes for ironaai-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cf063b7112d5c360f5815cdae5767d1aae68c53a3c65f8929a96419980d2ee07
MD5 a00589b38156b40e3b29921e3d451b19
BLAKE2b-256 cc163268f48d28a65e9a855ac1870c582154fdbfef1b62530709fc2d60ae5a2b

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