mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 23:59:02 +02:00
chore(deps): update dependency openai to v6 (#7155)
This commit is contained in:
commit
3a84a78cd1
@ -110,7 +110,7 @@
|
|||||||
"multer": "2.0.2",
|
"multer": "2.0.2",
|
||||||
"normalize-strings": "1.1.1",
|
"normalize-strings": "1.1.1",
|
||||||
"ollama": "0.6.0",
|
"ollama": "0.6.0",
|
||||||
"openai": "5.12.0",
|
"openai": "6.0.0",
|
||||||
"rand-token": "1.0.1",
|
"rand-token": "1.0.1",
|
||||||
"safe-compare": "1.1.4",
|
"safe-compare": "1.1.4",
|
||||||
"sanitize-filename": "1.6.3",
|
"sanitize-filename": "1.6.3",
|
||||||
|
@ -5,6 +5,7 @@ import { getOpenAIOptions } from './providers.js';
|
|||||||
import OpenAI from 'openai';
|
import OpenAI from 'openai';
|
||||||
import { PROVIDER_PROMPTS } from '../constants/llm_prompt_constants.js';
|
import { PROVIDER_PROMPTS } from '../constants/llm_prompt_constants.js';
|
||||||
import log from '../../log.js';
|
import log from '../../log.js';
|
||||||
|
import { ChatCompletionMessageFunctionToolCall } from 'openai/resources/index.mjs';
|
||||||
|
|
||||||
export class OpenAIService extends BaseAIService {
|
export class OpenAIService extends BaseAIService {
|
||||||
private openai: OpenAI | null = null;
|
private openai: OpenAI | null = null;
|
||||||
@ -42,10 +43,10 @@ export class OpenAIService extends BaseAIService {
|
|||||||
|
|
||||||
// Get base system prompt
|
// Get base system prompt
|
||||||
let systemPrompt = this.getSystemPrompt(providerOptions.systemPrompt || options.getOption('aiSystemPrompt'));
|
let systemPrompt = this.getSystemPrompt(providerOptions.systemPrompt || options.getOption('aiSystemPrompt'));
|
||||||
|
|
||||||
// Check if tools are enabled for this request
|
// Check if tools are enabled for this request
|
||||||
const willUseTools = providerOptions.enableTools && providerOptions.tools && providerOptions.tools.length > 0;
|
const willUseTools = providerOptions.enableTools && providerOptions.tools && providerOptions.tools.length > 0;
|
||||||
|
|
||||||
// Add tool instructions to system prompt if tools are enabled
|
// Add tool instructions to system prompt if tools are enabled
|
||||||
if (willUseTools && PROVIDER_PROMPTS.OPENAI.TOOL_INSTRUCTIONS) {
|
if (willUseTools && PROVIDER_PROMPTS.OPENAI.TOOL_INSTRUCTIONS) {
|
||||||
log.info('Adding tool instructions to system prompt for OpenAI');
|
log.info('Adding tool instructions to system prompt for OpenAI');
|
||||||
@ -101,7 +102,7 @@ export class OpenAIService extends BaseAIService {
|
|||||||
log.info('OpenAI API Stream Started');
|
log.info('OpenAI API Stream Started');
|
||||||
|
|
||||||
// Create a closure to hold accumulated tool calls
|
// Create a closure to hold accumulated tool calls
|
||||||
const accumulatedToolCalls: OpenAI.Chat.ChatCompletionMessageToolCall[] = [];
|
const accumulatedToolCalls: OpenAI.Chat.ChatCompletionMessageFunctionToolCall[] = [];
|
||||||
|
|
||||||
// Return a response with the stream handler
|
// Return a response with the stream handler
|
||||||
const response: ChatResponse = {
|
const response: ChatResponse = {
|
||||||
@ -201,7 +202,7 @@ export class OpenAIService extends BaseAIService {
|
|||||||
completeText = content;
|
completeText = content;
|
||||||
|
|
||||||
// Check if there are tool calls in the non-stream response
|
// Check if there are tool calls in the non-stream response
|
||||||
const toolCalls = stream.choices[0]?.message?.tool_calls;
|
const toolCalls = stream.choices[0]?.message?.tool_calls as ChatCompletionMessageFunctionToolCall[];
|
||||||
if (toolCalls) {
|
if (toolCalls) {
|
||||||
response.tool_calls = toolCalls;
|
response.tool_calls = toolCalls;
|
||||||
console.log('OpenAI API Tool Calls in Non-iterable Response:', JSON.stringify(toolCalls, null, 2));
|
console.log('OpenAI API Tool Calls in Non-iterable Response:', JSON.stringify(toolCalls, null, 2));
|
||||||
@ -251,7 +252,7 @@ export class OpenAIService extends BaseAIService {
|
|||||||
completionTokens: completion.usage?.completion_tokens,
|
completionTokens: completion.usage?.completion_tokens,
|
||||||
totalTokens: completion.usage?.total_tokens
|
totalTokens: completion.usage?.total_tokens
|
||||||
},
|
},
|
||||||
tool_calls: completion.choices[0].message.tool_calls
|
tool_calls: completion.choices[0].message.tool_calls as ChatCompletionMessageFunctionToolCall[]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
16
pnpm-lock.yaml
generated
16
pnpm-lock.yaml
generated
@ -694,8 +694,8 @@ importers:
|
|||||||
specifier: 0.6.0
|
specifier: 0.6.0
|
||||||
version: 0.6.0
|
version: 0.6.0
|
||||||
openai:
|
openai:
|
||||||
specifier: 5.12.0
|
specifier: 6.0.0
|
||||||
version: 5.12.0(ws@8.18.3(bufferutil@4.0.9)(utf-8-validate@6.0.5))
|
version: 6.0.0(ws@8.18.3(bufferutil@4.0.9)(utf-8-validate@6.0.5))
|
||||||
rand-token:
|
rand-token:
|
||||||
specifier: 1.0.1
|
specifier: 1.0.1
|
||||||
version: 1.0.1
|
version: 1.0.1
|
||||||
@ -10289,12 +10289,12 @@ packages:
|
|||||||
resolution: {integrity: sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA==}
|
resolution: {integrity: sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
|
|
||||||
openai@5.12.0:
|
openai@6.0.0:
|
||||||
resolution: {integrity: sha512-vUdt02xiWgOHiYUmW0Hj1Qu9OKAiVQu5Bd547ktVCiMKC1BkB5L3ImeEnCyq3WpRKR6ZTaPgekzqdozwdPs7Lg==}
|
resolution: {integrity: sha512-J7LEmTn3WLZnbyEmMYcMPyT5A0fGzhPwSvVUcNRKy6j2hJIbqSFrJERnUHYNkcoCCalRumypnj9AVoe5bVHd3Q==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
ws: ^8.18.0
|
ws: ^8.18.0
|
||||||
zod: ^3.23.8
|
zod: ^3.25 || ^4.0
|
||||||
peerDependenciesMeta:
|
peerDependenciesMeta:
|
||||||
ws:
|
ws:
|
||||||
optional: true
|
optional: true
|
||||||
@ -14944,8 +14944,6 @@ snapshots:
|
|||||||
'@ckeditor/ckeditor5-utils': 46.1.1
|
'@ckeditor/ckeditor5-utils': 46.1.1
|
||||||
'@ckeditor/ckeditor5-watchdog': 46.1.1
|
'@ckeditor/ckeditor5-watchdog': 46.1.1
|
||||||
es-toolkit: 1.39.5
|
es-toolkit: 1.39.5
|
||||||
transitivePeerDependencies:
|
|
||||||
- supports-color
|
|
||||||
|
|
||||||
'@ckeditor/ckeditor5-dev-build-tools@43.1.0(@swc/helpers@0.5.17)(tslib@2.8.1)(typescript@5.9.3)':
|
'@ckeditor/ckeditor5-dev-build-tools@43.1.0(@swc/helpers@0.5.17)(tslib@2.8.1)(typescript@5.9.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -21241,6 +21239,8 @@ snapshots:
|
|||||||
ckeditor5-collaboration@46.1.1:
|
ckeditor5-collaboration@46.1.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@ckeditor/ckeditor5-collaboration-core': 46.1.1
|
'@ckeditor/ckeditor5-collaboration-core': 46.1.1
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- supports-color
|
||||||
|
|
||||||
ckeditor5-premium-features@46.1.1(bufferutil@4.0.9)(ckeditor5@46.1.1(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41))(utf-8-validate@6.0.5):
|
ckeditor5-premium-features@46.1.1(bufferutil@4.0.9)(ckeditor5@46.1.1(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41))(utf-8-validate@6.0.5):
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -26474,7 +26474,7 @@ snapshots:
|
|||||||
is-inside-container: 1.0.0
|
is-inside-container: 1.0.0
|
||||||
wsl-utils: 0.1.0
|
wsl-utils: 0.1.0
|
||||||
|
|
||||||
openai@5.12.0(ws@8.18.3(bufferutil@4.0.9)(utf-8-validate@6.0.5)):
|
openai@6.0.0(ws@8.18.3(bufferutil@4.0.9)(utf-8-validate@6.0.5)):
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
ws: 8.18.3(bufferutil@4.0.9)(utf-8-validate@6.0.5)
|
ws: 8.18.3(bufferutil@4.0.9)(utf-8-validate@6.0.5)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user