mirror of
https://github.com/Gitlawb/openclaude.git
synced 2026-08-24 02:34:15 -05:00
fix(openai-shim): restore provider coverage and array content guard
Keep relocated openaiShim suite tests in test:provider, and reject non-object array content parts the same way the inline converter did.
This commit is contained in:
+1
-1
@@ -68,7 +68,7 @@
|
||||
"install:verify": "bun run scripts/verify-clean-install.ts",
|
||||
"install:verify:published": "bun run scripts/verify-clean-install.ts --published",
|
||||
"build:verified": "bun run build && bun run verify:privacy",
|
||||
"test:provider": "bun test --feature=UNATTENDED_RETRY --max-concurrency=1 src/services/api/*.test.ts src/utils/context.test.ts",
|
||||
"test:provider": "bun test --feature=UNATTENDED_RETRY --max-concurrency=1 src/services/api/*.test.ts src/services/api/openaiShim/*.test.ts src/utils/context.test.ts",
|
||||
"doctor:runtime": "bun run scripts/system-check.ts",
|
||||
"doctor:runtime:json": "bun run scripts/system-check.ts --json",
|
||||
"doctor:report": "bun run scripts/system-check.ts --out reports/doctor-runtime.json",
|
||||
|
||||
@@ -203,12 +203,17 @@ test('preserves structured Gemini signatures and safety terminal responses', ()
|
||||
})
|
||||
|
||||
test('normalizes array content and length stop reasons', () => {
|
||||
const functionPart = Object.assign(() => {}, {
|
||||
type: 'text' as const,
|
||||
text: 'ignored-fn',
|
||||
})
|
||||
const message = convert({
|
||||
choices: [{
|
||||
message: {
|
||||
content: [
|
||||
{ type: 'text', text: 'first' },
|
||||
{ type: 'image' },
|
||||
functionPart,
|
||||
{ type: 'text', text: 'second' },
|
||||
],
|
||||
},
|
||||
|
||||
@@ -69,8 +69,16 @@ export function convertNonStreamingResponseToAnthropicMessage(
|
||||
? choice.message.content : null
|
||||
if (typeof rawContent === 'string' && rawContent) appendTextOrRecoveredToolCalls(rawContent)
|
||||
else if (Array.isArray(rawContent)) {
|
||||
const text = rawContent.filter(part => part?.type === 'text' && typeof part.text === 'string')
|
||||
.map(part => part.text!).join('\n')
|
||||
const text = rawContent
|
||||
.filter(
|
||||
part =>
|
||||
part &&
|
||||
typeof part === 'object' &&
|
||||
part.type === 'text' &&
|
||||
typeof part.text === 'string',
|
||||
)
|
||||
.map(part => part.text!)
|
||||
.join('\n')
|
||||
if (text) appendTextOrRecoveredToolCalls(text)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user