How kharvd/gpt-cli works
Main Components
a) Core Components:
• CLI Interface Layer
• Provider Integration Layer
• Session Management
• Configuration Management
• Logging System
b) External Services:
• OpenAI API
• Anthropic API
• Google Gemini API
• Cohere API
• Custom OpenAI-compatible APIs
Top Layer: User Interface
Middle Layer: Core Logic
Bottom Layer: Provider Integration
External Layer: API Services
Component Relationships
a) User Interface Components:
• cli.py → Main entry point
• shell.py → Interactive shell handling
• completion.py → Command completion
b) Core Logic:
• session.py → Chat session management
• config.py → Configuration handling
• assistant.py → Assistant behavior
• cost.py → Usage tracking
• logging_utils.py → Logging functionality
c) Provider Integration:
• providers/* → Individual provider implementations
• gpt.py → Common interface for providers
Specific Implementation Details
a) Data Flow:
• User input → CLI → Session Manager → Provider → External API
• Configuration file (gpt.yml) → Config Manager → Component Configuration
• Usage data → Cost Tracker → Logging System
b) Key Interfaces:
• Provider abstract interface in providers/__init__.py
• Individual provider implementations
• Session management interface
Below it, create a layer for core components
• Session Manager (session.py)
• Assistant Manager (assistant.py)
• Configuration Manager (config.py)
• Abstract Provider Interface
• Individual Provider Implementations
At the bottom, show external API services
Important Architectural Patterns to Highlight:
• Provider Pattern: Show how different LLM providers are abstracted
• Command Pattern: CLI command processing
• Strategy Pattern: Different assistant configurations
• Factory Pattern: Provider creation
• Component types
• Configuration flow