perplexity.e2e.ts 1.1 KB

1234567891011121314151617181920212223
  1. import { describe, expect, it } from 'vitest'
  2. import { PerplexitySearchProvider, PERPLEXITY_DEFAULT_BASE_URL, PERPLEXITY_DEFAULT_MAX_TOKENS, PERPLEXITY_DEFAULT_MODEL } from '@deepseek-ai/dsh-web-search-perplexity'
  3. /**
  4. * Real-API smoke for the Perplexity search provider. Self-skips without
  5. * `$PERPLEXITY_API_KEY`, per the with-key e2e policy in docs/testing.md.
  6. */
  7. const apiKey = process.env.PERPLEXITY_API_KEY
  8. const maybe = apiKey !== undefined && apiKey.length > 0 ? describe : describe.skip
  9. maybe('PerplexitySearchProvider real API', () => {
  10. it('returns a generated answer and sources for a live query', async () => {
  11. const provider = new PerplexitySearchProvider({
  12. apiKey: apiKey!,
  13. baseURL: process.env.PERPLEXITY_BASE_URL ?? PERPLEXITY_DEFAULT_BASE_URL,
  14. model: process.env.PERPLEXITY_MODEL ?? PERPLEXITY_DEFAULT_MODEL,
  15. maxTokens: PERPLEXITY_DEFAULT_MAX_TOKENS,
  16. })
  17. const result = await provider.search({ query: 'What is DeepSeek Harness?', maxResults: 5 })
  18. expect(result.content ?? '').not.toBe('')
  19. for (const source of result.sources) expect(source.url).toMatch(/^https?:\/\//)
  20. }, 30_000)
  21. })