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(
    model_list=["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.completions.create(
    messages=[{"role": "user", "content": "Hello, how are you?"}],
    model_list=["openai/gpt-3.5-turbo", "openai/gpt-4", "anthropic/claude-2"],)

# Function calling
def get_current_weather(location: str, unit: str = "fahrenheit"):
    """Get the current weather in a given location"""
    # Implementation here
    return f"The weather in {location} is 72°F."

tools = [
    {
        "name": "get_current_weather",
        "description": "Get the current weather in a given location",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {"type": "string"},
                "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
            },
            "required": ["location"],
        },
    }
]

messages = [{"role": "user", "content": "What's the weather like in San Francisco?"}]

# Call the model
response = client.completions.create( messages=messages, tools=tools, tool_choice="auto",)

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.3.tar.gz (9.4 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.3-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ironaai-0.0.3.tar.gz
  • Upload date:
  • Size: 9.4 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.3.tar.gz
Algorithm Hash digest
SHA256 ba6b039c11cdc2ec115d31c1feb3af3e920e9dfd8060a518e64049fce1a55b6a
MD5 cacc98bdaf3a329356d507fe9ef3263e
BLAKE2b-256 83b03ed2948bebd44dd281fb9a3f952645ce1661bb460a87248bd2872e5120a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ironaai-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.0 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bd14e5f583fd927b87836f9fbe1a2ad57d6eb22631a57ee9174f24c1d9f2d386
MD5 33dd9fd98a4391f8c978a6a417e1fb9e
BLAKE2b-256 3901439f9b40f583357be06473e4283c495288f53e20b4c02bf67f5395f1d1b7

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