Skip to content

Commit f9493c0

Browse files
committed
fix deepseek provider path tests
1 parent 34f8a0f commit f9493c0

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

web/src/app/api/v1/chat/completions/__tests__/completions.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,10 @@ describe('/api/v1/chat/completions POST endpoint', () => {
779779
const fetchedUrls: string[] = []
780780
const fetchViaDeepSeek = mock(
781781
async (url: string | URL | Request, init?: RequestInit) => {
782+
if (String(url).startsWith('https://api.ipinfo.io/lookup/')) {
783+
return Response.json({})
784+
}
785+
782786
fetchedUrls.push(String(url))
783787
fetchedBodies.push(JSON.parse(init?.body as string))
784788
return new Response(

web/src/llm-api/__tests__/deepseek-image-compat.integration.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ describe('normalizeDeepSeekRequestBody', () => {
5050
model: 'deepseek-v4-pro',
5151
})
5252
})
53+
54+
it('does not throw on minimal provider-path bodies without messages', () => {
55+
const body = {
56+
model: 'deepseek/deepseek-v4-pro',
57+
stream: false,
58+
} as ChatCompletionRequestBody
59+
60+
expect(normalizeDeepSeekRequestBody(body)).toEqual({
61+
...body,
62+
model: 'deepseek-v4-pro',
63+
})
64+
})
5365
})
5466

5567
describe('buildDeepSeekRequestBody', () => {

web/src/llm-api/deepseek-request-body.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,20 @@ export function normalizeDeepSeekRequestBody(
7777
body: ChatCompletionRequestBody,
7878
originalModel: string = body.model,
7979
): ChatCompletionRequestBody {
80+
const messages = Array.isArray(body.messages)
81+
? body.messages.map((message) => ({
82+
...message,
83+
content:
84+
message.content === undefined || message.content === null
85+
? message.content
86+
: contentPartsToDeepSeekText(message.content),
87+
}))
88+
: body.messages
89+
8090
return {
8191
...body,
8292
model: getDeepSeekModelId(originalModel),
83-
messages: body.messages.map((message) => ({
84-
...message,
85-
content:
86-
message.content === undefined || message.content === null
87-
? message.content
88-
: contentPartsToDeepSeekText(message.content),
89-
})),
93+
messages,
9094
}
9195
}
9296

0 commit comments

Comments
 (0)