|
|
@@ -7,6 +7,7 @@ import type { SessionEvent } from '@deepseek-ai/dsh-session'
|
|
|
import { CompactionId } from '@deepseek-ai/dsh-compact'
|
|
|
import LlmService, { CallId, createUserMessage, GenerateOptions, LlmAdapter, StreamChunk } from '@deepseek-ai/dsh-llm'
|
|
|
import {
|
|
|
+ type Config,
|
|
|
type ReplayEntry,
|
|
|
type SessionScript,
|
|
|
apply,
|
|
|
@@ -1097,11 +1098,31 @@ describe('apply (the plugin entry)', () => {
|
|
|
writeFileSync(file, sessionJsonl(TEXT_CHUNKS.map((c, i) => chunkEvent(i + 1, 1, 1, c))), 'utf8')
|
|
|
const ctx = new Context()
|
|
|
await ctx.plugin(LlmService)
|
|
|
- apply(ctx, { file, providers: [{ id: 'm', models: [{ id: 'm' }] }], paceMs: 1 })
|
|
|
- expect(ctx.llm.listProviders()).toEqual([{ id: 'm', name: 'm' }])
|
|
|
+ apply(ctx, {
|
|
|
+ file,
|
|
|
+ providers: [
|
|
|
+ { id: 'm', models: [{ id: 'm', inputModalities: ['image'] }, { id: 'text' }] },
|
|
|
+ { id: 'empty' },
|
|
|
+ ],
|
|
|
+ paceMs: 1,
|
|
|
+ })
|
|
|
+ expect(ctx.llm.listProviders()).toEqual([{ id: 'm', name: 'm' }, { id: 'empty', name: 'empty' }])
|
|
|
+ await expect(ctx.llm.resolveModelInfo('m', 'm')).resolves.toMatchObject({ inputModalities: ['image'] })
|
|
|
expect(await drain(ctx.llm.stream({ provider: 'm', model: 'm', messages: [] }))).toEqual(TEXT_CHUNKS)
|
|
|
})
|
|
|
|
|
|
+ it.each([
|
|
|
+ ['a string', 'image'],
|
|
|
+ ['an unknown modality', ['audio']],
|
|
|
+ ])('rejects inputModalities configured as %s during load', (_case, inputModalities) => {
|
|
|
+ const ctx = new Context()
|
|
|
+ const providers = [{ id: 'm', models: [{ id: 'm', inputModalities }] }] as unknown as
|
|
|
+ NonNullable<Config['providers']>
|
|
|
+ expect(() => { apply(ctx, { file, providers }) }).toThrow(
|
|
|
+ 'llm-replay: provider "m" model "m" inputModalities must be an array containing only "text" and "image"',
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
it('falls back to $DSH_SNAPSHOT_FILE / $DSH_SNAPSHOT_OVERRIDE when config is empty', async () => {
|
|
|
writeFileSync(file, sessionJsonl([]), 'utf8')
|
|
|
const overrideFile = join(dir, 'replay.override.json')
|