mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🐛 fix(api): Fix the issue where custom AI Providers cannot use custom APIs (#11335)
* 🐛 fix(api): use provider instead of sdkType for API endpoints Fixed custom AI Provider functionality by correcting API endpoint construction. Previously used sdkType/runtimeProvider (e.g., 'azure', 'openai') as the API path, causing server to query wrong provider configuration from database. Now correctly uses the original provider identifier, allowing custom providers to work with server-side APIs. Changes: - chat/index.ts: use provider for chat API endpoint - models.ts: use provider for models and modelPull API endpoints 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * ✅ test(models): update test to match API endpoint fix 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -82,7 +82,8 @@ describe('ModelsService', () => {
|
||||
await modelsService.getModels('custom-provider');
|
||||
|
||||
expect(mockedResolveRuntimeProvider).toHaveBeenCalledWith('custom-provider');
|
||||
expect(fetch).toHaveBeenCalledWith('/webapi/models/openai', { headers: {} });
|
||||
// API endpoint uses original provider, allowing server to query correct config
|
||||
expect(fetch).toHaveBeenCalledWith('/webapi/models/custom-provider', { headers: {} });
|
||||
expect(mockedInitializeWithClientStore).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
@@ -402,7 +402,7 @@ class ChatService {
|
||||
responseAnimation,
|
||||
].reduce((acc, cur) => merge(acc, standardizeAnimationStyle(cur)), {});
|
||||
|
||||
return fetchSSE(API_ENDPOINTS.chat(sdkType), {
|
||||
return fetchSSE(API_ENDPOINTS.chat(provider), {
|
||||
body: JSON.stringify(payload),
|
||||
fetcher: fetcher,
|
||||
headers,
|
||||
|
||||
@@ -49,7 +49,7 @@ export class ModelsService {
|
||||
return agentRuntime.models();
|
||||
}
|
||||
|
||||
const res = await fetch(API_ENDPOINTS.models(runtimeProvider), { headers });
|
||||
const res = await fetch(API_ENDPOINTS.models(provider), { headers });
|
||||
if (!res.ok) return;
|
||||
|
||||
return res.json();
|
||||
@@ -87,7 +87,7 @@ export class ModelsService {
|
||||
});
|
||||
res = (await agentRuntime.pullModel({ model }, { signal }))!;
|
||||
} else {
|
||||
res = await fetch(API_ENDPOINTS.modelPull(runtimeProvider), {
|
||||
res = await fetch(API_ENDPOINTS.modelPull(provider), {
|
||||
body: JSON.stringify({ model }),
|
||||
headers,
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user