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.4.tar.gz (9.5 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.4-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ironaai-0.0.4.tar.gz
  • Upload date:
  • Size: 9.5 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.4.tar.gz
Algorithm Hash digest
SHA256 a657035d832a3d77926d58d9b96f7c2410a3be2de20ffcd4ec6904c7d16ed286
MD5 886693de980749695fbf3e9653d5a603
BLAKE2b-256 85242dc99216bd0d31a258ae170265569c8305371a637ffef713ac86d765d994

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ironaai-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.1 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d92aaa534f8fe65c5cc8dd9fb14bdc7ea81c26c28d6fc240ed3bb7e80bbb4f1d
MD5 ac028a693fd4b151c06f4e0603d3caa7
BLAKE2b-256 82ea50b9ff49a9ff8112a708d8999938b381b3128654ec1cb7b4e26626408cf4

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