qwen.js 0.1.5 → 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 +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -0
- package/dist/types.d.ts +12 -1
- package/package.json +1 -1
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
|
@@ -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:
|
|
19
|
+
content: MessageContent | null;
|
|
9
20
|
tool_calls?: ToolCall[];
|
|
10
21
|
tool_call_id?: string;
|
|
11
22
|
}
|