fix(provider): ollama provider fix (#246)
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Haze <hazeone@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { PROVIDER_TYPES, PROVIDER_TYPE_INFO } from '@/lib/providers';
|
||||
import { PROVIDER_TYPES, PROVIDER_TYPE_INFO, resolveProviderApiKeyForSave } from '@/lib/providers';
|
||||
import {
|
||||
BUILTIN_PROVIDER_TYPES,
|
||||
getProviderConfig,
|
||||
@@ -39,4 +39,26 @@ describe('provider metadata', () => {
|
||||
expect.arrayContaining(['anthropic', 'openai', 'google', 'openrouter', 'ark', 'moonshot', 'siliconflow', 'minimax-portal', 'minimax-portal-cn', 'qwen-portal', 'ollama'])
|
||||
);
|
||||
});
|
||||
|
||||
it('uses OpenAI-compatible Ollama default base URL', () => {
|
||||
expect(PROVIDER_TYPE_INFO).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: 'ollama',
|
||||
defaultBaseUrl: 'http://localhost:11434/v1',
|
||||
requiresApiKey: false,
|
||||
showBaseUrl: true,
|
||||
showModelId: true,
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
it('normalizes provider API keys for save flow', () => {
|
||||
expect(resolveProviderApiKeyForSave('ollama', '')).toBe('ollama-local');
|
||||
expect(resolveProviderApiKeyForSave('ollama', ' ')).toBe('ollama-local');
|
||||
expect(resolveProviderApiKeyForSave('ollama', 'real-key')).toBe('real-key');
|
||||
expect(resolveProviderApiKeyForSave('openai', '')).toBeUndefined();
|
||||
expect(resolveProviderApiKeyForSave('openai', ' sk-test ')).toBe('sk-test');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user