How jeremychone/rust-genai works
Main Components Identification
The system should be divided into these key components:
a) Client Layer
• Entry point for all interactions
• Handles configuration and builder patterns
• Located in src/client/
b) Adapter Layer
• Core component managing different AI providers
• Contains provider-specific implementations
• Located in src/adapter/adapters/
c) Chat System
• Handles chat messages and responses
• Manages streaming capabilities
• Located in src/chat/
d) Resolver System
• Handles authentication, endpoints, and model mapping
• Located in src/resolver/
[Client Layer]
• ↓
[Resolver Layer]
• ↓
[Adapter Layer] ←→ [External AI Services]
• ↑
[Chat System]
Component Details
Client Layer:
• ClientBuilder
• Config management
• ServiceTarget resolution
Adapter Layer:
• Supported providers (OpenAI, Anthropic, Gemini, etc.)
• Adapter dispatcher
• Streaming capabilities
Chat System:
• Message handling
• Tool support
• Response formatting
Resolver System:
• Auth resolution
• Model mapping
• Endpoint management
Data Flow Representation
• Request flow: Client → Resolver → Adapter → External Service
• Response flow: External Service → Adapter → Chat System → Client
• Authentication flow: Client → Resolver → Adapter
• Model resolution flow: Client → Resolver → Adapter
Integration Points
Connections to:
• OpenAI
• Anthropic
• Gemini
• Ollama
• Groq
• Cohere
• DeepSeek
• xAI
Important Notes
Callouts for:
• Native implementation approach
• Standardized chat completion APIs
• Authentication flexibility
• Model name resolution
• Streaming support