@aigne/openai 0.4.3 → 0.6.0
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 +32 -0
- package/README.md +6 -4
- package/README.zh.md +6 -4
- package/lib/cjs/openai-chat-model.d.ts +5 -1
- package/lib/cjs/openai-chat-model.js +1 -0
- package/lib/dts/openai-chat-model.d.ts +5 -1
- package/lib/esm/openai-chat-model.d.ts +5 -1
- package/lib/esm/openai-chat-model.js +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.0](https://github.com/AIGNE-io/aigne-framework/compare/openai-v0.5.0...openai-v0.6.0) (2025-07-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **example:** use AIGNE cli to run chat-bot example ([#198](https://github.com/AIGNE-io/aigne-framework/issues/198)) ([7085541](https://github.com/AIGNE-io/aigne-framework/commit/708554100692f2a557f7329ea78e46c3c870ce10))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @aigne/core bumped to 1.28.0
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @aigne/test-utils bumped to 0.4.12
|
|
18
|
+
|
|
19
|
+
## [0.5.0](https://github.com/AIGNE-io/aigne-framework/compare/openai-v0.4.3...openai-v0.5.0) (2025-07-01)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* **cli:** support HTTPS_PROXY and named path param ([#196](https://github.com/AIGNE-io/aigne-framework/issues/196)) ([04e684e](https://github.com/AIGNE-io/aigne-framework/commit/04e684ee26bc2d79924b0e3cb541cd07a7191804))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Dependencies
|
|
28
|
+
|
|
29
|
+
* The following workspace dependencies were updated
|
|
30
|
+
* dependencies
|
|
31
|
+
* @aigne/core bumped to 1.27.0
|
|
32
|
+
* devDependencies
|
|
33
|
+
* @aigne/test-utils bumped to 0.4.11
|
|
34
|
+
|
|
3
35
|
## [0.4.3](https://github.com/AIGNE-io/aigne-framework/compare/openai-v0.4.2...openai-v0.4.3) (2025-06-30)
|
|
4
36
|
|
|
5
37
|
|
package/README.md
CHANGED
|
@@ -79,6 +79,7 @@ console.log(result);
|
|
|
79
79
|
## Streaming Responses
|
|
80
80
|
|
|
81
81
|
```typescript file="test/openai-chat-model.test.ts" region="example-openai-chat-model-stream"
|
|
82
|
+
import { isAgentResponseDelta } from "@aigne/core";
|
|
82
83
|
import { OpenAIChatModel } from "@aigne/openai";
|
|
83
84
|
|
|
84
85
|
const model = new OpenAIChatModel({
|
|
@@ -90,7 +91,6 @@ const stream = await model.invoke(
|
|
|
90
91
|
{
|
|
91
92
|
messages: [{ role: "user", content: "Hello, who are you?" }],
|
|
92
93
|
},
|
|
93
|
-
undefined,
|
|
94
94
|
{ streaming: true },
|
|
95
95
|
);
|
|
96
96
|
|
|
@@ -98,9 +98,11 @@ let fullText = "";
|
|
|
98
98
|
const json = {};
|
|
99
99
|
|
|
100
100
|
for await (const chunk of stream) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
if (isAgentResponseDelta(chunk)) {
|
|
102
|
+
const text = chunk.delta.text?.text;
|
|
103
|
+
if (text) fullText += text;
|
|
104
|
+
if (chunk.delta.json) Object.assign(json, chunk.delta.json);
|
|
105
|
+
}
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
console.log(fullText); // Output: "Hello! How can I assist you today?"
|
package/README.zh.md
CHANGED
|
@@ -79,6 +79,7 @@ console.log(result);
|
|
|
79
79
|
## 流式响应
|
|
80
80
|
|
|
81
81
|
```typescript file="test/openai-chat-model.test.ts" region="example-openai-chat-model-stream"
|
|
82
|
+
import { isAgentResponseDelta } from "@aigne/core";
|
|
82
83
|
import { OpenAIChatModel } from "@aigne/openai";
|
|
83
84
|
|
|
84
85
|
const model = new OpenAIChatModel({
|
|
@@ -90,7 +91,6 @@ const stream = await model.invoke(
|
|
|
90
91
|
{
|
|
91
92
|
messages: [{ role: "user", content: "Hello, who are you?" }],
|
|
92
93
|
},
|
|
93
|
-
undefined,
|
|
94
94
|
{ streaming: true },
|
|
95
95
|
);
|
|
96
96
|
|
|
@@ -98,9 +98,11 @@ let fullText = "";
|
|
|
98
98
|
const json = {};
|
|
99
99
|
|
|
100
100
|
for await (const chunk of stream) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
if (isAgentResponseDelta(chunk)) {
|
|
102
|
+
const text = chunk.delta.text?.text;
|
|
103
|
+
if (text) fullText += text;
|
|
104
|
+
if (chunk.delta.json) Object.assign(json, chunk.delta.json);
|
|
105
|
+
}
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
console.log(fullText); // Output: "Hello! How can I assist you today?"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelInputMessage, type ChatModelInputTool, type ChatModelOptions, type ChatModelOutput, type Role } from "@aigne/core";
|
|
2
2
|
import { type PromiseOrValue } from "@aigne/core/utils/type-utils.js";
|
|
3
|
-
import OpenAI from "openai";
|
|
3
|
+
import OpenAI, { type ClientOptions } from "openai";
|
|
4
4
|
import type { ChatCompletionMessageParam, ChatCompletionTool } from "openai/resources";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
export interface OpenAIChatModelCapabilities {
|
|
@@ -38,6 +38,10 @@ export interface OpenAIChatModelOptions {
|
|
|
38
38
|
* Additional model options to control behavior
|
|
39
39
|
*/
|
|
40
40
|
modelOptions?: ChatModelOptions;
|
|
41
|
+
/**
|
|
42
|
+
* Client options for OpenAI API
|
|
43
|
+
*/
|
|
44
|
+
clientOptions?: Partial<ClientOptions>;
|
|
41
45
|
}
|
|
42
46
|
/**
|
|
43
47
|
* @hidden
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelInputMessage, type ChatModelInputTool, type ChatModelOptions, type ChatModelOutput, type Role } from "@aigne/core";
|
|
2
2
|
import { type PromiseOrValue } from "@aigne/core/utils/type-utils.js";
|
|
3
|
-
import OpenAI from "openai";
|
|
3
|
+
import OpenAI, { type ClientOptions } from "openai";
|
|
4
4
|
import type { ChatCompletionMessageParam, ChatCompletionTool } from "openai/resources";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
export interface OpenAIChatModelCapabilities {
|
|
@@ -38,6 +38,10 @@ export interface OpenAIChatModelOptions {
|
|
|
38
38
|
* Additional model options to control behavior
|
|
39
39
|
*/
|
|
40
40
|
modelOptions?: ChatModelOptions;
|
|
41
|
+
/**
|
|
42
|
+
* Client options for OpenAI API
|
|
43
|
+
*/
|
|
44
|
+
clientOptions?: Partial<ClientOptions>;
|
|
41
45
|
}
|
|
42
46
|
/**
|
|
43
47
|
* @hidden
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelInputMessage, type ChatModelInputTool, type ChatModelOptions, type ChatModelOutput, type Role } from "@aigne/core";
|
|
2
2
|
import { type PromiseOrValue } from "@aigne/core/utils/type-utils.js";
|
|
3
|
-
import OpenAI from "openai";
|
|
3
|
+
import OpenAI, { type ClientOptions } from "openai";
|
|
4
4
|
import type { ChatCompletionMessageParam, ChatCompletionTool } from "openai/resources";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
export interface OpenAIChatModelCapabilities {
|
|
@@ -38,6 +38,10 @@ export interface OpenAIChatModelOptions {
|
|
|
38
38
|
* Additional model options to control behavior
|
|
39
39
|
*/
|
|
40
40
|
modelOptions?: ChatModelOptions;
|
|
41
|
+
/**
|
|
42
|
+
* Client options for OpenAI API
|
|
43
|
+
*/
|
|
44
|
+
clientOptions?: Partial<ClientOptions>;
|
|
41
45
|
}
|
|
42
46
|
/**
|
|
43
47
|
* @hidden
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/openai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "AIGNE OpenAI SDK for integrating with OpenAI's GPT models and API services",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"nanoid": "^5.1.5",
|
|
36
36
|
"openai": "^4.87.3",
|
|
37
37
|
"zod": "^3.24.4",
|
|
38
|
-
"@aigne/core": "^1.
|
|
38
|
+
"@aigne/core": "^1.28.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/bun": "^1.2.12",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"npm-run-all": "^4.1.5",
|
|
44
44
|
"rimraf": "^6.0.1",
|
|
45
45
|
"typescript": "^5.8.3",
|
|
46
|
-
"@aigne/test-utils": "^0.4.
|
|
46
|
+
"@aigne/test-utils": "^0.4.12"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"lint": "tsc --noEmit",
|