feat(image-recognition): independent key/url/model defaults
Make the HTTP vision provider's configuration independent of the main chat model: the API key default moves from DEEPSEEK_API_KEY to IMAGE_RECOGNITION_API_KEY, and the URL and model get image-recognition-specific defaults (Aliyun DashScope compatible-mode and qwen3-vl-flash) instead of the chat model's deepseek-v4-flash. The provider fails loud when no model is configured. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,6 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { ImageRecognitionRequest } from '@deepseek-ai/dsh-image-recognition'
|
||||
import {
|
||||
ImageRecognitionHttpProvider,
|
||||
IMAGE_RECOGNITION_DEFAULT_MODEL,
|
||||
type ImageRecognitionHttpProviderOptions,
|
||||
} from '../src/provider.ts'
|
||||
|
||||
@@ -15,7 +14,7 @@ function makeProvider(overrides: Partial<ImageRecognitionHttpProviderOptions> =
|
||||
return new ImageRecognitionHttpProvider(() => ({
|
||||
resolveApiKey: async () => 'key',
|
||||
baseURL: 'https://vision.example.com/v1',
|
||||
model: IMAGE_RECOGNITION_DEFAULT_MODEL,
|
||||
model: 'vision-model',
|
||||
maxTokens: 128,
|
||||
...overrides,
|
||||
}))
|
||||
@@ -60,6 +59,11 @@ describe('ImageRecognitionHttpProvider.recognize', () => {
|
||||
.rejects.toThrow(expect.objectContaining({ code: 'IMAGE_RECOGNITION_PROVIDER_CREDENTIAL_MISSING' }))
|
||||
})
|
||||
|
||||
it('throws IMAGE_RECOGNITION_PROVIDER_CREDENTIAL_MISSING without a model', async () => {
|
||||
await expect(makeProvider({ model: '' }).recognize(request))
|
||||
.rejects.toThrow(expect.objectContaining({ code: 'IMAGE_RECOGNITION_PROVIDER_CREDENTIAL_MISSING' }))
|
||||
})
|
||||
|
||||
it('maps a non-2xx response to IMAGE_RECOGNITION_PROVIDER_ERROR', async () => {
|
||||
stubFetch({ ok: false, status: 429, json: async () => ({ error: { message: 'rate limited' } }) })
|
||||
await expect(makeProvider().recognize(request))
|
||||
|
||||
Reference in New Issue
Block a user