|
|
@@ -8,14 +8,12 @@ import * as LlmDeepSeek from '@deepseek-ai/dsh-llm-deepseek'
|
|
|
import { assemble, type AssembledResult } from './assemble.ts'
|
|
|
|
|
|
/**
|
|
|
- * Real-API e2e for the pi-ai-backed adapter: V4 Flash + V4 Pro with provider
|
|
|
- * defaults and representative off/high/max reasoning. Mirrors the native
|
|
|
- * adapter's StreamChunk contract and exercises a replayed tool follow-up.
|
|
|
- * Key-gated.
|
|
|
+ * Real-API e2e for the pi-ai-backed adapter: V4 Flash defaults and
|
|
|
+ * off/high/max reasoning. Mirrors the native adapter's StreamChunk contract
|
|
|
+ * and exercises a replayed tool follow-up. Key-gated.
|
|
|
*/
|
|
|
|
|
|
const FLASH = 'deepseek-v4-flash'
|
|
|
-const PRO = 'deepseek-v4-pro'
|
|
|
const contexts: Context[] = []
|
|
|
|
|
|
async function harness(_model: string, config: Partial<PiAiProviderProfile> = {}) {
|
|
|
@@ -67,10 +65,10 @@ const weatherTool: ToolSchema = {
|
|
|
}
|
|
|
|
|
|
describe.skipIf(!process.env.DEEPSEEK_API_KEY)('llm-pi-ai e2e (real API)', () => {
|
|
|
- it.each([FLASH, PRO])('%s + provider-default reasoning: plain text generation', async (model) => {
|
|
|
- const ctx = await harness(model)
|
|
|
+ it(`${FLASH} + provider-default reasoning: plain text generation`, async () => {
|
|
|
+ const ctx = await harness(FLASH)
|
|
|
const result = await assemble(ctx,{
|
|
|
- model,
|
|
|
+ model: FLASH,
|
|
|
messages: ask('Reply with exactly the word: pong'),
|
|
|
maxTokens: 50,
|
|
|
})
|
|
|
@@ -91,10 +89,10 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('llm-pi-ai e2e (real API)', () =>
|
|
|
expect(textOf(result).toLowerCase()).toContain('pong')
|
|
|
})
|
|
|
|
|
|
- it.each([FLASH, PRO])('%s + reasoning high: reasoning blocks present', async (model) => {
|
|
|
- const ctx = await harness(model)
|
|
|
+ it(`${FLASH} + reasoning high: reasoning blocks present`, async () => {
|
|
|
+ const ctx = await harness(FLASH)
|
|
|
const result = await assemble(ctx,{
|
|
|
- model,
|
|
|
+ model: FLASH,
|
|
|
reasoningEffort: ReasoningEffortId('high'),
|
|
|
messages: ask('Which is larger, 9.11 or 9.8? Answer with just the number.'),
|
|
|
maxTokens: 2000,
|
|
|
@@ -104,24 +102,27 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('llm-pi-ai e2e (real API)', () =>
|
|
|
expect(textOf(result)).toContain('9.8')
|
|
|
})
|
|
|
|
|
|
- it('pro + reasoning max: tool-call round trip', async () => {
|
|
|
- const ctx = await harness(PRO)
|
|
|
+ it('flash + reasoning max: tool-call round trip', async () => {
|
|
|
+ const ctx = await harness(FLASH)
|
|
|
|
|
|
const first = await assemble(ctx,{
|
|
|
- model: PRO,
|
|
|
+ model: FLASH,
|
|
|
reasoningEffort: ReasoningEffortId('max'),
|
|
|
messages: ask('What is the weather in Paris right now? Use the get_weather tool.'),
|
|
|
tools: [weatherTool],
|
|
|
maxTokens: 2000,
|
|
|
})
|
|
|
- expect(first.finish.kind).toBe('tool-calls')
|
|
|
+ expect(
|
|
|
+ first.finish.kind,
|
|
|
+ `pi-ai Flash tool-call turn finished as ${JSON.stringify(first.finish)}`,
|
|
|
+ ).toBe('tool-calls')
|
|
|
const call = first.message.content.find(block => block.type === 'tool-call')
|
|
|
expect(call).toBeDefined()
|
|
|
expect(call!.name).toBe('get_weather')
|
|
|
expect(JSON.parse(call!.arguments)).toMatchObject({ city: expect.stringMatching(/paris/i) as string })
|
|
|
|
|
|
const second = await assemble(ctx,{
|
|
|
- model: PRO,
|
|
|
+ model: FLASH,
|
|
|
reasoningEffort: ReasoningEffortId('max'),
|
|
|
messages: [
|
|
|
...ask('What is the weather in Paris right now? Use the get_weather tool.'),
|
|
|
@@ -138,7 +139,10 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('llm-pi-ai e2e (real API)', () =>
|
|
|
tools: [weatherTool],
|
|
|
maxTokens: 2000,
|
|
|
})
|
|
|
- expect(second.finish.kind).toBe('stop')
|
|
|
+ expect(
|
|
|
+ second.finish.kind,
|
|
|
+ `pi-ai Flash tool-result turn finished as ${JSON.stringify(second.finish)}`,
|
|
|
+ ).toBe('stop')
|
|
|
expect(textOf(second).toLowerCase()).toMatch(/sunny|22/)
|
|
|
})
|
|
|
|