@xsai-ext/providers 0.4.0-beta.9 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/anthropic-Bel15KQV.d.ts +111 -0
- package/dist/create.d.ts +201 -208
- package/dist/create.js +2 -42
- package/dist/index.d.ts +327 -237
- package/dist/index.js +51 -40
- package/dist/player2-D788vRq_.js +47 -0
- package/dist/special/create.d.ts +66 -0
- package/dist/special/create.js +37 -0
- package/dist/special/index.d.ts +12 -0
- package/dist/special/index.js +6 -0
- package/dist/{together-ai-DXREpfi4.js → together-ai-CzFuvpt-.js} +106 -59
- package/dist/types-Czo87gCh.d.ts +7 -0
- package/dist/types-DW1hvH0W.d.ts +38 -0
- package/dist/utils/index.d.ts +52 -0
- package/dist/utils/index.js +37 -0
- package/package.json +16 -4
- package/dist/openrouter-DCc0QhRt.d.ts +0 -104
package/dist/index.js
CHANGED
|
@@ -1,63 +1,74 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
|
-
import { c as
|
|
3
|
-
import '
|
|
2
|
+
import { c as createAlibaba, a as createAlibabaCn, b as createBailing, d as createBaseten, e as createCerebras, f as createChutes, g as createCortecs, h as createDeepinfra, i as createDeepSeek, j as createFastrouter, k as createFireworks, l as createGithubCopilot, m as createGithubModels, n as createGoogleGenerativeAI, o as createGroq, p as createHelicone, q as createHuggingface, r as createIflowcn, s as createInception, t as createInference, u as createIoNet, v as createKimiForCoding, w as createLlama, x as createLmstudio, y as createLucidquery, z as createMinimax, A as createMinimaxCn, B as createMistral, C as createModelscope, D as createMoonshotai, E as createMoonshotaiCn, F as createMorph, G as createNebius, H as createNvidia, I as createOllamaCloud, J as createOpenAI, K as createOpencode, L as createOvhcloud, M as createPerplexity, N as createPoe, O as createRequesty, P as createScaleway, Q as createSiliconFlow, R as createSiliconflowCn, S as createSubmodel, T as createSynthetic, U as createUpstage, V as createVenice, W as createVultr, X as createWandb, Y as createXai, Z as createXiaomi, _ as createZai, $ as createZaiCodingPlan, a0 as createZenmux, a1 as createZhipuai, a2 as createZhipuaiCodingPlan, a3 as createNovita, a4 as createStepfun, a5 as createTencentHunyuan, a6 as createOllama, a7 as createLitellm, a8 as createAnthropic, a9 as createFeatherless, aa as createOpenRouter, ab as createTogetherAI } from './together-ai-CzFuvpt-.js';
|
|
3
|
+
import './utils/index.js';
|
|
4
4
|
import '@xsai/shared';
|
|
5
5
|
|
|
6
|
-
const moonshotaiCn = createMoonshotaiCn(process.env.MOONSHOT_API_KEY ?? "");
|
|
7
|
-
const lucidquery = createLucidquery(process.env.LUCIDQUERY_API_KEY ?? "");
|
|
8
|
-
const moonshotai = createMoonshotai(process.env.MOONSHOT_API_KEY ?? "");
|
|
9
|
-
const zaiCodingPlan = createZaiCodingPlan(process.env.ZHIPU_API_KEY ?? "");
|
|
10
6
|
const alibaba = createAlibaba(process.env.DASHSCOPE_API_KEY ?? "");
|
|
11
|
-
const xai = createXai(process.env.XAI_API_KEY ?? "");
|
|
12
|
-
const vultr = createVultr(process.env.VULTR_API_KEY ?? "");
|
|
13
|
-
const nvidia = createNvidia(process.env.NVIDIA_API_KEY ?? "");
|
|
14
|
-
const upstage = createUpstage(process.env.UPSTAGE_API_KEY ?? "");
|
|
15
|
-
const groq = createGroq(process.env.GROQ_API_KEY ?? "");
|
|
16
|
-
const githubCopilot = createGithubCopilot(process.env.GITHUB_TOKEN ?? "");
|
|
17
|
-
const mistral = createMistral(process.env.MISTRAL_API_KEY ?? "");
|
|
18
|
-
const nebius = createNebius(process.env.NEBIUS_API_KEY ?? "");
|
|
19
|
-
const deepseek = createDeepSeek(process.env.DEEPSEEK_API_KEY ?? "");
|
|
20
7
|
const alibabaCn = createAlibabaCn(process.env.DASHSCOPE_API_KEY ?? "");
|
|
21
|
-
const
|
|
8
|
+
const bailing = createBailing(process.env.BAILING_API_TOKEN ?? "");
|
|
9
|
+
const baseten = createBaseten(process.env.BASETEN_API_KEY ?? "");
|
|
10
|
+
const cerebras = createCerebras(process.env.CEREBRAS_API_KEY ?? "");
|
|
22
11
|
const chutes = createChutes(process.env.CHUTES_API_KEY ?? "");
|
|
23
12
|
const cortecs = createCortecs(process.env.CORTECS_API_KEY ?? "");
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const huggingface = createHuggingface(process.env.HF_TOKEN ?? "");
|
|
27
|
-
const opencode = createOpencode(process.env.OPENCODE_API_KEY ?? "");
|
|
13
|
+
const deepinfra = createDeepinfra(process.env.DEEPINFRA_API_KEY ?? "");
|
|
14
|
+
const deepseek = createDeepSeek(process.env.DEEPSEEK_API_KEY ?? "");
|
|
28
15
|
const fastrouter = createFastrouter(process.env.FASTROUTER_API_KEY ?? "");
|
|
16
|
+
const fireworks = createFireworks(process.env.FIREWORKS_API_KEY ?? "");
|
|
17
|
+
const githubCopilot = createGithubCopilot(process.env.GITHUB_TOKEN ?? "");
|
|
18
|
+
const githubModels = createGithubModels(process.env.GITHUB_TOKEN ?? "");
|
|
29
19
|
const google = createGoogleGenerativeAI(process.env.GOOGLE_GENERATIVE_AI_API_KEY ?? process.env.GEMINI_API_KEY ?? "");
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const zhipuaiCodingPlan = createZhipuaiCodingPlan(process.env.ZHIPU_API_KEY ?? "");
|
|
34
|
-
const perplexity = createPerplexity(process.env.PERPLEXITY_API_KEY ?? "");
|
|
35
|
-
const zenmux = createZenmux(process.env.ZENMUX_API_KEY ?? "");
|
|
20
|
+
const groq = createGroq(process.env.GROQ_API_KEY ?? "");
|
|
21
|
+
const helicone = createHelicone(process.env.HELICONE_API_KEY ?? "");
|
|
22
|
+
const huggingface = createHuggingface(process.env.HF_TOKEN ?? "");
|
|
36
23
|
const iflowcn = createIflowcn(process.env.IFLOW_API_KEY ?? "");
|
|
37
|
-
const
|
|
38
|
-
const deepinfra = createDeepinfra(process.env.DEEPINFRA_API_KEY ?? "");
|
|
39
|
-
const zhipuai = createZhipuai(process.env.ZHIPU_API_KEY ?? "");
|
|
40
|
-
const submodel = createSubmodel(process.env.SUBMODEL_INSTAGEN_ACCESS_KEY ?? "");
|
|
41
|
-
const zai = createZai(process.env.ZHIPU_API_KEY ?? "");
|
|
24
|
+
const inception = createInception(process.env.INCEPTION_API_KEY ?? "");
|
|
42
25
|
const inference = createInference(process.env.INFERENCE_API_KEY ?? "");
|
|
43
|
-
const
|
|
44
|
-
const
|
|
26
|
+
const ioNet = createIoNet(process.env.IOINTELLIGENCE_API_KEY ?? "");
|
|
27
|
+
const kimiForCoding = createKimiForCoding(process.env.KIMI_API_KEY ?? "");
|
|
28
|
+
const llama = createLlama(process.env.LLAMA_API_KEY ?? "");
|
|
45
29
|
const lmstudio = createLmstudio(process.env.LMSTUDIO_API_KEY ?? "");
|
|
46
|
-
const
|
|
30
|
+
const lucidquery = createLucidquery(process.env.LUCIDQUERY_API_KEY ?? "");
|
|
31
|
+
const minimax = createMinimax(process.env.MINIMAX_API_KEY ?? "");
|
|
32
|
+
const minimaxCn = createMinimaxCn(process.env.MINIMAX_API_KEY ?? "");
|
|
33
|
+
const mistral = createMistral(process.env.MISTRAL_API_KEY ?? "");
|
|
47
34
|
const modelscope = createModelscope(process.env.MODELSCOPE_API_KEY ?? "");
|
|
48
|
-
const
|
|
35
|
+
const moonshotai = createMoonshotai(process.env.MOONSHOT_API_KEY ?? "");
|
|
36
|
+
const moonshotaiCn = createMoonshotaiCn(process.env.MOONSHOT_API_KEY ?? "");
|
|
37
|
+
const morph = createMorph(process.env.MORPH_API_KEY ?? "");
|
|
38
|
+
const nebius = createNebius(process.env.NEBIUS_API_KEY ?? "");
|
|
39
|
+
const nvidia = createNvidia(process.env.NVIDIA_API_KEY ?? "");
|
|
40
|
+
const ollamaCloud = createOllamaCloud(process.env.OLLAMA_API_KEY ?? "");
|
|
41
|
+
const openai = createOpenAI(process.env.OPENAI_API_KEY ?? "");
|
|
42
|
+
const opencode = createOpencode(process.env.OPENCODE_API_KEY ?? "");
|
|
43
|
+
const ovhcloud = createOvhcloud(process.env.OVHCLOUD_API_KEY ?? "");
|
|
44
|
+
const perplexity = createPerplexity(process.env.PERPLEXITY_API_KEY ?? "");
|
|
45
|
+
const poe = createPoe(process.env.POE_API_KEY ?? "");
|
|
46
|
+
const requesty = createRequesty(process.env.REQUESTY_API_KEY ?? "");
|
|
49
47
|
const scaleway = createScaleway(process.env.SCALEWAY_API_KEY ?? "");
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
48
|
+
const siliconflow = createSiliconFlow(process.env.SILICONFLOW_API_KEY ?? "");
|
|
49
|
+
const siliconflowCn = createSiliconflowCn(process.env.SILICONFLOW_API_KEY ?? "");
|
|
50
|
+
const submodel = createSubmodel(process.env.SUBMODEL_INSTAGEN_ACCESS_KEY ?? "");
|
|
51
|
+
const synthetic = createSynthetic(process.env.SYNTHETIC_API_KEY ?? "");
|
|
52
|
+
const upstage = createUpstage(process.env.UPSTAGE_API_KEY ?? "");
|
|
53
|
+
const venice = createVenice(process.env.VENICE_API_KEY ?? "");
|
|
54
|
+
const vultr = createVultr(process.env.VULTR_API_KEY ?? "");
|
|
55
|
+
const wandb = createWandb(process.env.WANDB_API_KEY ?? "");
|
|
56
|
+
const xai = createXai(process.env.XAI_API_KEY ?? "");
|
|
57
|
+
const xiaomi = createXiaomi(process.env.XIAOMI_API_KEY ?? "");
|
|
58
|
+
const zai = createZai(process.env.ZHIPU_API_KEY ?? "");
|
|
59
|
+
const zaiCodingPlan = createZaiCodingPlan(process.env.ZHIPU_API_KEY ?? "");
|
|
60
|
+
const zenmux = createZenmux(process.env.ZENMUX_API_KEY ?? "");
|
|
61
|
+
const zhipuai = createZhipuai(process.env.ZHIPU_API_KEY ?? "");
|
|
62
|
+
const zhipuaiCodingPlan = createZhipuaiCodingPlan(process.env.ZHIPU_API_KEY ?? "");
|
|
53
63
|
const novita = createNovita(process.env.NOVITA_API_KEY ?? "");
|
|
54
|
-
const siliconFlow = createSiliconFlow(process.env.SILICON_FLOW_API_KEY ?? "");
|
|
55
64
|
const stepfun = createStepfun(process.env.STEPFUN_API_KEY ?? "");
|
|
56
65
|
const tencentHunyuan = createTencentHunyuan(process.env.TENCENT_HUNYUAN_API_KEY ?? "");
|
|
66
|
+
const ollama = createOllama(process.env.OLLAMA_API_KEY ?? "");
|
|
67
|
+
const litellm = createLitellm(process.env.LITELLM_API_KEY ?? "");
|
|
57
68
|
|
|
58
69
|
const anthropic = createAnthropic(process.env.ANTHROPIC_API_KEY ?? "");
|
|
59
70
|
const featherless = createFeatherless(process.env.FEATHERLESS_API_KEY ?? "");
|
|
60
71
|
const openrouter = createOpenRouter(process.env.OPENROUTER_API_KEY ?? "");
|
|
61
72
|
const togetherai = createTogetherAI(process.env.TOGETHER_API_KEY ?? "");
|
|
62
73
|
|
|
63
|
-
export { alibaba, alibabaCn, anthropic, baseten, cerebras, chutes, cortecs, deepinfra, deepseek, fastrouter, featherless, fireworks, githubCopilot, githubModels, google, groq, huggingface, iflowcn, inception, inference, llama, lmstudio, lucidquery, minimax,
|
|
74
|
+
export { alibaba, alibabaCn, anthropic, bailing, baseten, cerebras, chutes, cortecs, deepinfra, deepseek, fastrouter, featherless, fireworks, githubCopilot, githubModels, google, groq, helicone, huggingface, iflowcn, inception, inference, ioNet, kimiForCoding, litellm, llama, lmstudio, lucidquery, minimax, minimaxCn, mistral, modelscope, moonshotai, moonshotaiCn, morph, nebius, novita, nvidia, ollama, ollamaCloud, openai, opencode, openrouter, ovhcloud, perplexity, poe, requesty, scaleway, siliconflow, siliconflowCn, stepfun, submodel, synthetic, tencentHunyuan, togetherai, upstage, venice, vultr, wandb, xai, xiaomi, zai, zaiCodingPlan, zenmux, zhipuai, zhipuaiCodingPlan };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { merge, createSpeechProvider, createChatProvider } from './utils/index.js';
|
|
2
|
+
|
|
3
|
+
const createPlayer2 = (baseURL = "http://localhost:4315/v1/", gameKey = "xsai") => merge(
|
|
4
|
+
createChatProvider({ baseURL, headers: { "player2-game-key": gameKey } }),
|
|
5
|
+
createSpeechProvider({
|
|
6
|
+
baseURL,
|
|
7
|
+
fetch: async (input, reqInit) => {
|
|
8
|
+
const newUrl = `${input.toString().slice(0, -"audio/speech".length)}tts/speak`;
|
|
9
|
+
try {
|
|
10
|
+
const { input: input2, response_format, speed, voice, ...rest } = JSON.parse(reqInit?.body);
|
|
11
|
+
const modified = {
|
|
12
|
+
audio_format: response_format,
|
|
13
|
+
play_in_app: false,
|
|
14
|
+
speed: speed ?? 1,
|
|
15
|
+
text: input2,
|
|
16
|
+
voice_ids: voice != null ? [voice] : [],
|
|
17
|
+
...rest
|
|
18
|
+
};
|
|
19
|
+
if (reqInit) {
|
|
20
|
+
reqInit.body = JSON.stringify(modified);
|
|
21
|
+
}
|
|
22
|
+
} catch (err) {
|
|
23
|
+
console.warn("Could not parse body as JSON:", err);
|
|
24
|
+
}
|
|
25
|
+
return globalThis.fetch(newUrl, reqInit).then(async (res) => res.json()).then((json) => {
|
|
26
|
+
const base64 = json.data ?? "";
|
|
27
|
+
const bytes = Uint8Array.fromBase64(base64);
|
|
28
|
+
const body = new ReadableStream({
|
|
29
|
+
start: (controller) => {
|
|
30
|
+
controller.enqueue(bytes);
|
|
31
|
+
controller.close();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return new Response(body, {
|
|
35
|
+
headers: {
|
|
36
|
+
"Content-Type": "audio/mpeg"
|
|
37
|
+
// adjust if needed
|
|
38
|
+
},
|
|
39
|
+
status: 200
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
headers: { "player2-game-key": gameKey }
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export { createPlayer2 as c };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { S as SpeechProvider, C as ChatProvider, E as EmbedProvider, T as TranscriptionProvider, M as ModelProvider } from '../types-DW1hvH0W.js';
|
|
2
|
+
import { a as AzureModels, C as CloudflareWorkersAiModels } from '../types-Czo87gCh.js';
|
|
3
|
+
import '@xsai/shared';
|
|
4
|
+
|
|
5
|
+
interface CreateAzureOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The static API key or AD access token fetcher for authorization.
|
|
8
|
+
*
|
|
9
|
+
* If passed in as a function, it is treated as an accessTokenFetcher.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link https://learn.microsoft.com/en-us/azure/api-management/api-management-authenticate-authorize-azure-openai}
|
|
12
|
+
*/
|
|
13
|
+
apiKey: (() => Promise<string> | string) | string;
|
|
14
|
+
/**
|
|
15
|
+
* The Azure API version to use (`api-version` param).
|
|
16
|
+
*
|
|
17
|
+
* Notice: Different deployment over different time may have different API versions, please
|
|
18
|
+
* follow the exact prompt from either [Azure AI Foundry](https://ai.azure.com/) or Azure OpenAI service
|
|
19
|
+
* to get the correct API version from the Azure OpenAI Service endpoint.
|
|
20
|
+
*
|
|
21
|
+
* On Azure AI Foundry portal, you can go to https://ai.azure.com/build/overview > Choose the project >
|
|
22
|
+
* Overview > Endpoints and keys > Included capabilities > Azure OpenAI Service to get the correct endpoint.
|
|
23
|
+
*
|
|
24
|
+
* @see {@link https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#rest-api-versioning}
|
|
25
|
+
*/
|
|
26
|
+
apiVersion?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Azure resource name.
|
|
29
|
+
*
|
|
30
|
+
* On Azure AI Foundry portal, you can go to https://ai.azure.com/build/overview > Choose the project >
|
|
31
|
+
* Overview > Endpoints and keys > Included capabilities > Azure OpenAI Service to get the correct endpoint.
|
|
32
|
+
*
|
|
33
|
+
* @see {@link https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#uri-parameters}
|
|
34
|
+
*/
|
|
35
|
+
resourceName: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a Azure Provider
|
|
39
|
+
* @see {@link https://ai.azure.com/explore/models}
|
|
40
|
+
* @see {@link https://learn.microsoft.com/en-us/azure/ai-foundry/model-inference/concepts/endpoints?tabs=rest#routing}
|
|
41
|
+
* @remarks
|
|
42
|
+
* For Azure AI services, you can have multiple deployments of the same model with different names.
|
|
43
|
+
*
|
|
44
|
+
* Please pass your deployment name as the `model` parameter. By default, Azure will use the model name
|
|
45
|
+
* as the deployment name when deploying a model.
|
|
46
|
+
*/
|
|
47
|
+
declare const createAzure: (options: CreateAzureOptions) => Promise<SpeechProvider<string> & ChatProvider<AzureModels> & EmbedProvider<string> & TranscriptionProvider<string> & ModelProvider>;
|
|
48
|
+
|
|
49
|
+
declare global {
|
|
50
|
+
interface Uint8ArrayConstructor {
|
|
51
|
+
fromBase64: (base64: string) => Uint8Array;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a Player2 Provider
|
|
56
|
+
* @see {@link https://player2.game}
|
|
57
|
+
*/
|
|
58
|
+
declare const createPlayer2: (baseURL?: string, gameKey?: string) => ChatProvider<string> & SpeechProvider<string>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Create a Workers AI Provider
|
|
62
|
+
* @see {@link https://developers.cloudflare.com/workers-ai}
|
|
63
|
+
*/
|
|
64
|
+
declare const createWorkersAI: (apiKey: string, accountId: string) => EmbedProvider<string> & ChatProvider<CloudflareWorkersAiModels>;
|
|
65
|
+
|
|
66
|
+
export { createAzure, createPlayer2, createWorkersAI };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { merge, createModelProvider, createTranscriptionProvider, createSpeechProvider, createEmbedProvider, createChatProvider } from '../utils/index.js';
|
|
2
|
+
export { c as createPlayer2 } from '../player2-D788vRq_.js';
|
|
3
|
+
|
|
4
|
+
const createAzure = async (options) => {
|
|
5
|
+
const headers = typeof options.apiKey === "string" ? { "api-key": options.apiKey } : void 0;
|
|
6
|
+
const baseURL = `https://${options.resourceName}.services.ai.azure.com/models/`;
|
|
7
|
+
const fetch = async (input, init) => {
|
|
8
|
+
if (options.apiVersion != null)
|
|
9
|
+
input.searchParams.set("api-version", options.apiVersion);
|
|
10
|
+
const token = `Bearer ${typeof options.apiKey === "function" ? await options.apiKey() : options.apiKey}`;
|
|
11
|
+
init.headers ??= {};
|
|
12
|
+
if (Array.isArray(init.headers))
|
|
13
|
+
init.headers.push(["Authorization", token]);
|
|
14
|
+
else if (init.headers instanceof Headers)
|
|
15
|
+
init.headers.append("Authorization", token);
|
|
16
|
+
else
|
|
17
|
+
init.headers.Authorization = token;
|
|
18
|
+
return globalThis.fetch(input, init);
|
|
19
|
+
};
|
|
20
|
+
return merge(
|
|
21
|
+
createChatProvider({ baseURL, fetch, headers }),
|
|
22
|
+
createEmbedProvider({ baseURL, fetch, headers }),
|
|
23
|
+
createSpeechProvider({ baseURL, fetch, headers }),
|
|
24
|
+
createTranscriptionProvider({ baseURL, fetch, headers }),
|
|
25
|
+
createModelProvider({ baseURL, fetch, headers })
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const createWorkersAI = (apiKey, accountId) => {
|
|
30
|
+
const baseURL = `https://api.cloudflare.com/client/v4/accounts/${accountId}/ai/v1/`;
|
|
31
|
+
return merge(
|
|
32
|
+
createChatProvider({ apiKey, baseURL }),
|
|
33
|
+
createEmbedProvider({ apiKey, baseURL })
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { createAzure, createWorkersAI };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { C as ChatProvider, S as SpeechProvider } from '../types-DW1hvH0W.js';
|
|
2
|
+
import '@xsai/shared';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Create a Player2 Provider
|
|
6
|
+
* @see {@link https://player2.game}
|
|
7
|
+
* @remarks
|
|
8
|
+
* - baseURL - `http://localhost:4315/v1/`
|
|
9
|
+
*/
|
|
10
|
+
declare const player2: ChatProvider<string> & SpeechProvider<string>;
|
|
11
|
+
|
|
12
|
+
export { player2 };
|