@untiny/qwen-ai-provider 0.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## 0.0.1
2
+
3
+ ### Initialize
4
+
5
+ 初始化项目
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # AI SDK - Qwen Provider
2
+
3
+ The Qwen provider for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the Qwen chat API.
4
+
5
+ ## Setup
6
+
7
+ The Qwen provider is available in the `@untiny/qwen-ai-provider` module. You can install it with
8
+
9
+ ```bash
10
+ npm i @untiny/qwen-ai-provider
11
+ ```
12
+
13
+ ## Provider Instance
14
+
15
+ You can import the default provider instance `qwen` from `@untiny/qwen-ai-provider`:
16
+
17
+ ```ts
18
+ import { qwen } from '@untiny/qwen-ai-provider';
19
+ ```
20
+
21
+ ## Example
22
+
23
+ ```ts
24
+ import { qwen } from '@untiny/qwen-ai-provider';
25
+ import { generateText, embed } from 'ai';
26
+
27
+ const { text } = await generateText({
28
+ model: qwen('qwen-plus'),
29
+ prompt: 'Write a vegetarian lasagna recipe for 4 people.',
30
+ });
31
+
32
+ const { embedding } = await embed({
33
+ model: qwen.embeddingModel('text-embedding-v4'),
34
+ value: 'sunny day at the beach',
35
+ });
36
+ ```
37
+
38
+ ## Documentation
39
+
40
+ Please check out the Qwen provider for more information.
@@ -0,0 +1,69 @@
1
+ import { ProviderV3, LanguageModelV3, EmbeddingModelV3, ImageModelV3 } from '@ai-sdk/provider';
2
+ import { FetchFunction } from '@ai-sdk/provider-utils';
3
+
4
+ type QwenChatModeId = 'qwen3-max' | 'qwen-plus' | 'qwen-plus-latest' | 'qwen-flash' | 'qwen-turbo' | 'qwen-turbo-latest' | 'qwq-plus' | 'qwq-plus-latest' | 'qwen-long' | 'qwen-long-latest' | 'qwen3-omni-flash' | 'qwen3-omni-flash-realtime' | 'qvq-max' | 'qvq-max-latest' | 'qwen3-vl-plus' | 'qwen3-vl-flash' | 'qwen-vl-ocr' | 'qwen-vl-ocr-latest' | 'qwen-audio-turbo' | 'qwen-audio-turbo-latest' | 'qwen-math-plus' | 'qwen-math-turbo' | 'qwen3-coder-plus' | 'qwen-mt-plus' | 'qwen-deep-research' | 'deepseek-v3.2' | (string & {});
5
+
6
+ type QwenCompletionModelId = 'qwen2.5-coder-0.5b-instruct' | 'qwen2.5-coder-1.5b-instruct' | 'qwen2.5-coder-3b-instruct' | 'qwen2.5-coder-7b-instruct' | 'qwen2.5-coder-14b-instruct' | 'qwen2.5-coder-32b-instruct' | 'qwen-coder-turbo-0919' | 'qwen-coder-turbo-latest' | 'qwen-coder-turbo' | (string & {});
7
+
8
+ type QwenEmbeddingModelId = 'text-embedding-v4' | (string & {});
9
+
10
+ interface QwenProvider extends ProviderV3 {
11
+ (modelId: QwenChatModeId): LanguageModelV3;
12
+ /**
13
+ * 创建文本生成模型。
14
+ * @param modelId 用于文本生成的模型 ID。
15
+ */
16
+ languageModel(modelId: QwenChatModeId): LanguageModelV3;
17
+ /**
18
+ * 创建文本生成模型。
19
+ * @param modelId 用于文本生成的模型 ID。
20
+ */
21
+ chat(modelId: QwenChatModeId): LanguageModelV3;
22
+ completion(modelId: QwenCompletionModelId): LanguageModelV3;
23
+ /**
24
+ * 创建文本嵌入模型。
25
+ * @param modelId 用于文本嵌入的模型 ID。
26
+ */
27
+ embedding(modelId: QwenEmbeddingModelId): EmbeddingModelV3;
28
+ /**
29
+ * 创建文本嵌入模型。
30
+ * @param modelId 用于文本嵌入的模型 ID。
31
+ */
32
+ embeddingModel: (modelId: QwenEmbeddingModelId) => EmbeddingModelV3;
33
+ /**
34
+ * @deprecated Use `embedding` instead.
35
+ */
36
+ textEmbedding(modelId: QwenEmbeddingModelId): EmbeddingModelV3;
37
+ /**
38
+ * @deprecated Use `embeddingModel` instead.
39
+ */
40
+ textEmbeddingModel(modelId: QwenEmbeddingModelId): EmbeddingModelV3;
41
+ imageModel(modelId: string): ImageModelV3;
42
+ }
43
+ interface QwenProviderSettings {
44
+ /**
45
+ * 对 API 调用使用不同的 URL 前缀,例如使用代理服务器。
46
+ * 默认前缀是"https://dashscope.aliyuncs.com/compatible-mode/v1"。
47
+ */
48
+ baseURL?: string;
49
+ /**
50
+ * 使用“Authorization”标头发送的 API 密钥。
51
+ * 它默认为“DASHSCOPE_API_KEY”环境变量。
52
+ */
53
+ apiKey?: string;
54
+ /**
55
+ * 要包含在请求中的自定义标头。
56
+ */
57
+ headers?: Record<string, string>;
58
+ /**
59
+ * 自定义获取实现。您可以将其用作拦截请求的中间件,或者提供自定义的获取实现,例如测试。
60
+ */
61
+ fetch?: FetchFunction;
62
+ }
63
+ /** 创建 Qwen AI 提供程序实例。 */
64
+ declare function createQwen(options?: QwenProviderSettings): QwenProvider;
65
+ declare const qwen: QwenProvider;
66
+
67
+ declare const VERSION: string;
68
+
69
+ export { type QwenProvider, type QwenProviderSettings, VERSION, createQwen, qwen };
@@ -0,0 +1,69 @@
1
+ import { ProviderV3, LanguageModelV3, EmbeddingModelV3, ImageModelV3 } from '@ai-sdk/provider';
2
+ import { FetchFunction } from '@ai-sdk/provider-utils';
3
+
4
+ type QwenChatModeId = 'qwen3-max' | 'qwen-plus' | 'qwen-plus-latest' | 'qwen-flash' | 'qwen-turbo' | 'qwen-turbo-latest' | 'qwq-plus' | 'qwq-plus-latest' | 'qwen-long' | 'qwen-long-latest' | 'qwen3-omni-flash' | 'qwen3-omni-flash-realtime' | 'qvq-max' | 'qvq-max-latest' | 'qwen3-vl-plus' | 'qwen3-vl-flash' | 'qwen-vl-ocr' | 'qwen-vl-ocr-latest' | 'qwen-audio-turbo' | 'qwen-audio-turbo-latest' | 'qwen-math-plus' | 'qwen-math-turbo' | 'qwen3-coder-plus' | 'qwen-mt-plus' | 'qwen-deep-research' | 'deepseek-v3.2' | (string & {});
5
+
6
+ type QwenCompletionModelId = 'qwen2.5-coder-0.5b-instruct' | 'qwen2.5-coder-1.5b-instruct' | 'qwen2.5-coder-3b-instruct' | 'qwen2.5-coder-7b-instruct' | 'qwen2.5-coder-14b-instruct' | 'qwen2.5-coder-32b-instruct' | 'qwen-coder-turbo-0919' | 'qwen-coder-turbo-latest' | 'qwen-coder-turbo' | (string & {});
7
+
8
+ type QwenEmbeddingModelId = 'text-embedding-v4' | (string & {});
9
+
10
+ interface QwenProvider extends ProviderV3 {
11
+ (modelId: QwenChatModeId): LanguageModelV3;
12
+ /**
13
+ * 创建文本生成模型。
14
+ * @param modelId 用于文本生成的模型 ID。
15
+ */
16
+ languageModel(modelId: QwenChatModeId): LanguageModelV3;
17
+ /**
18
+ * 创建文本生成模型。
19
+ * @param modelId 用于文本生成的模型 ID。
20
+ */
21
+ chat(modelId: QwenChatModeId): LanguageModelV3;
22
+ completion(modelId: QwenCompletionModelId): LanguageModelV3;
23
+ /**
24
+ * 创建文本嵌入模型。
25
+ * @param modelId 用于文本嵌入的模型 ID。
26
+ */
27
+ embedding(modelId: QwenEmbeddingModelId): EmbeddingModelV3;
28
+ /**
29
+ * 创建文本嵌入模型。
30
+ * @param modelId 用于文本嵌入的模型 ID。
31
+ */
32
+ embeddingModel: (modelId: QwenEmbeddingModelId) => EmbeddingModelV3;
33
+ /**
34
+ * @deprecated Use `embedding` instead.
35
+ */
36
+ textEmbedding(modelId: QwenEmbeddingModelId): EmbeddingModelV3;
37
+ /**
38
+ * @deprecated Use `embeddingModel` instead.
39
+ */
40
+ textEmbeddingModel(modelId: QwenEmbeddingModelId): EmbeddingModelV3;
41
+ imageModel(modelId: string): ImageModelV3;
42
+ }
43
+ interface QwenProviderSettings {
44
+ /**
45
+ * 对 API 调用使用不同的 URL 前缀,例如使用代理服务器。
46
+ * 默认前缀是"https://dashscope.aliyuncs.com/compatible-mode/v1"。
47
+ */
48
+ baseURL?: string;
49
+ /**
50
+ * 使用“Authorization”标头发送的 API 密钥。
51
+ * 它默认为“DASHSCOPE_API_KEY”环境变量。
52
+ */
53
+ apiKey?: string;
54
+ /**
55
+ * 要包含在请求中的自定义标头。
56
+ */
57
+ headers?: Record<string, string>;
58
+ /**
59
+ * 自定义获取实现。您可以将其用作拦截请求的中间件,或者提供自定义的获取实现,例如测试。
60
+ */
61
+ fetch?: FetchFunction;
62
+ }
63
+ /** 创建 Qwen AI 提供程序实例。 */
64
+ declare function createQwen(options?: QwenProviderSettings): QwenProvider;
65
+ declare const qwen: QwenProvider;
66
+
67
+ declare const VERSION: string;
68
+
69
+ export { type QwenProvider, type QwenProviderSettings, VERSION, createQwen, qwen };