deepseek.e2e.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { describe, expect, it } from 'vitest'
  2. import {
  3. DeepSeekSearchProvider,
  4. DEEPSEEK_DEFAULT_API_VERSION,
  5. DEEPSEEK_DEFAULT_BASE_URL,
  6. DEEPSEEK_DEFAULT_MAX_TOKENS,
  7. DEEPSEEK_DEFAULT_MAX_USES,
  8. DEEPSEEK_DEFAULT_MODEL,
  9. } from '@deepseek-ai/dsh-web-search-deepseek'
  10. /** Construct the provider over a fixed options value; production passes a live thunk. */
  11. import type { DeepSeekSearchProviderOptions } from '@deepseek-ai/dsh-web-search-deepseek'
  12. const searchProvider = (options: DeepSeekSearchProviderOptions): DeepSeekSearchProvider =>
  13. new DeepSeekSearchProvider(() => options)
  14. /**
  15. * Disabled real-API probe for the DeepSeek search provider. The live endpoint
  16. * can complete without structured source blocks, so this is not a reliable
  17. * merge signal. Its body remains because mocks cannot confirm the wire shape.
  18. */
  19. const apiKey = process.env.DEEPSEEK_API_KEY
  20. const maybe = apiKey !== undefined && apiKey.length > 0 ? describe : describe.skip
  21. maybe('DeepSeekSearchProvider real API', () => {
  22. it.skip('returns citeable sources for a live query via native web_search', async () => {
  23. const provider = searchProvider({
  24. apiKey: apiKey!,
  25. baseURL: process.env.DEEPSEEK_SEARCH_BASE_URL ?? DEEPSEEK_DEFAULT_BASE_URL,
  26. model: process.env.DEEPSEEK_SEARCH_MODEL ?? DEEPSEEK_DEFAULT_MODEL,
  27. apiVersion: DEEPSEEK_DEFAULT_API_VERSION,
  28. maxTokens: DEEPSEEK_DEFAULT_MAX_TOKENS,
  29. maxUses: DEEPSEEK_DEFAULT_MAX_USES,
  30. })
  31. const result = await provider.search({ query: 'What is DeepSeek Harness?', maxResults: 5 })
  32. expect(result.sources.length).toBeGreaterThan(0)
  33. for (const source of result.sources) expect(source.url).toMatch(/^https?:\/\//)
  34. }, 60_000)
  35. })