qwen.js 0.1.4 → 0.1.6

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/client.d.ts CHANGED
@@ -17,6 +17,7 @@ export declare class QwenClient {
17
17
  chat(messages: ChatMessage[], options?: ChatOptions): Promise<ChatResponse>;
18
18
  chatStream(messages: ChatMessage[] | string, options?: ChatOptions): AsyncGenerator<string, void, unknown>;
19
19
  ask(prompt: string, options?: ChatOptions): Promise<string>;
20
+ createImageMessage(text: string, imageUrls: string[]): ChatMessage;
20
21
  setModel(model: string): void;
21
22
  getModel(): string;
22
23
  createToolResult(toolCallId: string, content: string): ChatMessage;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { QwenClient } from "./client";
2
2
  export { generatePKCE, requestDeviceCode, pollForToken, refreshAccessToken, isTokenExpired, } from "./auth";
3
- export type { QwenConfig, ChatMessage, ChatOptions, ChatResponse, ChatSession, StreamChunk, TokenState, DeviceCodeResponse, TokenResponse, PKCEPair, Tool, ToolCall, ToolResult, } from "./types";
3
+ export type { QwenConfig, ChatMessage, ChatOptions, ChatResponse, ChatSession, StreamChunk, TokenState, DeviceCodeResponse, TokenResponse, PKCEPair, Tool, ToolCall, ToolResult, ImageContent, TextContent, MessageContent, } from "./types";
4
4
  import { QwenClient } from "./client";
5
5
  export declare function createQwen(config?: {
6
6
  accessToken?: string;
package/dist/index.js CHANGED
@@ -79,7 +79,7 @@ function isTokenExpired(state) {
79
79
 
80
80
  // src/client.ts
81
81
  var API_BASE = "https://portal.qwen.ai/v1";
82
- var DEFAULT_MODEL = "qwen-plus";
82
+ var DEFAULT_MODEL = "coder-model";
83
83
  var TOKEN_LIFETIME_MS = 6 * 60 * 60 * 1000;
84
84
 
85
85
  class QwenClient {
@@ -243,6 +243,19 @@ ${url}
243
243
  }
244
244
  return result;
245
245
  }
246
+ createImageMessage(text, imageUrls) {
247
+ const content = [
248
+ { type: "text", text },
249
+ ...imageUrls.map((url) => ({
250
+ type: "image_url",
251
+ image_url: { url }
252
+ }))
253
+ ];
254
+ return {
255
+ role: "user",
256
+ content
257
+ };
258
+ }
246
259
  setModel(model) {
247
260
  this.model = model;
248
261
  }
package/dist/types.d.ts CHANGED
@@ -3,9 +3,20 @@ export interface QwenConfig {
3
3
  refreshToken?: string;
4
4
  model?: string;
5
5
  }
6
+ export interface ImageContent {
7
+ type: "image_url";
8
+ image_url: {
9
+ url: string;
10
+ };
11
+ }
12
+ export interface TextContent {
13
+ type: "text";
14
+ text: string;
15
+ }
16
+ export type MessageContent = string | (TextContent | ImageContent)[];
6
17
  export interface ChatMessage {
7
18
  role: "system" | "user" | "assistant" | "tool";
8
- content: string | null;
19
+ content: MessageContent | null;
9
20
  tool_calls?: ToolCall[];
10
21
  tool_call_id?: string;
11
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qwen.js",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Elegant TypeScript SDK for Qwen AI API with OAuth/PKCE authentication",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/readme.md CHANGED
@@ -123,7 +123,7 @@ const qwen2 = createQwen({
123
123
  |--------|------|-------------|
124
124
  | `accessToken` | `string` | Pre-existing access token |
125
125
  | `refreshToken` | `string` | Pre-existing refresh token |
126
- | `model` | `string` | Default model (default: `qwen-plus`) |
126
+ | `model` | `string` | Default model (default: `coder-model`) |
127
127
 
128
128
  ### Methods
129
129