-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Context
Following the resolution of #32, which revealed deeper architectural needs beyond the immediate system_instruction fix, this issue tracks the comprehensive work needed to achieve true provider abstraction in ai-proxy-core.
Problem Statement
While fixing #32, we discovered that parameter handling is inconsistent across providers. The library currently requires developers to understand provider-specific differences, defeating the purpose of an abstraction layer.
Current Gaps
1. Parameter Normalization
- Temperature: Different ranges (0-1 vs 0-2)
- Token limits:
max_tokensvsmax_output_tokensvsmax_new_tokens - Response formats: JSON mode implementations vary
- Stop sequences: Different parameter names and behaviors
- Sampling parameters: top_p, top_k availability varies
2. Feature Parity Issues
- Tool/Function calling: Completely different implementations
- Streaming: Inconsistent response formats
- Vision capabilities: Not all providers support images
- Embeddings: Different dimensionality and models
- Safety settings: Provider-specific implementations
3. Error Handling
- Different error formats and codes
- Inconsistent rate limiting responses
- No unified retry strategy
- Missing automatic failover
4. Missing Abstractions
# What we have:
system_instruction="Be helpful" # Works after v0.4.3
# What we need:
response = await client.create_completion(
messages=messages,
model="auto", # Provider selection based on requirements
temperature=0.7, # Normalized across all providers
json_mode=True, # Unified JSON response handling
safety="medium", # Abstracted safety levels
retry_strategy="exponential",
fallback_providers=["openai", "gemini", "ollama"],
capabilities_required=["streaming", "tools", "vision"]
)Proposed Solution
Phase 1: Discovery & Documentation
- Audit ALL parameters across providers
- Create compatibility matrix
- Document provider capabilities
- Identify normalization strategies
Phase 2: Core Abstractions
- Implement parameter normalization layer
- Create unified error handling
- Build capability detection system
- Add provider selection logic
Phase 3: Advanced Features
- Automatic failover between providers
- Cost optimization routing
- Performance-based selection
- Feature fallback strategies
Phase 4: Testing & Validation
- Cross-provider integration tests
- Performance benchmarks
- Error scenario testing
- Real-world usage validation
Success Criteria
- Zero provider-specific code in applications using the library
- Automatic handling of provider differences
- Seamless failover when providers are unavailable
- Consistent behavior across all providers
- Clear capability reporting for feature availability
Technical Design Considerations
- Backwards compatibility: Existing code must continue working
- Progressive enhancement: Advanced features optional
- Performance: Abstraction shouldn't add significant overhead
- Extensibility: Easy to add new providers
- Debugging: Clear visibility into provider selection and transformations
Related Issues
- OpenAI provider fails with 'unexpected keyword argument system_instruction' in v0.4.1 #32 - Original issue that exposed these needs
Questions for Discussion
- Should provider-specific features be exposed or hidden?
- How do we handle features that only some providers support?
- What's the right balance between abstraction and control?
- Should we support provider-specific escape hatches?
This is a significant architectural evolution that will make ai-proxy-core truly provider-agnostic. Looking for community input on priorities and approach.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels