mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-23 01:50:13 +08:00
fix: resolve PR review issues for Proxy API Server
- Fix tool result content bug: return `values` array instead of empty array - Fix empty message bug: skip pushing user/assistant messages when content is empty - Expand provider support: remove type restrictions to support all AI SDK providers - Add missing alias for @cherrystudio/ai-sdk-provider in main process config 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
0f6ec3e061
commit
f163c4d3ee
@ -27,7 +27,8 @@ export default defineConfig({
|
|||||||
'@mcp-trace/trace-core': resolve('packages/mcp-trace/trace-core'),
|
'@mcp-trace/trace-core': resolve('packages/mcp-trace/trace-core'),
|
||||||
'@mcp-trace/trace-node': resolve('packages/mcp-trace/trace-node'),
|
'@mcp-trace/trace-node': resolve('packages/mcp-trace/trace-node'),
|
||||||
'@cherrystudio/ai-core/provider': resolve('packages/aiCore/src/core/providers'),
|
'@cherrystudio/ai-core/provider': resolve('packages/aiCore/src/core/providers'),
|
||||||
'@cherrystudio/ai-core': resolve('packages/aiCore/src')
|
'@cherrystudio/ai-core': resolve('packages/aiCore/src'),
|
||||||
|
'@cherrystudio/ai-sdk-provider': resolve('packages/ai-sdk-provider/src')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
|
|||||||
@ -186,7 +186,7 @@ IANA media type.
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
type: 'content',
|
type: 'content',
|
||||||
value: []
|
value: values
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,17 +313,24 @@ function convertAnthropicToAiMessages(params: MessageCreateParams): ModelMessage
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build the message based on role
|
// Build the message based on role
|
||||||
|
// Only push user/assistant message if there's actual content (avoid empty messages)
|
||||||
if (msg.role === 'user') {
|
if (msg.role === 'user') {
|
||||||
messages.push({
|
const userContent = [...textParts, ...imageParts]
|
||||||
role: 'user',
|
if (userContent.length > 0) {
|
||||||
content: [...textParts, ...imageParts]
|
messages.push({
|
||||||
})
|
role: 'user',
|
||||||
|
content: userContent
|
||||||
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Assistant messages contain tool calls, not tool results
|
// Assistant messages contain tool calls, not tool results
|
||||||
messages.push({
|
const assistantContent = [...reasoningParts, ...textParts, ...toolCallParts]
|
||||||
role: 'assistant',
|
if (assistantContent.length > 0) {
|
||||||
content: [...reasoningParts, ...textParts, ...toolCallParts]
|
messages.push({
|
||||||
})
|
role: 'assistant',
|
||||||
|
content: assistantContent
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,10 +28,9 @@ export async function getAvailableProviders(): Promise<Provider[]> {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support OpenAI and Anthropic type providers for API server
|
// Support all provider types that AI SDK can handle
|
||||||
const supportedProviders = providers.filter(
|
// The unified-messages service uses AI SDK which supports many providers
|
||||||
(p: Provider) => p.enabled && (p.type === 'openai' || p.type === 'anthropic')
|
const supportedProviders = providers.filter((p: Provider) => p.enabled)
|
||||||
)
|
|
||||||
|
|
||||||
// Cache the filtered results
|
// Cache the filtered results
|
||||||
CacheService.set(PROVIDERS_CACHE_KEY, supportedProviders, PROVIDERS_CACHE_TTL)
|
CacheService.set(PROVIDERS_CACHE_KEY, supportedProviders, PROVIDERS_CACHE_TTL)
|
||||||
@ -160,7 +159,7 @@ export async function validateModelId(model: string): Promise<{
|
|||||||
valid: false,
|
valid: false,
|
||||||
error: {
|
error: {
|
||||||
type: 'provider_not_found',
|
type: 'provider_not_found',
|
||||||
message: `Provider '${providerId}' not found, not enabled, or not supported. Only OpenAI providers are currently supported.`,
|
message: `Provider '${providerId}' not found or not enabled.`,
|
||||||
code: 'provider_not_found'
|
code: 'provider_not_found'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,14 +261,8 @@ export function validateProvider(provider: Provider): boolean {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support OpenAI and Anthropic type providers
|
// AI SDK supports many provider types, no longer need to filter by type
|
||||||
if (provider.type !== 'openai' && provider.type !== 'anthropic') {
|
// The unified-messages service handles all supported types
|
||||||
logger.debug('Provider type not supported', {
|
|
||||||
providerId: provider.id,
|
|
||||||
providerType: provider.type
|
|
||||||
})
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user