Skip to content

Enhanced AI Provider URL Configuration and Cross-Platform Support#15

Open
morler wants to merge 6 commits intodavelet:mainfrom
morler:main
Open

Enhanced AI Provider URL Configuration and Cross-Platform Support#15
morler wants to merge 6 commits intodavelet:mainfrom
morler:main

Conversation

@morler
Copy link

@morler morler commented Aug 10, 2025

Support Custom AI Provider URLs and Enhanced Cross-Platform Compatibility

Overview

This PR introduces several important features:

  1. Support for custom AI provider base URL configuration
  2. Enhanced compatibility and support for the Windows platform
  3. Added --show-location flag to show the configuration file location

Major Changes

1. AI Provider URL Configuration Enhancement

  • Users now only need to provide the base URL instead of the full path
  • The application automatically appends the correct path for different providers:
    • OpenAI: https://api.openai.comhttps://api.openai.com/v1/chat/completions
    • Qwen: https://dashscope.aliyuncs.comhttps://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions
    • Other providers supporting /v1 path will also be handled correctly
  • Refactored URL building logic to be more flexible and maintainable

2. Windows Support Enhancement

  • Added full Windows platform support (Windows 7 and later)
  • Implemented Windows-specific file operations and path handling
  • Added test cases for Windows platform to ensure functionality correctness
  • Updated documentation to reflect Windows support

3. Configuration Management Improvement

  • Added --show-location flag to the config subcommand
  • When using this flag, the application will display the configuration file location and open the configuration directory
  • Makes it easier for users to find and edit configuration files

Technical Implementation Details

URL Builder Implementation

  • Defined base URLs and paths for each AI provider in src/constants.rs
  • Implemented construct_full_url function in src/cli/http.rs to handle URL building logic
  • Added comprehensive test cases to verify various URL building scenarios

Windows Compatibility

  • Added Windows-specific file manager opening logic in src/cli/entry.rs
  • Used cfg!(target_os = "windows") conditional compilation to handle platform-specific code
  • Added src/cli/windows_test.rs file containing test cases for the Windows platform

Configuration Location Display

  • Implemented open_config_directory function in src/cli/entry.rs
  • Added --show-location flag in src/cli/command.rs
  • Updated related configuration handling logic

Documentation Updates

  • Updated README.md to explain the new URL configuration method
  • Updated GEMINI.md to reflect the project's new features
  • Added descriptions of new features in the changelog

Testing

  • Added unit tests for the URL builder
  • Added dedicated test cases for Windows platform functionality
  • Verified that all existing tests still pass

This PR improves the application's usability and cross-platform compatibility, allowing users to configure AI providers more flexibly and have a better experience on the Windows platform.

morler added 6 commits August 10, 2025 21:30
{.cargo/config.toml: Add Windows target rustflags to cargo config (4)}
{Cargo.toml: Remove Windows-specific rustflags entry from Cargo.toml (2)}
README.md: Document base AI provider URL configuration and automatic path append (18)
src/cli/http.rs: Introduce construct_full_url to assemble full chat completions URLs from a user-supplied base URL, update URL resolution to use base + per-provider path, and add tests (71)
src/constants.rs: Define base URLs for providers and default/partial chat completions paths, replacing previous full URL constants (23)
README.md: Add AI Provider URL Configuration documentation (11)
src/cli/http.rs: Add construct_full_url helper, integrate it into chat URL handling, switch to base URL constants with provider-specific paths, and add tests for URL construction (69)
src/constants.rs: Introduce base URL constants and per-provider chat completion path constants; remove old URL constants (14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant