@cobrowser/chatgpt 0.7.19 → 0.7.21
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ChatGptResponse from '../../models/ChatGptResponse';
|
|
2
2
|
import BaseService from '../BaseService/BaseService';
|
|
3
|
+
import { AssistantResponseFormatOption } from 'openai/resources/beta/threads/threads';
|
|
3
4
|
export declare class AssistantService extends BaseService {
|
|
4
5
|
assistantId: string | undefined;
|
|
5
6
|
threadId: string | undefined;
|
|
@@ -20,5 +21,6 @@ export declare class AssistantService extends BaseService {
|
|
|
20
21
|
instructions?: string;
|
|
21
22
|
tools?: any[];
|
|
22
23
|
functionOutputs?: string;
|
|
24
|
+
definedSchema?: AssistantResponseFormatOption;
|
|
23
25
|
}): Promise<ChatGptResponse | undefined>;
|
|
24
26
|
}
|
|
@@ -58,12 +58,13 @@ class AssistantService extends BaseService_1.default {
|
|
|
58
58
|
* @param message
|
|
59
59
|
*/
|
|
60
60
|
getReply(message, runOptions = {}) {
|
|
61
|
-
var _a;
|
|
61
|
+
var _a, _b;
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
63
|
if (!this.assistantId || !this.threadId) {
|
|
64
64
|
logger_1.default.error('Assistant and Thread are required');
|
|
65
65
|
return Promise.reject(new Error('Assistant and Thread are required'));
|
|
66
66
|
}
|
|
67
|
+
logger_1.default.info(`New run with message: ${message} & options: ${JSON.stringify(runOptions)}`);
|
|
67
68
|
const openai = new openai_1.default({ apiKey: this.openaiApiKey });
|
|
68
69
|
let run;
|
|
69
70
|
if (runOptions.functionOutputs && this.runId) {
|
|
@@ -81,6 +82,7 @@ class AssistantService extends BaseService_1.default {
|
|
|
81
82
|
run = yield openai.beta.threads.runs.create(this.threadId, {
|
|
82
83
|
assistant_id: (_a = this.assistantId) !== null && _a !== void 0 ? _a : '',
|
|
83
84
|
additional_instructions: runOptions.instructions,
|
|
85
|
+
response_format: (_b = runOptions.definedSchema) !== null && _b !== void 0 ? _b : { type: 'text' },
|
|
84
86
|
tools: runOptions.tools
|
|
85
87
|
});
|
|
86
88
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobrowser/chatgpt",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.21",
|
|
4
4
|
"description": "chatgpt services to connect our projects with chatgpt api",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chatgpt",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@cobrowser/logger": "^2.0.2",
|
|
25
25
|
"axios": "^1.6.1",
|
|
26
26
|
"axios-mock-adapter": "^1.22.0",
|
|
27
|
-
"openai": "^4.
|
|
27
|
+
"openai": "^4.86.2"
|
|
28
28
|
},
|
|
29
29
|
"directories": {
|
|
30
30
|
"dist": "dist"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"bugs": {
|
|
40
40
|
"url": "https://bitbucket.org/cobrowser/cb_utils/issues"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "3a426ebc382c861be00fdef6455b611075436ece"
|
|
43
43
|
}
|