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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ironaai-0.0.1.tar.gz.
File metadata
- Download URL: ironaai-0.0.1.tar.gz
- Upload date:
- Size: 3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
101fbbe2b29f38a270215badb16ce3c1ebcca59cd012075b592b173d2e44bb89
|
|
| MD5 |
868cf801850da00fd322aa48d9298264
|
|
| BLAKE2b-256 |
d5f909b50afaec96c581811d95b34d43c16e1fbd7cb746cdebcaa4716eaf2eeb
|
File details
Details for the file ironaai-0.0.1-py3-none-any.whl.
File metadata
- Download URL: ironaai-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dfd2a57fb14c0bbb8bb89838391a59c35a7ce5594df051dbc67a909f051f2cc
|
|
| MD5 |
d72ba34b320493f507c6b69dfe992757
|
|
| BLAKE2b-256 |
a33cfd506966fc4f4f2bf7075b0a5d1c81e6a64eb0b93910411b1429aded3717
|