@promptbook/utils 0.59.0-30 → 0.59.0-31
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 +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -1
- package/esm/typings/src/_packages/types.index.d.ts +3 -2
- package/esm/typings/src/execution/EmbeddingVector.d.ts +8 -0
- package/esm/typings/src/execution/PromptResult.d.ts +11 -0
- package/esm/typings/src/execution/embeddingVectorToString.d.ts +5 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -2
- package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +4 -2
- package/esm/typings/src/types/PromptbookJson/MaterialKnowledgePieceJson.d.ts +2 -1
- package/package.json +1 -1
- package/umd/index.umd.js +1 -1
- package/umd/typings/src/_packages/core.index.d.ts +2 -1
- package/umd/typings/src/_packages/types.index.d.ts +3 -2
- package/umd/typings/src/execution/EmbeddingVector.d.ts +8 -0
- package/umd/typings/src/execution/PromptResult.d.ts +11 -0
- package/umd/typings/src/execution/embeddingVectorToString.d.ts +5 -0
- package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -2
- package/umd/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +4 -2
- package/umd/typings/src/types/PromptbookJson/MaterialKnowledgePieceJson.d.ts +2 -1
package/esm/index.es.js
CHANGED
|
@@ -1692,7 +1692,7 @@ function unwrapResult(text, options) {
|
|
|
1692
1692
|
/**
|
|
1693
1693
|
* The version of the Promptbook library
|
|
1694
1694
|
*/
|
|
1695
|
-
var PROMPTBOOK_VERSION = '0.59.0-
|
|
1695
|
+
var PROMPTBOOK_VERSION = '0.59.0-30';
|
|
1696
1696
|
|
|
1697
1697
|
// @promptbook/utils
|
|
1698
1698
|
// And the normalization (originally n12 library) utilities:
|
|
@@ -13,6 +13,7 @@ import { TemplateError } from '../errors/TemplateError';
|
|
|
13
13
|
import { UnexpectedError } from '../errors/UnexpectedError';
|
|
14
14
|
import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
|
|
15
15
|
import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
|
|
16
|
+
import { embeddingVectorToString } from '../execution/embeddingVectorToString';
|
|
16
17
|
import { addUsage } from '../execution/utils/addUsage';
|
|
17
18
|
import { checkExpectations, isPassingExpectations } from '../execution/utils/checkExpectations';
|
|
18
19
|
import { usageToWorktime } from '../execution/utils/usageToWorktime';
|
|
@@ -33,7 +34,7 @@ import { ExecutionTypes } from '../types/ExecutionTypes';
|
|
|
33
34
|
import { PROMPTBOOK_VERSION } from '../version';
|
|
34
35
|
export { PROMPTBOOK_VERSION };
|
|
35
36
|
export { ExecutionTypes };
|
|
36
|
-
export { addUsage, assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, isPassingExpectations, prepareKnowledgeFromMarkdown, prettifyPromptbookString, usageToWorktime, };
|
|
37
|
+
export { addUsage, assertsExecutionSuccessful, checkExpectations, embeddingVectorToString, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, isPassingExpectations, prepareKnowledgeFromMarkdown, prettifyPromptbookString, usageToWorktime, };
|
|
37
38
|
export { createLibraryFromJson, createLibraryFromPromise, createLibraryFromUrl, createSublibrary, libraryToJson };
|
|
38
39
|
export { SimplePromptInterfaceTools };
|
|
39
40
|
export { promptbookJsonToString, promptbookStringToJson, validatePromptbook };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionToolsOptions';
|
|
2
|
+
import { EmbeddingVector } from '../execution/EmbeddingVector';
|
|
2
3
|
import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
3
4
|
import type { AvailableModel, LlmExecutionTools } from '../execution/LlmExecutionTools';
|
|
4
|
-
import type { PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, UncertainNumber } from '../execution/PromptResult';
|
|
5
|
+
import type { PromptEmbeddingResult, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, UncertainNumber } from '../execution/PromptResult';
|
|
5
6
|
import type { PromptbookExecutor } from '../execution/PromptbookExecutor';
|
|
6
7
|
import type { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools';
|
|
7
8
|
import type { UserInterfaceTools, UserInterfaceToolsPromptDialogOptions } from '../execution/UserInterfaceTools';
|
|
@@ -26,7 +27,7 @@ import type { FromtoItems } from '../utils/FromtoItems';
|
|
|
26
27
|
import { PROMPTBOOK_VERSION } from '../version';
|
|
27
28
|
export { PROMPTBOOK_VERSION };
|
|
28
29
|
export { EXPECTATION_UNITS };
|
|
29
|
-
export type { AvailableModel, client_id, CommonExecutionToolsOptions, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, Expectations, ExpectationUnit, FromtoItems, KnowledgeJson, LlmExecutionTools, LlmTemplateJson, MaterialKnowledgePieceJson, ModelRequirements, ModelVariant, Parameters, Prompt, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptDialogJson, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_prompt, string_promptbook_url, string_promptbook_url_with_hashtemplate, string_script, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_version, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, };
|
|
30
|
+
export type { AvailableModel, client_id, CommonExecutionToolsOptions, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, Expectations, ExpectationUnit, FromtoItems, KnowledgeJson, LlmExecutionTools, LlmTemplateJson, MaterialKnowledgePieceJson, ModelRequirements, ModelVariant, Parameters, Prompt, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, PromptChatResult, PromptEmbeddingResult, EmbeddingVector, PromptCommonResult, PromptCompletionResult, PromptDialogJson, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_prompt, string_promptbook_url, string_promptbook_url_with_hashtemplate, string_script, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_version, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, };
|
|
30
31
|
/**
|
|
31
32
|
* TODO: Delete type aliases (from ../types/typeAliases) that are not exported here
|
|
32
33
|
*/
|
|
@@ -4,6 +4,7 @@ import type { number_positive } from '../types/typeAliases';
|
|
|
4
4
|
import type { number_usd } from '../types/typeAliases';
|
|
5
5
|
import type { string_date_iso8601 } from '../types/typeAliases';
|
|
6
6
|
import type { string_model_name } from '../types/typeAliases';
|
|
7
|
+
import type { EmbeddingVector } from './EmbeddingVector';
|
|
7
8
|
/**
|
|
8
9
|
* Prompt result is the simplest concept of execution.
|
|
9
10
|
* It is the result of executing one prompt _(NOT a template)_.
|
|
@@ -20,6 +21,16 @@ export type PromptCompletionResult = PromptCommonResult;
|
|
|
20
21
|
* Prompt chat result
|
|
21
22
|
*/
|
|
22
23
|
export type PromptChatResult = PromptCommonResult & {};
|
|
24
|
+
/**
|
|
25
|
+
* Prompt embedding result
|
|
26
|
+
* It contains only the following text NOT the whole completion
|
|
27
|
+
*/
|
|
28
|
+
export type PromptEmbeddingResult = Omit<PromptCommonResult, 'content'> & {
|
|
29
|
+
/**
|
|
30
|
+
* The response from the model
|
|
31
|
+
*/
|
|
32
|
+
content: EmbeddingVector;
|
|
33
|
+
};
|
|
23
34
|
export type PromptCommonResult = {
|
|
24
35
|
/**
|
|
25
36
|
* Exact text response from the model
|
|
@@ -2,6 +2,7 @@ import type { AvailableModel } from '../../execution/LlmExecutionTools';
|
|
|
2
2
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
3
|
import type { PromptChatResult } from '../../execution/PromptResult';
|
|
4
4
|
import type { PromptCompletionResult } from '../../execution/PromptResult';
|
|
5
|
+
import type { PromptEmbeddingResult } from '../../execution/PromptResult';
|
|
5
6
|
import type { Prompt } from '../../types/Prompt';
|
|
6
7
|
import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
|
|
7
8
|
/**
|
|
@@ -28,9 +29,9 @@ export declare class OpenAiExecutionTools implements LlmExecutionTools {
|
|
|
28
29
|
*/
|
|
29
30
|
gptComplete(prompt: Pick<Prompt, 'content' | 'modelRequirements'>): Promise<PromptCompletionResult>;
|
|
30
31
|
/**
|
|
31
|
-
*
|
|
32
|
+
* Calls OpenAI API to use a embedding model
|
|
32
33
|
*/
|
|
33
|
-
embed(prompt: Pick<Prompt, 'content' | 'modelRequirements'>): Promise<
|
|
34
|
+
embed(prompt: Pick<Prompt, 'content' | 'modelRequirements'>): Promise<PromptEmbeddingResult>;
|
|
34
35
|
/**
|
|
35
36
|
* Default model for chat variant.
|
|
36
37
|
*/
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type OpenAI from 'openai';
|
|
2
|
-
import type { PromptResult } from '../../execution/PromptResult';
|
|
3
2
|
import type { PromptResultUsage } from '../../execution/PromptResult';
|
|
4
3
|
import type { Prompt } from '../../types/Prompt';
|
|
5
4
|
/**
|
|
6
5
|
* Computes the usage of the OpenAI API based on the response from OpenAI
|
|
7
6
|
*
|
|
7
|
+
* @param promptContent The content of the prompt
|
|
8
|
+
* @param resultContent The content of the result (for embedding prompts or failed prompts pass empty string)
|
|
9
|
+
* @param rawResponse The raw response from OpenAI API
|
|
8
10
|
* @throws {PromptbookExecutionError} If the usage is not defined in the response from OpenAI
|
|
9
11
|
* @private internal util of `OpenAiExecutionTools`
|
|
10
12
|
*/
|
|
11
13
|
export declare function computeOpenaiUsage(promptContent: Prompt['content'], // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer
|
|
12
|
-
resultContent:
|
|
14
|
+
resultContent: string, rawResponse: Pick<OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion | OpenAI.Embeddings.CreateEmbeddingResponse, 'model' | 'usage'>): PromptResultUsage;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EmbeddingVector } from '../../execution/EmbeddingVector';
|
|
1
2
|
import type { string_keyword } from '../../utils/normalization/IKeywords';
|
|
2
3
|
import type { string_href } from '../typeAliases';
|
|
3
4
|
import type { string_markdown } from '../typeAliases';
|
|
@@ -11,7 +12,7 @@ export type MaterialKnowledgePieceJson = {
|
|
|
11
12
|
readonly keywords: Array<string_keyword>;
|
|
12
13
|
readonly index: Array<{
|
|
13
14
|
modelName: string_model_name;
|
|
14
|
-
position:
|
|
15
|
+
position: EmbeddingVector;
|
|
15
16
|
}>;
|
|
16
17
|
readonly sources: Array<{
|
|
17
18
|
title: string_markdown_text;
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -1695,7 +1695,7 @@
|
|
|
1695
1695
|
/**
|
|
1696
1696
|
* The version of the Promptbook library
|
|
1697
1697
|
*/
|
|
1698
|
-
var PROMPTBOOK_VERSION = '0.59.0-
|
|
1698
|
+
var PROMPTBOOK_VERSION = '0.59.0-30';
|
|
1699
1699
|
|
|
1700
1700
|
// @promptbook/utils
|
|
1701
1701
|
// And the normalization (originally n12 library) utilities:
|
|
@@ -13,6 +13,7 @@ import { TemplateError } from '../errors/TemplateError';
|
|
|
13
13
|
import { UnexpectedError } from '../errors/UnexpectedError';
|
|
14
14
|
import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
|
|
15
15
|
import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
|
|
16
|
+
import { embeddingVectorToString } from '../execution/embeddingVectorToString';
|
|
16
17
|
import { addUsage } from '../execution/utils/addUsage';
|
|
17
18
|
import { checkExpectations, isPassingExpectations } from '../execution/utils/checkExpectations';
|
|
18
19
|
import { usageToWorktime } from '../execution/utils/usageToWorktime';
|
|
@@ -33,7 +34,7 @@ import { ExecutionTypes } from '../types/ExecutionTypes';
|
|
|
33
34
|
import { PROMPTBOOK_VERSION } from '../version';
|
|
34
35
|
export { PROMPTBOOK_VERSION };
|
|
35
36
|
export { ExecutionTypes };
|
|
36
|
-
export { addUsage, assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, isPassingExpectations, prepareKnowledgeFromMarkdown, prettifyPromptbookString, usageToWorktime, };
|
|
37
|
+
export { addUsage, assertsExecutionSuccessful, checkExpectations, embeddingVectorToString, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, isPassingExpectations, prepareKnowledgeFromMarkdown, prettifyPromptbookString, usageToWorktime, };
|
|
37
38
|
export { createLibraryFromJson, createLibraryFromPromise, createLibraryFromUrl, createSublibrary, libraryToJson };
|
|
38
39
|
export { SimplePromptInterfaceTools };
|
|
39
40
|
export { promptbookJsonToString, promptbookStringToJson, validatePromptbook };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionToolsOptions';
|
|
2
|
+
import { EmbeddingVector } from '../execution/EmbeddingVector';
|
|
2
3
|
import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
3
4
|
import type { AvailableModel, LlmExecutionTools } from '../execution/LlmExecutionTools';
|
|
4
|
-
import type { PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, UncertainNumber } from '../execution/PromptResult';
|
|
5
|
+
import type { PromptEmbeddingResult, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, UncertainNumber } from '../execution/PromptResult';
|
|
5
6
|
import type { PromptbookExecutor } from '../execution/PromptbookExecutor';
|
|
6
7
|
import type { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools';
|
|
7
8
|
import type { UserInterfaceTools, UserInterfaceToolsPromptDialogOptions } from '../execution/UserInterfaceTools';
|
|
@@ -26,7 +27,7 @@ import type { FromtoItems } from '../utils/FromtoItems';
|
|
|
26
27
|
import { PROMPTBOOK_VERSION } from '../version';
|
|
27
28
|
export { PROMPTBOOK_VERSION };
|
|
28
29
|
export { EXPECTATION_UNITS };
|
|
29
|
-
export type { AvailableModel, client_id, CommonExecutionToolsOptions, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, Expectations, ExpectationUnit, FromtoItems, KnowledgeJson, LlmExecutionTools, LlmTemplateJson, MaterialKnowledgePieceJson, ModelRequirements, ModelVariant, Parameters, Prompt, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptDialogJson, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_prompt, string_promptbook_url, string_promptbook_url_with_hashtemplate, string_script, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_version, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, };
|
|
30
|
+
export type { AvailableModel, client_id, CommonExecutionToolsOptions, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, Expectations, ExpectationUnit, FromtoItems, KnowledgeJson, LlmExecutionTools, LlmTemplateJson, MaterialKnowledgePieceJson, ModelRequirements, ModelVariant, Parameters, Prompt, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, PromptChatResult, PromptEmbeddingResult, EmbeddingVector, PromptCommonResult, PromptCompletionResult, PromptDialogJson, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_prompt, string_promptbook_url, string_promptbook_url_with_hashtemplate, string_script, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_version, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, };
|
|
30
31
|
/**
|
|
31
32
|
* TODO: Delete type aliases (from ../types/typeAliases) that are not exported here
|
|
32
33
|
*/
|
|
@@ -4,6 +4,7 @@ import type { number_positive } from '../types/typeAliases';
|
|
|
4
4
|
import type { number_usd } from '../types/typeAliases';
|
|
5
5
|
import type { string_date_iso8601 } from '../types/typeAliases';
|
|
6
6
|
import type { string_model_name } from '../types/typeAliases';
|
|
7
|
+
import type { EmbeddingVector } from './EmbeddingVector';
|
|
7
8
|
/**
|
|
8
9
|
* Prompt result is the simplest concept of execution.
|
|
9
10
|
* It is the result of executing one prompt _(NOT a template)_.
|
|
@@ -20,6 +21,16 @@ export type PromptCompletionResult = PromptCommonResult;
|
|
|
20
21
|
* Prompt chat result
|
|
21
22
|
*/
|
|
22
23
|
export type PromptChatResult = PromptCommonResult & {};
|
|
24
|
+
/**
|
|
25
|
+
* Prompt embedding result
|
|
26
|
+
* It contains only the following text NOT the whole completion
|
|
27
|
+
*/
|
|
28
|
+
export type PromptEmbeddingResult = Omit<PromptCommonResult, 'content'> & {
|
|
29
|
+
/**
|
|
30
|
+
* The response from the model
|
|
31
|
+
*/
|
|
32
|
+
content: EmbeddingVector;
|
|
33
|
+
};
|
|
23
34
|
export type PromptCommonResult = {
|
|
24
35
|
/**
|
|
25
36
|
* Exact text response from the model
|
|
@@ -2,6 +2,7 @@ import type { AvailableModel } from '../../execution/LlmExecutionTools';
|
|
|
2
2
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
3
|
import type { PromptChatResult } from '../../execution/PromptResult';
|
|
4
4
|
import type { PromptCompletionResult } from '../../execution/PromptResult';
|
|
5
|
+
import type { PromptEmbeddingResult } from '../../execution/PromptResult';
|
|
5
6
|
import type { Prompt } from '../../types/Prompt';
|
|
6
7
|
import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
|
|
7
8
|
/**
|
|
@@ -28,9 +29,9 @@ export declare class OpenAiExecutionTools implements LlmExecutionTools {
|
|
|
28
29
|
*/
|
|
29
30
|
gptComplete(prompt: Pick<Prompt, 'content' | 'modelRequirements'>): Promise<PromptCompletionResult>;
|
|
30
31
|
/**
|
|
31
|
-
*
|
|
32
|
+
* Calls OpenAI API to use a embedding model
|
|
32
33
|
*/
|
|
33
|
-
embed(prompt: Pick<Prompt, 'content' | 'modelRequirements'>): Promise<
|
|
34
|
+
embed(prompt: Pick<Prompt, 'content' | 'modelRequirements'>): Promise<PromptEmbeddingResult>;
|
|
34
35
|
/**
|
|
35
36
|
* Default model for chat variant.
|
|
36
37
|
*/
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type OpenAI from 'openai';
|
|
2
|
-
import type { PromptResult } from '../../execution/PromptResult';
|
|
3
2
|
import type { PromptResultUsage } from '../../execution/PromptResult';
|
|
4
3
|
import type { Prompt } from '../../types/Prompt';
|
|
5
4
|
/**
|
|
6
5
|
* Computes the usage of the OpenAI API based on the response from OpenAI
|
|
7
6
|
*
|
|
7
|
+
* @param promptContent The content of the prompt
|
|
8
|
+
* @param resultContent The content of the result (for embedding prompts or failed prompts pass empty string)
|
|
9
|
+
* @param rawResponse The raw response from OpenAI API
|
|
8
10
|
* @throws {PromptbookExecutionError} If the usage is not defined in the response from OpenAI
|
|
9
11
|
* @private internal util of `OpenAiExecutionTools`
|
|
10
12
|
*/
|
|
11
13
|
export declare function computeOpenaiUsage(promptContent: Prompt['content'], // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer
|
|
12
|
-
resultContent:
|
|
14
|
+
resultContent: string, rawResponse: Pick<OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion | OpenAI.Embeddings.CreateEmbeddingResponse, 'model' | 'usage'>): PromptResultUsage;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EmbeddingVector } from '../../execution/EmbeddingVector';
|
|
1
2
|
import type { string_keyword } from '../../utils/normalization/IKeywords';
|
|
2
3
|
import type { string_href } from '../typeAliases';
|
|
3
4
|
import type { string_markdown } from '../typeAliases';
|
|
@@ -11,7 +12,7 @@ export type MaterialKnowledgePieceJson = {
|
|
|
11
12
|
readonly keywords: Array<string_keyword>;
|
|
12
13
|
readonly index: Array<{
|
|
13
14
|
modelName: string_model_name;
|
|
14
|
-
position:
|
|
15
|
+
position: EmbeddingVector;
|
|
15
16
|
}>;
|
|
16
17
|
readonly sources: Array<{
|
|
17
18
|
title: string_markdown_text;
|