Airtrain
A powerful platform for building and deploying AI agents with structured skills and capabilities.
Features
- Structured Skills: Build modular AI skills with defined input/output schemas
- Multiple LLM Integrations: Built-in support for OpenAI and Anthropic models
- Structured Outputs: Parse LLM responses into structured Pydantic models
- Credential Management: Secure handling of API keys and credentials
- Type Safety: Full type hints and Pydantic model support
- Image Support: Handle image inputs for multimodal models
- Error Handling: Robust error handling and logging
Installation
pip install airtrain
Quick Start
1. Basic OpenAI Chat
from airtrain.integrations.openai.skills import OpenAIChatSkill, OpenAIInput
# Initialize the skill
skill = OpenAIChatSkill()
# Create input
input_data = OpenAIInput(
user_input="Explain quantum computing in simple terms.",
system_prompt="You are a helpful teacher.",
max_tokens=500,
temperature=0.7
)
# Get response
result = skill.process(input_data)
print(result.response)
print(f"Tokens Used: {result.usage['total_tokens']}")
2. Anthropic Claude Integration
from airtrain.integrations.anthropic.skills import AnthropicChatSkill, AnthropicInput
# Initialize the skill
skill = AnthropicChatSkill()
# Create input
input_data = AnthropicInput(
user_input="Explain the theory of relativity.",
system_prompt="You are a physics expert.",
model="claude-3-opus-20240229",
temperature=0.3
)
# Get response
result = skill.process(input_data)
print(result.response)
print(f"Usage: {result.usage}")
3. Structured Output with OpenAI
from pydantic import BaseModel
from typing import List
from airtrain.integrations.openai.skills import OpenAIParserSkill, OpenAIParserInput
# Define your response model
class PersonInfo(BaseModel):
name: str
age: int
occupation: str
skills: List[str]
# Initialize the parser skill
parser_skill = OpenAIParserSkill()
# Create input with response model
input_data = OpenAIParserInput(
user_input="Tell me about John Doe, a 30-year-old software engineer who specializes in Python and AI",
system_prompt="Extract structured information about the person.",
response_model=PersonInfo
)
# Get structured response
result = parser_skill.process(input_data)
person_info = result.parsed_response
print(f"Name: {person_info.name}")
print(f"Skills: {', '.join(person_info.skills)}")
Error Handling
All skills include built-in error handling:
from airtrain.core.skills import ProcessingError
try:
result = skill.process(input_data)
except ProcessingError as e:
print(f"Processing failed: {e}")
Advanced Features
- Image Analysis Support
- Function Calling
- Custom Validators
- Async Processing
- Token Usage Tracking
For more examples and detailed documentation, visit our documentation.
Documentation
For detailed documentation, visit our documentation site.
Telemetry
Airtrain collects telemetry data to help improve the library. The data collected includes:
- Agent run information (model used, task description, environment settings)
- Agent steps and actions (full action details and reasoning)
- Performance metrics (token usage, execution time, CPU and memory usage)
- System information (OS, Python version, machine details)
- Error information (complete stack traces and context)
- Model usage details (prompts, responses, parameters)
The telemetry helps us identify usage patterns, troubleshoot issues, and improve the library based on real-world usage. The user ID is stored at ~/.cache/airtrain/telemetry_user_id.
Disabling Telemetry
Telemetry is enabled by default, but you can disable it if needed:
- Set an environment variable:
export AIRTRAIN_TELEMETRY_ENABLED=false
- In your Python code:
import os
os.environ["AIRTRAIN_TELEMETRY_ENABLED"] = "false"
Viewing Telemetry Debug Information
To see what telemetry data is being sent:
os.environ["AIRTRAIN_LOGGING_LEVEL"] = "debug"
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for airtrain 0.1.68
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| airtrain-0.1.68.tar.gz | 89.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| airtrain-0.1.68-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 236.2 kB
Release files / airtrain-0.1.68.tar.gz
| Download URL | airtrain-0.1.68.tar.gz |
|---|---|
| Size | 89.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4f02c4bfc3be8de99dccb2ad60dd83d1a9f35935f528db9933c9af6bc5be436
|
|
BLAKE2b-256 checksum How to use checksums |
379b799a7288e923d95d318c80118bc8d7869cc8ae398fbbce247bbd62e200f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / airtrain-0.1.68-py3-none-any.whl
| Download URL | airtrain-0.1.68-py3-none-any.whl |
|---|---|
| Size | 146.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c14218d24cdbde1a51ad0bf6ab5746740c6924cbe0e3481dabef3fbf436d5b62
|
|
BLAKE2b-256 checksum How to use checksums |
69bebc703dd2a2abbe2f95fca3d49f69d30225ffe5cfd8f0657f4ec306c90cdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|