Skip to content
Source
Sign inSign up
TanStack/schemas

feat(providers): add dashscope adapter #18

Mergedtombeckenhammerged 1 commit intomain fromrefs/pull/18/headmerged by tombeckenham View on GitHub

Showing 2 changed files with 184 additions and 0 deletions.

x
0 of 2 viewed, 2 left
119 additions and 0 deletionssrc/server/providers/adapters/dashscope.test.tsAdded
View file
@@ -0,0 +1,119 @@
+import { describe, expect, it } from 'vitest'
+​
+import { OPENAI_OPENAPI_URL } from '../openai-compat.ts'
+import { provider } from './dashscope.ts'
+​
+const OPENAI_FIXTURE = JSON.stringify({
+ openapi: '3.1.0',
+ info: { title: 'OpenAI API', version: '2.3.0' },
+ servers: [{ url: 'https://api.openai.com/v1' }],
+ paths: {
+ '/chat/completions': { post: { operationId: 'createChatCompletion' } },
+ '/embeddings': { post: { operationId: 'createEmbedding' } },
+ '/images/generations': { post: { operationId: 'createImage' } },
+ '/audio/speech': { post: { operationId: 'createSpeech' } },
+ '/audio/transcriptions': { post: { operationId: 'createTranscription' } },
+ '/files': { get: { operationId: 'listFiles' } },
+ },
+})
+​
+function withStubbedFetch<T>(
+ handler: (url: string, init?: RequestInit) => Response,
+ run: () => Promise<T>,
+): Promise<{ result: T; calls: Array<{ url: string; auth: string | null }> }> {
+ const original = globalThis.fetch
+ const calls: Array<{ url: string; auth: string | null }> = []
+ globalThis.fetch = ((url: string, init?: RequestInit) => {
+ calls.push({