@promptbook/openai 0.102.0-2 → 0.102.0-4
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/esm/index.es.js +80 -39
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +15 -13
- package/esm/typings/src/_packages/types.index.d.ts +3 -3
- package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +14 -1
- package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +13 -0
- package/esm/typings/src/book-components/Chat/save/_common/getChatSaveFormatDefinitions.d.ts +8 -0
- package/esm/typings/src/book-components/Chat/save/_common/string_chat_format_name.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +12 -0
- package/esm/typings/src/book-components/Chat/save/index.d.ts +39 -0
- package/esm/typings/src/book-components/Chat/save/json/jsonSaveFormatDefinition.d.ts +12 -0
- package/esm/typings/src/book-components/Chat/save/markdown/mdSaveFormatDefinition.d.ts +12 -0
- package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +12 -0
- package/esm/typings/src/book-components/Chat/save/text/txtSaveFormatDefinition.d.ts +12 -0
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +31 -5
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +3 -3
- package/esm/typings/src/book-components/Chat/utils/exportChatHistory.d.ts +3 -0
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +4 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +80 -39
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-components/Chat/save/savePlugins.d.ts +0 -105
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
|
|
2
|
+
import { id } from '../../../types/typeAliases';
|
|
2
3
|
import type { ChatProps } from '../Chat/ChatProps';
|
|
4
|
+
import type { SendMessageToLlmChatFunction } from '../hooks/useSendMessageToLlmChat';
|
|
3
5
|
import type { ChatMessage } from '../types/ChatMessage';
|
|
4
6
|
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
5
|
-
import type { SendMessageToLlmChatFunction } from '../hooks/useSendMessageToLlmChat';
|
|
6
7
|
/**
|
|
7
8
|
* Props for LlmChat component, derived from ChatProps but with LLM-specific modifications
|
|
8
9
|
*
|
|
@@ -34,4 +35,16 @@ export type LlmChatProps = Omit<ChatProps, 'messages' | 'onMessage' | 'onChange'
|
|
|
34
35
|
* When provided, LlmChat will attach its internal handler to it (no React context needed).
|
|
35
36
|
*/
|
|
36
37
|
readonly sendMessage?: SendMessageToLlmChatFunction;
|
|
38
|
+
/**
|
|
39
|
+
* Name of the USER as participant in the chat
|
|
40
|
+
*
|
|
41
|
+
* @default 'USER'
|
|
42
|
+
*/
|
|
43
|
+
readonly userParticipantName?: id;
|
|
44
|
+
/**
|
|
45
|
+
* Name of the LLM as participant in the chat
|
|
46
|
+
*
|
|
47
|
+
* @default 'ASSISTANT'
|
|
48
|
+
*/
|
|
49
|
+
readonly llmParticipantName?: id;
|
|
37
50
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { string_file_extension, string_mime_type } from '../../../../types/typeAliases';
|
|
2
|
+
import type { ChatMessage } from '../../types/ChatMessage';
|
|
3
|
+
/**
|
|
4
|
+
* Plugin contract for chat export formatNames
|
|
5
|
+
* @public exported from `@promptbook/components`
|
|
6
|
+
*/
|
|
7
|
+
export type ChatSaveFormatDefinition = {
|
|
8
|
+
formatName: string_file_extension | string_mime_type | string;
|
|
9
|
+
label: string;
|
|
10
|
+
getContent: (messages: ChatMessage[]) => string;
|
|
11
|
+
mimeType: string;
|
|
12
|
+
fileExtension: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ChatSaveFormatDefinition } from './ChatSaveFormatDefinition';
|
|
2
|
+
import { string_chat_format_name } from './string_chat_format_name';
|
|
3
|
+
/**
|
|
4
|
+
* Returns enabled chat save plugins filtered by formatNames (or all when omitted)
|
|
5
|
+
*
|
|
6
|
+
* @public exported from `@promptbook/components`
|
|
7
|
+
*/
|
|
8
|
+
export declare function getChatSaveFormatDefinitions(formatNames?: ReadonlyArray<string_chat_format_name>): ReadonlyArray<ChatSaveFormatDefinition>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML export plugin
|
|
3
|
+
*
|
|
4
|
+
* @public exported from `@promptbook/components`
|
|
5
|
+
*/
|
|
6
|
+
export declare const htmlSaveFormatDefinition: {
|
|
7
|
+
readonly formatName: "html";
|
|
8
|
+
readonly label: "HTML";
|
|
9
|
+
readonly getContent: (messages: import("../../types/ChatMessage").ChatMessage[]) => string;
|
|
10
|
+
readonly mimeType: "text/html";
|
|
11
|
+
readonly fileExtension: "html";
|
|
12
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry of all built-in chat save plugins
|
|
3
|
+
*
|
|
4
|
+
* @public exported from `@promptbook/components`
|
|
5
|
+
*/
|
|
6
|
+
export declare const CHAT_SAVE_FORMATS: readonly [{
|
|
7
|
+
readonly formatName: "json";
|
|
8
|
+
readonly label: "JSON (full)";
|
|
9
|
+
readonly getContent: (messages: import("../types/ChatMessage").ChatMessage[]) => string;
|
|
10
|
+
readonly mimeType: "application/json";
|
|
11
|
+
readonly fileExtension: "json";
|
|
12
|
+
}, {
|
|
13
|
+
readonly formatName: "txt";
|
|
14
|
+
readonly label: "Plain Text";
|
|
15
|
+
readonly getContent: (messages: import("../types/ChatMessage").ChatMessage[]) => string;
|
|
16
|
+
readonly mimeType: "text/plain";
|
|
17
|
+
readonly fileExtension: "txt";
|
|
18
|
+
}, {
|
|
19
|
+
readonly formatName: "md";
|
|
20
|
+
readonly label: "Markdown";
|
|
21
|
+
readonly getContent: (messages: import("../types/ChatMessage").ChatMessage[]) => string;
|
|
22
|
+
readonly mimeType: "text/markdown";
|
|
23
|
+
readonly fileExtension: "md";
|
|
24
|
+
}, {
|
|
25
|
+
readonly formatName: "html";
|
|
26
|
+
readonly label: "HTML";
|
|
27
|
+
readonly getContent: (messages: import("../types/ChatMessage").ChatMessage[]) => string;
|
|
28
|
+
readonly mimeType: "text/html";
|
|
29
|
+
readonly fileExtension: "html";
|
|
30
|
+
}, {
|
|
31
|
+
readonly formatName: "pdf";
|
|
32
|
+
readonly label: "PDF";
|
|
33
|
+
readonly getContent: (messages: import("../types/ChatMessage").ChatMessage[]) => string;
|
|
34
|
+
readonly mimeType: "application/pdf";
|
|
35
|
+
readonly fileExtension: "pdf";
|
|
36
|
+
}];
|
|
37
|
+
/**
|
|
38
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
39
|
+
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON export plugin (full metadata)
|
|
3
|
+
*
|
|
4
|
+
* @public exported from `@promptbook/components`
|
|
5
|
+
*/
|
|
6
|
+
export declare const jsonSaveFormatDefinition: {
|
|
7
|
+
readonly formatName: "json";
|
|
8
|
+
readonly label: "JSON (full)";
|
|
9
|
+
readonly getContent: (messages: import("../../types/ChatMessage").ChatMessage[]) => string;
|
|
10
|
+
readonly mimeType: "application/json";
|
|
11
|
+
readonly fileExtension: "json";
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown export plugin
|
|
3
|
+
*
|
|
4
|
+
* @public exported from `@promptbook/components`
|
|
5
|
+
*/
|
|
6
|
+
export declare const mdSaveFormatDefinition: {
|
|
7
|
+
readonly formatName: "md";
|
|
8
|
+
readonly label: "Markdown";
|
|
9
|
+
readonly getContent: (messages: import("../../types/ChatMessage").ChatMessage[]) => string;
|
|
10
|
+
readonly mimeType: "text/markdown";
|
|
11
|
+
readonly fileExtension: "md";
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF export plugin
|
|
3
|
+
*
|
|
4
|
+
* @public exported from `@promptbook/components`
|
|
5
|
+
*/
|
|
6
|
+
export declare const pdfSaveFormatDefinition: {
|
|
7
|
+
readonly formatName: "pdf";
|
|
8
|
+
readonly label: "PDF";
|
|
9
|
+
readonly getContent: (messages: import("../../types/ChatMessage").ChatMessage[]) => string;
|
|
10
|
+
readonly mimeType: "application/pdf";
|
|
11
|
+
readonly fileExtension: "pdf";
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain text export plugin (messages only)
|
|
3
|
+
*
|
|
4
|
+
* @public exported from `@promptbook/components`
|
|
5
|
+
*/
|
|
6
|
+
export declare const txtSaveFormatDefinition: {
|
|
7
|
+
readonly formatName: "txt";
|
|
8
|
+
readonly label: "Plain Text";
|
|
9
|
+
readonly getContent: (messages: import("../../types/ChatMessage").ChatMessage[]) => string;
|
|
10
|
+
readonly mimeType: "text/plain";
|
|
11
|
+
readonly fileExtension: "txt";
|
|
12
|
+
};
|
|
@@ -1,16 +1,42 @@
|
|
|
1
|
-
import type { string_markdown } from '../../../types/typeAliases';
|
|
2
|
-
import type { string_name } from '../../../types/typeAliases';
|
|
1
|
+
import type { id, string_markdown } from '../../../types/typeAliases';
|
|
3
2
|
/**
|
|
4
3
|
* A message in the chat
|
|
5
4
|
*
|
|
6
5
|
* @public exported from `@promptbook/components`
|
|
7
6
|
*/
|
|
8
7
|
export type ChatMessage = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Unique identifier of the message
|
|
10
|
+
*/
|
|
11
|
+
id: id;
|
|
12
|
+
/**
|
|
13
|
+
* Date when the message was created
|
|
14
|
+
*/
|
|
15
|
+
date?: Date;
|
|
16
|
+
/**
|
|
17
|
+
* The name of the participant who sent the message
|
|
18
|
+
*/
|
|
19
|
+
from: id;
|
|
20
|
+
/**
|
|
21
|
+
* The content of the message with optional markdown formatting
|
|
22
|
+
*/
|
|
12
23
|
content: string_markdown;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the message is complete (for example, if it's still being generated by an AI)
|
|
26
|
+
*
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
13
29
|
isComplete?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @@@
|
|
32
|
+
*/
|
|
14
33
|
expectedAnswer?: string;
|
|
34
|
+
/**
|
|
35
|
+
* @@@
|
|
36
|
+
*/
|
|
15
37
|
isVoiceCall?: boolean;
|
|
16
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* TODO: Delete `expectedAnswer` from ChatMessage
|
|
41
|
+
* TODO: Rename `date` into `created`+`modified`
|
|
42
|
+
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { id, string_color, string_person_fullname, string_url_image } from '../../../types/typeAliases';
|
|
2
2
|
import { Color } from '../../../utils/color/Color';
|
|
3
3
|
/**
|
|
4
4
|
* A participant in the chat
|
|
@@ -9,11 +9,11 @@ export type ChatParticipant = {
|
|
|
9
9
|
/**
|
|
10
10
|
* Identifies the participant by their name, same as `message.from`
|
|
11
11
|
*/
|
|
12
|
-
name:
|
|
12
|
+
name: id;
|
|
13
13
|
/**
|
|
14
14
|
* Full name of the participant
|
|
15
15
|
*/
|
|
16
|
-
fullname
|
|
16
|
+
fullname?: string_person_fullname;
|
|
17
17
|
/**
|
|
18
18
|
* Am I the participant? (i.e. is this the user)
|
|
19
19
|
*/
|
|
@@ -7,3 +7,6 @@ import type { ExportFormat } from './ExportFormat';
|
|
|
7
7
|
* @private utility of `<Chat/>` component
|
|
8
8
|
*/
|
|
9
9
|
export declare function exportChatHistory(messages: ChatMessage[], format: ExportFormat, headerMarkdown?: string, participants?: ReadonlyArray<ChatParticipant>): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: !!!! Delete this parallel chat history export
|
|
12
|
+
*/
|
|
@@ -63,6 +63,10 @@ export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecu
|
|
|
63
63
|
* Calls OpenAI compatible API to use a embedding model
|
|
64
64
|
*/
|
|
65
65
|
callEmbeddingModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<EmbeddingPromptResult>;
|
|
66
|
+
/**
|
|
67
|
+
* Internal method that handles parameter retry for embedding model calls
|
|
68
|
+
*/
|
|
69
|
+
private callEmbeddingModelWithRetry;
|
|
66
70
|
/**
|
|
67
71
|
* Get the model that should be used as default
|
|
68
72
|
*/
|
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.102.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.102.0-3`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/openai",
|
|
3
|
-
"version": "0.102.0-
|
|
3
|
+
"version": "0.102.0-4",
|
|
4
4
|
"description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"module": "./esm/index.es.js",
|
|
103
103
|
"typings": "./esm/typings/src/_packages/openai.index.d.ts",
|
|
104
104
|
"peerDependencies": {
|
|
105
|
-
"@promptbook/core": "0.102.0-
|
|
105
|
+
"@promptbook/core": "0.102.0-4"
|
|
106
106
|
},
|
|
107
107
|
"dependencies": {
|
|
108
108
|
"bottleneck": "^2.19.5",
|
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.102.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.102.0-4';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2337,16 +2337,22 @@
|
|
|
2337
2337
|
* Calls OpenAI compatible API to use a embedding model
|
|
2338
2338
|
*/
|
|
2339
2339
|
async callEmbeddingModel(prompt) {
|
|
2340
|
+
return this.callEmbeddingModelWithRetry(prompt, prompt.modelRequirements);
|
|
2341
|
+
}
|
|
2342
|
+
/**
|
|
2343
|
+
* Internal method that handles parameter retry for embedding model calls
|
|
2344
|
+
*/
|
|
2345
|
+
async callEmbeddingModelWithRetry(prompt, currentModelRequirements) {
|
|
2340
2346
|
if (this.options.isVerbose) {
|
|
2341
|
-
console.info(`🖋 ${this.title} embedding call`, { prompt });
|
|
2347
|
+
console.info(`🖋 ${this.title} embedding call`, { prompt, currentModelRequirements });
|
|
2342
2348
|
}
|
|
2343
|
-
const { content, parameters
|
|
2349
|
+
const { content, parameters } = prompt;
|
|
2344
2350
|
const client = await this.getClient();
|
|
2345
2351
|
// TODO: [☂] Use here more modelRequirements
|
|
2346
|
-
if (
|
|
2352
|
+
if (currentModelRequirements.modelVariant !== 'EMBEDDING') {
|
|
2347
2353
|
throw new PipelineExecutionError('Use embed only for EMBEDDING variant');
|
|
2348
2354
|
}
|
|
2349
|
-
const modelName =
|
|
2355
|
+
const modelName = currentModelRequirements.modelName || this.getDefaultEmbeddingModel().modelName;
|
|
2350
2356
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
2351
2357
|
const rawRequest = {
|
|
2352
2358
|
input: rawPromptContent,
|
|
@@ -2356,44 +2362,79 @@
|
|
|
2356
2362
|
if (this.options.isVerbose) {
|
|
2357
2363
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
2358
2364
|
}
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2365
|
+
try {
|
|
2366
|
+
const rawResponse = await this.limiter
|
|
2367
|
+
.schedule(() => this.makeRequestWithNetworkRetry(() => client.embeddings.create(rawRequest)))
|
|
2368
|
+
.catch((error) => {
|
|
2369
|
+
assertsError(error);
|
|
2370
|
+
if (this.options.isVerbose) {
|
|
2371
|
+
console.info(colors__default["default"].bgRed('error'), error);
|
|
2372
|
+
}
|
|
2373
|
+
throw error;
|
|
2374
|
+
});
|
|
2363
2375
|
if (this.options.isVerbose) {
|
|
2364
|
-
console.info(colors__default["default"].
|
|
2376
|
+
console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
2365
2377
|
}
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2378
|
+
const complete = $getCurrentDate();
|
|
2379
|
+
if (rawResponse.data.length !== 1) {
|
|
2380
|
+
throw new PipelineExecutionError(`Expected exactly 1 data item in response, got ${rawResponse.data.length}`);
|
|
2381
|
+
}
|
|
2382
|
+
const resultContent = rawResponse.data[0].embedding;
|
|
2383
|
+
const usage = this.computeUsage(content || '', '',
|
|
2384
|
+
// <- Note: Embedding does not have result content
|
|
2385
|
+
rawResponse);
|
|
2386
|
+
return exportJson({
|
|
2387
|
+
name: 'promptResult',
|
|
2388
|
+
message: `Result of \`OpenAiCompatibleExecutionTools.callEmbeddingModel\``,
|
|
2389
|
+
order: [],
|
|
2390
|
+
value: {
|
|
2391
|
+
content: resultContent,
|
|
2392
|
+
modelName: rawResponse.model || modelName,
|
|
2393
|
+
timing: {
|
|
2394
|
+
start,
|
|
2395
|
+
complete,
|
|
2396
|
+
},
|
|
2397
|
+
usage,
|
|
2398
|
+
rawPromptContent,
|
|
2399
|
+
rawRequest,
|
|
2400
|
+
rawResponse,
|
|
2401
|
+
// <- [🗯]
|
|
2402
|
+
},
|
|
2403
|
+
});
|
|
2370
2404
|
}
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2405
|
+
catch (error) {
|
|
2406
|
+
assertsError(error);
|
|
2407
|
+
// Check if this is an unsupported parameter error
|
|
2408
|
+
if (!isUnsupportedParameterError(error)) {
|
|
2409
|
+
throw error;
|
|
2410
|
+
}
|
|
2411
|
+
// Parse which parameter is unsupported
|
|
2412
|
+
const unsupportedParameter = parseUnsupportedParameterError(error.message);
|
|
2413
|
+
if (!unsupportedParameter) {
|
|
2414
|
+
if (this.options.isVerbose) {
|
|
2415
|
+
console.warn(colors__default["default"].bgYellow('Warning'), 'Could not parse unsupported parameter from error:', error.message);
|
|
2416
|
+
}
|
|
2417
|
+
throw error;
|
|
2418
|
+
}
|
|
2419
|
+
// Create a unique key for this model + parameter combination to prevent infinite loops
|
|
2420
|
+
const retryKey = `${modelName}-${unsupportedParameter}`;
|
|
2421
|
+
if (this.retriedUnsupportedParameters.has(retryKey)) {
|
|
2422
|
+
// Already retried this parameter, throw the error
|
|
2423
|
+
if (this.options.isVerbose) {
|
|
2424
|
+
console.warn(colors__default["default"].bgRed('Error'), `Parameter '${unsupportedParameter}' for model '${modelName}' already retried once, throwing error:`, error.message);
|
|
2425
|
+
}
|
|
2426
|
+
throw error;
|
|
2427
|
+
}
|
|
2428
|
+
// Mark this parameter as retried
|
|
2429
|
+
this.retriedUnsupportedParameters.add(retryKey);
|
|
2430
|
+
// Log warning in verbose mode
|
|
2431
|
+
if (this.options.isVerbose) {
|
|
2432
|
+
console.warn(colors__default["default"].bgYellow('Warning'), `Removing unsupported parameter '${unsupportedParameter}' for model '${modelName}' and retrying request`);
|
|
2433
|
+
}
|
|
2434
|
+
// Remove the unsupported parameter and retry
|
|
2435
|
+
const modifiedModelRequirements = removeUnsupportedModelRequirement(currentModelRequirements, unsupportedParameter);
|
|
2436
|
+
return this.callEmbeddingModelWithRetry(prompt, modifiedModelRequirements);
|
|
2374
2437
|
}
|
|
2375
|
-
const resultContent = rawResponse.data[0].embedding;
|
|
2376
|
-
const usage = this.computeUsage(content || '', '',
|
|
2377
|
-
// <- Note: Embedding does not have result content
|
|
2378
|
-
rawResponse);
|
|
2379
|
-
return exportJson({
|
|
2380
|
-
name: 'promptResult',
|
|
2381
|
-
message: `Result of \`OpenAiCompatibleExecutionTools.callEmbeddingModel\``,
|
|
2382
|
-
order: [],
|
|
2383
|
-
value: {
|
|
2384
|
-
content: resultContent,
|
|
2385
|
-
modelName: rawResponse.model || modelName,
|
|
2386
|
-
timing: {
|
|
2387
|
-
start,
|
|
2388
|
-
complete,
|
|
2389
|
-
},
|
|
2390
|
-
usage,
|
|
2391
|
-
rawPromptContent,
|
|
2392
|
-
rawRequest,
|
|
2393
|
-
rawResponse,
|
|
2394
|
-
// <- [🗯]
|
|
2395
|
-
},
|
|
2396
|
-
});
|
|
2397
2438
|
}
|
|
2398
2439
|
// <- Note: [🤖] callXxxModel
|
|
2399
2440
|
/**
|