mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
Add @deepseek-ai/dsh-web-search-deepseek: a WebSearchProvider that calls DeepSeek's Anthropic-compatible Messages API with the native web_search_20250305 server tool and parses the structured web_search_tool_result blocks into the ctx.web seam's WebSearchResult. - Namespace plugin (inject: ['web']), no default export — registers into ctx.web like dsh-llm-deepseek registers into ctx.llm. - Strict mode: a response with no web_search_tool_result block throws WEB_PROVIDER_ERROR rather than scraping URLs from model prose. - Reuses $DEEPSEEK_API_KEY; baseURL defaults to the Anthropic-compatible base (api.deepseek.com/anthropic/v1) and does NOT reuse $DEEPSEEK_BASE_URL, which belongs to the chat-completions LLM adapter. - snippet joined from text-block citations; sources deduped by url. - Two-stage build layout (outDir lib/types) matching the other web packages; registered in tsconfig.json, tsconfig.build.json, knip.json, and docs/module-graph.md.
37 lines
1.6 KiB
TypeScript
37 lines
1.6 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
DeepSeekSearchProvider,
|
|
DEEPSEEK_DEFAULT_API_VERSION,
|
|
DEEPSEEK_DEFAULT_BASE_URL,
|
|
DEEPSEEK_DEFAULT_MAX_TOKENS,
|
|
DEEPSEEK_DEFAULT_MAX_USES,
|
|
DEEPSEEK_DEFAULT_MODEL,
|
|
} from '@deepseek-ai/dsh-web-search-deepseek'
|
|
|
|
/**
|
|
* Real-API smoke for the DeepSeek search provider. Self-skips without
|
|
* `$DEEPSEEK_API_KEY`, per the with-key e2e policy in AGENTS.md § Secrets. This
|
|
* is the only test that proves DeepSeek's Anthropic-compatible endpoint actually
|
|
* triggers native `web_search` and returns the structured result blocks the
|
|
* provider parses — a mock cannot confirm the wire shape is real.
|
|
*/
|
|
const apiKey = process.env.DEEPSEEK_API_KEY
|
|
const maybe = apiKey !== undefined && apiKey.length > 0 ? describe : describe.skip
|
|
|
|
maybe('DeepSeekSearchProvider real API', () => {
|
|
it('returns citeable sources for a live query via native web_search', async () => {
|
|
const provider = new DeepSeekSearchProvider({
|
|
apiKey: apiKey!,
|
|
baseURL: process.env.DEEPSEEK_SEARCH_BASE_URL ?? DEEPSEEK_DEFAULT_BASE_URL,
|
|
model: process.env.DEEPSEEK_SEARCH_MODEL ?? DEEPSEEK_DEFAULT_MODEL,
|
|
apiVersion: DEEPSEEK_DEFAULT_API_VERSION,
|
|
maxTokens: DEEPSEEK_DEFAULT_MAX_TOKENS,
|
|
maxUses: DEEPSEEK_DEFAULT_MAX_USES,
|
|
})
|
|
const result = await provider.search({ query: 'What is the DeepSeek coding agent?', maxResults: 5 })
|
|
expect(result.providerId).toBe('deepseek')
|
|
expect(result.sources.length).toBeGreaterThan(0)
|
|
for (const source of result.sources) expect(source.url).toMatch(/^https?:\/\//)
|
|
}, 60_000)
|
|
})
|