@amux.ai/adapter-qwen 0.1.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.
@@ -0,0 +1,189 @@
1
+ import { LLMAdapter, ToolCall, JSONSchema } from '@amux.ai/llm-bridge';
2
+
3
+ /**
4
+ * Qwen (通义千问) adapter implementation
5
+ * Handles Qwen-specific features like enable_thinking, enable_search, and multimodal
6
+ */
7
+ declare const qwenAdapter: LLMAdapter;
8
+
9
+ /**
10
+ * Qwen message content part types
11
+ * Extended from OpenAI with audio and video support
12
+ */
13
+ type QwenContentPart = {
14
+ type: 'text';
15
+ text: string;
16
+ } | {
17
+ type: 'image_url';
18
+ image_url: {
19
+ url: string;
20
+ detail?: 'auto' | 'low' | 'high';
21
+ };
22
+ } | {
23
+ type: 'input_audio';
24
+ input_audio: {
25
+ data: string;
26
+ format: 'mp3' | 'wav' | 'pcm';
27
+ };
28
+ } | {
29
+ type: 'video';
30
+ video: string[];
31
+ } | {
32
+ type: 'video_url';
33
+ video_url: {
34
+ url: string;
35
+ };
36
+ };
37
+ /**
38
+ * Qwen message format
39
+ * Extended from OpenAI with reasoning_content support
40
+ */
41
+ interface QwenMessage {
42
+ role: 'system' | 'user' | 'assistant' | 'tool';
43
+ content?: string | QwenContentPart[] | null;
44
+ name?: string;
45
+ tool_calls?: ToolCall[];
46
+ tool_call_id?: string;
47
+ /**
48
+ * Qwen-specific: Reasoning content (for QwQ model)
49
+ */
50
+ reasoning_content?: string;
51
+ }
52
+ /**
53
+ * Qwen tool format (same as OpenAI)
54
+ */
55
+ interface QwenTool {
56
+ type: 'function';
57
+ function: {
58
+ name: string;
59
+ description?: string;
60
+ parameters?: JSONSchema;
61
+ strict?: boolean;
62
+ };
63
+ }
64
+ /**
65
+ * Qwen response format configuration
66
+ */
67
+ interface QwenResponseFormat {
68
+ type: 'text' | 'json_object';
69
+ }
70
+ /**
71
+ * Qwen stream options
72
+ */
73
+ interface QwenStreamOptions {
74
+ include_usage?: boolean;
75
+ }
76
+ /**
77
+ * Qwen request format
78
+ * Based on OpenAI with Qwen-specific extensions
79
+ */
80
+ interface QwenRequest {
81
+ model: string;
82
+ messages: QwenMessage[];
83
+ tools?: QwenTool[];
84
+ tool_choice?: 'auto' | 'none' | 'required' | {
85
+ type: 'function';
86
+ function: {
87
+ name: string;
88
+ };
89
+ };
90
+ stream?: boolean;
91
+ stream_options?: QwenStreamOptions;
92
+ temperature?: number;
93
+ top_p?: number;
94
+ max_tokens?: number;
95
+ stop?: string | string[];
96
+ presence_penalty?: number;
97
+ frequency_penalty?: number;
98
+ response_format?: QwenResponseFormat;
99
+ seed?: number;
100
+ /**
101
+ * Qwen-specific: Enable deep thinking mode (for QwQ model)
102
+ */
103
+ enable_thinking?: boolean;
104
+ /**
105
+ * Qwen-specific: Enable web search
106
+ */
107
+ enable_search?: boolean;
108
+ /**
109
+ * Qwen-specific: Video frame rate for video input
110
+ */
111
+ fps?: number;
112
+ }
113
+ /**
114
+ * Qwen response usage
115
+ */
116
+ interface QwenUsage {
117
+ prompt_tokens: number;
118
+ completion_tokens: number;
119
+ total_tokens: number;
120
+ }
121
+ /**
122
+ * Qwen response format
123
+ */
124
+ interface QwenResponse {
125
+ id: string;
126
+ object: string;
127
+ created: number;
128
+ model: string;
129
+ system_fingerprint?: string;
130
+ choices: Array<{
131
+ index: number;
132
+ message: {
133
+ role: string;
134
+ content: string | null;
135
+ tool_calls?: ToolCall[];
136
+ /**
137
+ * Qwen-specific: Reasoning content
138
+ */
139
+ reasoning_content?: string;
140
+ };
141
+ finish_reason: string;
142
+ }>;
143
+ usage?: QwenUsage;
144
+ }
145
+ /**
146
+ * Qwen stream chunk format
147
+ */
148
+ interface QwenStreamChunk {
149
+ id: string;
150
+ object: string;
151
+ created: number;
152
+ model: string;
153
+ system_fingerprint?: string;
154
+ choices: Array<{
155
+ index: number;
156
+ delta: {
157
+ role?: string;
158
+ content?: string;
159
+ tool_calls?: Array<{
160
+ index: number;
161
+ id?: string;
162
+ type?: string;
163
+ function?: {
164
+ name?: string;
165
+ arguments?: string;
166
+ };
167
+ }>;
168
+ /**
169
+ * Qwen-specific: Reasoning content delta
170
+ */
171
+ reasoning_content?: string;
172
+ };
173
+ finish_reason?: string | null;
174
+ }>;
175
+ usage?: QwenUsage;
176
+ }
177
+ /**
178
+ * Qwen error format
179
+ */
180
+ interface QwenError {
181
+ error: {
182
+ message: string;
183
+ type: string;
184
+ param?: string;
185
+ code?: string;
186
+ };
187
+ }
188
+
189
+ export { type QwenContentPart, type QwenError, type QwenMessage, type QwenRequest, type QwenResponse, type QwenResponseFormat, type QwenStreamChunk, type QwenStreamOptions, type QwenTool, type QwenUsage, qwenAdapter };
@@ -0,0 +1,189 @@
1
+ import { LLMAdapter, ToolCall, JSONSchema } from '@amux.ai/llm-bridge';
2
+
3
+ /**
4
+ * Qwen (通义千问) adapter implementation
5
+ * Handles Qwen-specific features like enable_thinking, enable_search, and multimodal
6
+ */
7
+ declare const qwenAdapter: LLMAdapter;
8
+
9
+ /**
10
+ * Qwen message content part types
11
+ * Extended from OpenAI with audio and video support
12
+ */
13
+ type QwenContentPart = {
14
+ type: 'text';
15
+ text: string;
16
+ } | {
17
+ type: 'image_url';
18
+ image_url: {
19
+ url: string;
20
+ detail?: 'auto' | 'low' | 'high';
21
+ };
22
+ } | {
23
+ type: 'input_audio';
24
+ input_audio: {
25
+ data: string;
26
+ format: 'mp3' | 'wav' | 'pcm';
27
+ };
28
+ } | {
29
+ type: 'video';
30
+ video: string[];
31
+ } | {
32
+ type: 'video_url';
33
+ video_url: {
34
+ url: string;
35
+ };
36
+ };
37
+ /**
38
+ * Qwen message format
39
+ * Extended from OpenAI with reasoning_content support
40
+ */
41
+ interface QwenMessage {
42
+ role: 'system' | 'user' | 'assistant' | 'tool';
43
+ content?: string | QwenContentPart[] | null;
44
+ name?: string;
45
+ tool_calls?: ToolCall[];
46
+ tool_call_id?: string;
47
+ /**
48
+ * Qwen-specific: Reasoning content (for QwQ model)
49
+ */
50
+ reasoning_content?: string;
51
+ }
52
+ /**
53
+ * Qwen tool format (same as OpenAI)
54
+ */
55
+ interface QwenTool {
56
+ type: 'function';
57
+ function: {
58
+ name: string;
59
+ description?: string;
60
+ parameters?: JSONSchema;
61
+ strict?: boolean;
62
+ };
63
+ }
64
+ /**
65
+ * Qwen response format configuration
66
+ */
67
+ interface QwenResponseFormat {
68
+ type: 'text' | 'json_object';
69
+ }
70
+ /**
71
+ * Qwen stream options
72
+ */
73
+ interface QwenStreamOptions {
74
+ include_usage?: boolean;
75
+ }
76
+ /**
77
+ * Qwen request format
78
+ * Based on OpenAI with Qwen-specific extensions
79
+ */
80
+ interface QwenRequest {
81
+ model: string;
82
+ messages: QwenMessage[];
83
+ tools?: QwenTool[];
84
+ tool_choice?: 'auto' | 'none' | 'required' | {
85
+ type: 'function';
86
+ function: {
87
+ name: string;
88
+ };
89
+ };
90
+ stream?: boolean;
91
+ stream_options?: QwenStreamOptions;
92
+ temperature?: number;
93
+ top_p?: number;
94
+ max_tokens?: number;
95
+ stop?: string | string[];
96
+ presence_penalty?: number;
97
+ frequency_penalty?: number;
98
+ response_format?: QwenResponseFormat;
99
+ seed?: number;
100
+ /**
101
+ * Qwen-specific: Enable deep thinking mode (for QwQ model)
102
+ */
103
+ enable_thinking?: boolean;
104
+ /**
105
+ * Qwen-specific: Enable web search
106
+ */
107
+ enable_search?: boolean;
108
+ /**
109
+ * Qwen-specific: Video frame rate for video input
110
+ */
111
+ fps?: number;
112
+ }
113
+ /**
114
+ * Qwen response usage
115
+ */
116
+ interface QwenUsage {
117
+ prompt_tokens: number;
118
+ completion_tokens: number;
119
+ total_tokens: number;
120
+ }
121
+ /**
122
+ * Qwen response format
123
+ */
124
+ interface QwenResponse {
125
+ id: string;
126
+ object: string;
127
+ created: number;
128
+ model: string;
129
+ system_fingerprint?: string;
130
+ choices: Array<{
131
+ index: number;
132
+ message: {
133
+ role: string;
134
+ content: string | null;
135
+ tool_calls?: ToolCall[];
136
+ /**
137
+ * Qwen-specific: Reasoning content
138
+ */
139
+ reasoning_content?: string;
140
+ };
141
+ finish_reason: string;
142
+ }>;
143
+ usage?: QwenUsage;
144
+ }
145
+ /**
146
+ * Qwen stream chunk format
147
+ */
148
+ interface QwenStreamChunk {
149
+ id: string;
150
+ object: string;
151
+ created: number;
152
+ model: string;
153
+ system_fingerprint?: string;
154
+ choices: Array<{
155
+ index: number;
156
+ delta: {
157
+ role?: string;
158
+ content?: string;
159
+ tool_calls?: Array<{
160
+ index: number;
161
+ id?: string;
162
+ type?: string;
163
+ function?: {
164
+ name?: string;
165
+ arguments?: string;
166
+ };
167
+ }>;
168
+ /**
169
+ * Qwen-specific: Reasoning content delta
170
+ */
171
+ reasoning_content?: string;
172
+ };
173
+ finish_reason?: string | null;
174
+ }>;
175
+ usage?: QwenUsage;
176
+ }
177
+ /**
178
+ * Qwen error format
179
+ */
180
+ interface QwenError {
181
+ error: {
182
+ message: string;
183
+ type: string;
184
+ param?: string;
185
+ code?: string;
186
+ };
187
+ }
188
+
189
+ export { type QwenContentPart, type QwenError, type QwenMessage, type QwenRequest, type QwenResponse, type QwenResponseFormat, type QwenStreamChunk, type QwenStreamOptions, type QwenTool, type QwenUsage, qwenAdapter };