@promptbook/wizard 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
@@ -26,14 +26,15 @@ import { MOCKED_CHAT_DELAY_CONFIGS } from '../book-components/Chat/MockedChat/co
|
|
26
26
|
import type { MockedChatDelayConfig } from '../book-components/Chat/MockedChat/MockedChat';
|
27
27
|
import type { MockedChatProps } from '../book-components/Chat/MockedChat/MockedChat';
|
28
28
|
import { MockedChat } from '../book-components/Chat/MockedChat/MockedChat';
|
29
|
-
import type {
|
30
|
-
import
|
31
|
-
import {
|
32
|
-
import {
|
33
|
-
import {
|
34
|
-
import {
|
35
|
-
import {
|
36
|
-
import {
|
29
|
+
import type { ChatSaveFormatDefinition } from '../book-components/Chat/save/_common/ChatSaveFormatDefinition';
|
30
|
+
import { getChatSaveFormatDefinitions } from '../book-components/Chat/save/_common/getChatSaveFormatDefinitions';
|
31
|
+
import type { string_chat_format_name } from '../book-components/Chat/save/_common/string_chat_format_name';
|
32
|
+
import { htmlSaveFormatDefinition } from '../book-components/Chat/save/html/htmlSaveFormatDefinition';
|
33
|
+
import { CHAT_SAVE_FORMATS } from '../book-components/Chat/save/index';
|
34
|
+
import { jsonSaveFormatDefinition } from '../book-components/Chat/save/json/jsonSaveFormatDefinition';
|
35
|
+
import { mdSaveFormatDefinition } from '../book-components/Chat/save/markdown/mdSaveFormatDefinition';
|
36
|
+
import { pdfSaveFormatDefinition } from '../book-components/Chat/save/pdf/pdfSaveFormatDefinition';
|
37
|
+
import { txtSaveFormatDefinition } from '../book-components/Chat/save/text/txtSaveFormatDefinition';
|
37
38
|
import type { ChatMessage } from '../book-components/Chat/types/ChatMessage';
|
38
39
|
import type { ChatParticipant } from '../book-components/Chat/types/ChatParticipant';
|
39
40
|
import type { MessageButton } from '../book-components/Chat/utils/parseMessageButtons';
|
@@ -76,14 +77,15 @@ export { MOCKED_CHAT_DELAY_CONFIGS };
|
|
76
77
|
export type { MockedChatDelayConfig };
|
77
78
|
export type { MockedChatProps };
|
78
79
|
export { MockedChat };
|
79
|
-
export type { string_chat_format_name };
|
80
80
|
export type { ChatSaveFormatDefinition };
|
81
|
-
export {
|
82
|
-
export {
|
83
|
-
export { mdSaveFormatDefinition };
|
81
|
+
export { getChatSaveFormatDefinitions };
|
82
|
+
export type { string_chat_format_name };
|
84
83
|
export { htmlSaveFormatDefinition };
|
85
84
|
export { CHAT_SAVE_FORMATS };
|
86
|
-
export {
|
85
|
+
export { jsonSaveFormatDefinition };
|
86
|
+
export { mdSaveFormatDefinition };
|
87
|
+
export { pdfSaveFormatDefinition };
|
88
|
+
export { txtSaveFormatDefinition };
|
87
89
|
export type { ChatMessage };
|
88
90
|
export type { ChatParticipant };
|
89
91
|
export type { MessageButton };
|
@@ -16,8 +16,8 @@ import type { SendMessageToLlmChatFunction } from '../book-components/Chat/hooks
|
|
16
16
|
import type { LlmChatProps } from '../book-components/Chat/LlmChat/LlmChatProps';
|
17
17
|
import type { MockedChatDelayConfig } from '../book-components/Chat/MockedChat/MockedChat';
|
18
18
|
import type { MockedChatProps } from '../book-components/Chat/MockedChat/MockedChat';
|
19
|
-
import type {
|
20
|
-
import type {
|
19
|
+
import type { ChatSaveFormatDefinition } from '../book-components/Chat/save/_common/ChatSaveFormatDefinition';
|
20
|
+
import type { string_chat_format_name } from '../book-components/Chat/save/_common/string_chat_format_name';
|
21
21
|
import type { ChatMessage } from '../book-components/Chat/types/ChatMessage';
|
22
22
|
import type { ChatParticipant } from '../book-components/Chat/types/ChatParticipant';
|
23
23
|
import type { MessageButton } from '../book-components/Chat/utils/parseMessageButtons';
|
@@ -348,8 +348,8 @@ export type { SendMessageToLlmChatFunction };
|
|
348
348
|
export type { LlmChatProps };
|
349
349
|
export type { MockedChatDelayConfig };
|
350
350
|
export type { MockedChatProps };
|
351
|
-
export type { string_chat_format_name };
|
352
351
|
export type { ChatSaveFormatDefinition };
|
352
|
+
export type { string_chat_format_name };
|
353
353
|
export type { ChatMessage };
|
354
354
|
export type { ChatParticipant };
|
355
355
|
export type { MessageButton };
|
@@ -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/wizard",
|
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,
|
@@ -95,7 +95,7 @@
|
|
95
95
|
"module": "./esm/index.es.js",
|
96
96
|
"typings": "./esm/typings/src/_packages/wizard.index.d.ts",
|
97
97
|
"peerDependencies": {
|
98
|
-
"@promptbook/core": "0.102.0-
|
98
|
+
"@promptbook/core": "0.102.0-4"
|
99
99
|
},
|
100
100
|
"dependencies": {
|
101
101
|
"@ai-sdk/deepseek": "0.1.6",
|
package/umd/index.umd.js
CHANGED
@@ -48,7 +48,7 @@
|
|
48
48
|
* @generated
|
49
49
|
* @see https://github.com/webgptorg/promptbook
|
50
50
|
*/
|
51
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.102.0-
|
51
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.102.0-4';
|
52
52
|
/**
|
53
53
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
54
54
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
@@ -5013,16 +5013,22 @@
|
|
5013
5013
|
* Calls OpenAI compatible API to use a embedding model
|
5014
5014
|
*/
|
5015
5015
|
async callEmbeddingModel(prompt) {
|
5016
|
+
return this.callEmbeddingModelWithRetry(prompt, prompt.modelRequirements);
|
5017
|
+
}
|
5018
|
+
/**
|
5019
|
+
* Internal method that handles parameter retry for embedding model calls
|
5020
|
+
*/
|
5021
|
+
async callEmbeddingModelWithRetry(prompt, currentModelRequirements) {
|
5016
5022
|
if (this.options.isVerbose) {
|
5017
|
-
console.info(`🖋 ${this.title} embedding call`, { prompt });
|
5023
|
+
console.info(`🖋 ${this.title} embedding call`, { prompt, currentModelRequirements });
|
5018
5024
|
}
|
5019
|
-
const { content, parameters
|
5025
|
+
const { content, parameters } = prompt;
|
5020
5026
|
const client = await this.getClient();
|
5021
5027
|
// TODO: [☂] Use here more modelRequirements
|
5022
|
-
if (
|
5028
|
+
if (currentModelRequirements.modelVariant !== 'EMBEDDING') {
|
5023
5029
|
throw new PipelineExecutionError('Use embed only for EMBEDDING variant');
|
5024
5030
|
}
|
5025
|
-
const modelName =
|
5031
|
+
const modelName = currentModelRequirements.modelName || this.getDefaultEmbeddingModel().modelName;
|
5026
5032
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
5027
5033
|
const rawRequest = {
|
5028
5034
|
input: rawPromptContent,
|
@@ -5032,44 +5038,79 @@
|
|
5032
5038
|
if (this.options.isVerbose) {
|
5033
5039
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
5034
5040
|
}
|
5035
|
-
|
5036
|
-
|
5037
|
-
|
5038
|
-
|
5041
|
+
try {
|
5042
|
+
const rawResponse = await this.limiter
|
5043
|
+
.schedule(() => this.makeRequestWithNetworkRetry(() => client.embeddings.create(rawRequest)))
|
5044
|
+
.catch((error) => {
|
5045
|
+
assertsError(error);
|
5046
|
+
if (this.options.isVerbose) {
|
5047
|
+
console.info(colors__default["default"].bgRed('error'), error);
|
5048
|
+
}
|
5049
|
+
throw error;
|
5050
|
+
});
|
5039
5051
|
if (this.options.isVerbose) {
|
5040
|
-
console.info(colors__default["default"].
|
5052
|
+
console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
5041
5053
|
}
|
5042
|
-
|
5043
|
-
|
5044
|
-
|
5045
|
-
|
5054
|
+
const complete = $getCurrentDate();
|
5055
|
+
if (rawResponse.data.length !== 1) {
|
5056
|
+
throw new PipelineExecutionError(`Expected exactly 1 data item in response, got ${rawResponse.data.length}`);
|
5057
|
+
}
|
5058
|
+
const resultContent = rawResponse.data[0].embedding;
|
5059
|
+
const usage = this.computeUsage(content || '', '',
|
5060
|
+
// <- Note: Embedding does not have result content
|
5061
|
+
rawResponse);
|
5062
|
+
return exportJson({
|
5063
|
+
name: 'promptResult',
|
5064
|
+
message: `Result of \`OpenAiCompatibleExecutionTools.callEmbeddingModel\``,
|
5065
|
+
order: [],
|
5066
|
+
value: {
|
5067
|
+
content: resultContent,
|
5068
|
+
modelName: rawResponse.model || modelName,
|
5069
|
+
timing: {
|
5070
|
+
start,
|
5071
|
+
complete,
|
5072
|
+
},
|
5073
|
+
usage,
|
5074
|
+
rawPromptContent,
|
5075
|
+
rawRequest,
|
5076
|
+
rawResponse,
|
5077
|
+
// <- [🗯]
|
5078
|
+
},
|
5079
|
+
});
|
5046
5080
|
}
|
5047
|
-
|
5048
|
-
|
5049
|
-
|
5081
|
+
catch (error) {
|
5082
|
+
assertsError(error);
|
5083
|
+
// Check if this is an unsupported parameter error
|
5084
|
+
if (!isUnsupportedParameterError(error)) {
|
5085
|
+
throw error;
|
5086
|
+
}
|
5087
|
+
// Parse which parameter is unsupported
|
5088
|
+
const unsupportedParameter = parseUnsupportedParameterError(error.message);
|
5089
|
+
if (!unsupportedParameter) {
|
5090
|
+
if (this.options.isVerbose) {
|
5091
|
+
console.warn(colors__default["default"].bgYellow('Warning'), 'Could not parse unsupported parameter from error:', error.message);
|
5092
|
+
}
|
5093
|
+
throw error;
|
5094
|
+
}
|
5095
|
+
// Create a unique key for this model + parameter combination to prevent infinite loops
|
5096
|
+
const retryKey = `${modelName}-${unsupportedParameter}`;
|
5097
|
+
if (this.retriedUnsupportedParameters.has(retryKey)) {
|
5098
|
+
// Already retried this parameter, throw the error
|
5099
|
+
if (this.options.isVerbose) {
|
5100
|
+
console.warn(colors__default["default"].bgRed('Error'), `Parameter '${unsupportedParameter}' for model '${modelName}' already retried once, throwing error:`, error.message);
|
5101
|
+
}
|
5102
|
+
throw error;
|
5103
|
+
}
|
5104
|
+
// Mark this parameter as retried
|
5105
|
+
this.retriedUnsupportedParameters.add(retryKey);
|
5106
|
+
// Log warning in verbose mode
|
5107
|
+
if (this.options.isVerbose) {
|
5108
|
+
console.warn(colors__default["default"].bgYellow('Warning'), `Removing unsupported parameter '${unsupportedParameter}' for model '${modelName}' and retrying request`);
|
5109
|
+
}
|
5110
|
+
// Remove the unsupported parameter and retry
|
5111
|
+
const modifiedModelRequirements = removeUnsupportedModelRequirement(currentModelRequirements, unsupportedParameter);
|
5112
|
+
return this.callEmbeddingModelWithRetry(prompt, modifiedModelRequirements);
|
5050
5113
|
}
|
5051
|
-
const resultContent = rawResponse.data[0].embedding;
|
5052
|
-
const usage = this.computeUsage(content || '', '',
|
5053
|
-
// <- Note: Embedding does not have result content
|
5054
|
-
rawResponse);
|
5055
|
-
return exportJson({
|
5056
|
-
name: 'promptResult',
|
5057
|
-
message: `Result of \`OpenAiCompatibleExecutionTools.callEmbeddingModel\``,
|
5058
|
-
order: [],
|
5059
|
-
value: {
|
5060
|
-
content: resultContent,
|
5061
|
-
modelName: rawResponse.model || modelName,
|
5062
|
-
timing: {
|
5063
|
-
start,
|
5064
|
-
complete,
|
5065
|
-
},
|
5066
|
-
usage,
|
5067
|
-
rawPromptContent,
|
5068
|
-
rawRequest,
|
5069
|
-
rawResponse,
|
5070
|
-
// <- [🗯]
|
5071
|
-
},
|
5072
|
-
});
|
5073
5114
|
}
|
5074
5115
|
// <- Note: [🤖] callXxxModel
|
5075
5116
|
/**
|