Skip to content

Conversation

@hyperwd
Copy link

@hyperwd hyperwd commented Oct 14, 2025

Add comprehensive authentication support for custom AI providers, addressing limitations with the previous API key-only system.

Key Features:

  • Multiple authentication types: Bearer token, API key, custom headers, no auth
  • Flexible header configuration for complex authentication scenarios
  • Backward compatibility with existing provider configurations
  • Enhanced UI with example configurations for common providers
  • Support for Zhipu AI, Moonshot AI, and other custom providers

Changes:

Backend:

  • server/aiServer/authTypes.ts: Authentication types and utilities
  • server/aiServer/providers/EmbeddingProvider.ts: Enhanced with custom auth
  • server/aiServer/providers/LLMProvider.ts: Enhanced with custom auth
  • server/routerTrpc/ai.ts: Updated test connection and API endpoints

Frontend:

  • app/src/components/BlinkoSettings/AiSetting/AuthenticationConfig.tsx: New auth UI component
  • app/src/components/BlinkoSettings/AiSetting/ProviderDialogContent.tsx: Enhanced provider dialog
  • app/src/store/aiSettingStore.tsx: Enhanced store with auth support
  • app/public/locales/en/translation.json: Updated translations

Documentation:

  • docs/ENHANCED_AUTHENTICATION.md: Comprehensive usage guide

Technical Details:

  • Authentication config stored in provider.config.authConfig JSON field
  • Custom fetch functions inject authentication headers
  • Graceful fallback to legacy authentication for existing providers
  • Input validation and error handling for security

🤖 Generated with Claude Code

github-actions bot and others added 23 commits September 29, 2025 12:26
- Add feature flags for whisper-cuda and whisper-cpu in Cargo.toml
- Create separate tauri.cuda.conf.json with Blinko(CUDA) product name
- Implement conditional compilation for voice module based on features
- Add is_cuda_available command for frontend CUDA detection
- Update GitHub Actions workflows for matrix builds (cpu/cuda variants)
- Add CUDA availability check in voice settings UI
- Configure conditional voice module loading in lib.rs and setup.rs
Docs: update French translation of todo to Tâches instead of Procuration
- Add 250ms delay activation constraint for mouse and touch sensors
- Consolidate all drag logic into dedicated useDragCard hook
- Remove drag functionality from BlinkoCard component
- Implement stable drag with placeholder and insertion line
- Add multi-language support for dragging state
- Fix text selection conflicts with long-press approach
- Improve masonry layout stability during drag operations
Add comprehensive authentication support for custom AI providers, addressing
limitations with the previous API key-only system.

### Key Features:
- Multiple authentication types: Bearer token, API key, custom headers, no auth
- Flexible header configuration for complex authentication scenarios
- Backward compatibility with existing provider configurations
- Enhanced UI with example configurations for common providers
- Support for Zhipu AI, Moonshot AI, and other custom providers

### Changes:

#### Backend:
- `server/aiServer/authTypes.ts`: Authentication types and utilities
- `server/aiServer/providers/EmbeddingProvider.ts`: Enhanced with custom auth
- `server/aiServer/providers/LLMProvider.ts`: Enhanced with custom auth
- `server/routerTrpc/ai.ts`: Updated test connection and API endpoints

#### Frontend:
- `app/src/components/BlinkoSettings/AiSetting/AuthenticationConfig.tsx`: New auth UI component
- `app/src/components/BlinkoSettings/AiSetting/ProviderDialogContent.tsx`: Enhanced provider dialog
- `app/src/store/aiSettingStore.tsx`: Enhanced store with auth support
- `app/public/locales/en/translation.json`: Updated translations

#### Documentation:
- `docs/ENHANCED_AUTHENTICATION.md`: Comprehensive usage guide

### Technical Details:
- Authentication config stored in provider.config.authConfig JSON field
- Custom fetch functions inject authentication headers
- Graceful fallback to legacy authentication for existing providers
- Input validation and error handling for security

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels Oct 14, 2025
updateConfig({ customHeaders: newHeaders });
};

const renderBearerConfig = () => (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I learned that rendering by function could create problems when rerendering.
Instead, the best practice is to create a React component.
Simply like this:

Suggested change
const renderBearerConfig = () => (
const BearerConfig = <div...

To then use it with:

{localConfig.type === 'bearer' && <BearerConfig/>}

<Icon icon="hugeicons:settings-03" width="16" height="16" />
<div>
<div className="font-medium">Custom Headers</div>
<div className="text-xs text-default-500">Full control over headers</div>
Copy link
Contributor

@revaxe revaxe Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translation should certainly be provided for these descriptions and labels

</div>
))}

<div className="flex items-center gap-2">
Copy link
Contributor

@revaxe revaxe Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have put a <form here, and passed the button to submit type

Suggested change
<div className="flex items-center gap-2">
<form onSubmit={addCustomHeader} className="flex items-center gap-2">

Comment on lines +28 to +34
const baseURL = config.baseURL;

switch (config.provider.toLowerCase()) {
case 'openai':
return createOpenAI({
apiKey: config.apiKey,
baseURL: config.baseURL || undefined,
apiKey: apiKey,
baseURL: baseURL || undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also have added || undefined in the const.

 const baseURL = config.baseURL || undefined;

    switch (config.provider.toLowerCase()) {
      case 'openai':
        return createOpenAI({
          apiKey,
          baseURL,

@revaxe
Copy link
Contributor

revaxe commented Oct 19, 2025

That's cool what you're suggesting, it will answer my request for improvement : #818

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants