@promptbook/remote-client
Advanced tools
Comparing version 0.54.1 to 0.55.0-0
@@ -14,2 +14,3 @@ import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString'; | ||
import { UnexpectedError } from '../errors/UnexpectedError'; | ||
import { addPromptResultUsage } from '../execution/addPromptResultUsage'; | ||
import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful'; | ||
@@ -34,3 +35,3 @@ import { createPromptbookExecutor } from '../execution/createPromptbookExecutor'; | ||
export { ExecutionTypes, PROMPTBOOK_VERSION }; | ||
export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, isPassingExpectations, prettifyPromptbookString, }; | ||
export { addPromptResultUsage, assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, isPassingExpectations, prettifyPromptbookString, }; | ||
export { createPromptbookLibraryFromDirectory, createPromptbookLibraryFromSources, createPromptbookLibraryFromUrl, createPromptbookSublibrary, SimplePromptbookLibrary, }; | ||
@@ -37,0 +38,0 @@ export { SimplePromptInterfaceTools }; |
import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionToolsOptions'; | ||
import type { ExecutionTools } from '../execution/ExecutionTools'; | ||
import type { AvailableModel, LlmExecutionTools } from '../execution/LlmExecutionTools'; | ||
import type { PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult } from '../execution/PromptResult'; | ||
import type { PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, UncertainNumber } from '../execution/PromptResult'; | ||
import type { PromptbookExecutor } from '../execution/PromptbookExecutor'; | ||
@@ -24,5 +24,5 @@ import type { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools'; | ||
import { FromtoItems } from '../utils/FromtoItems'; | ||
export { AvailableModel, client_id, CommonExecutionToolsOptions, ExecutionReportJson, ExecutionTools, ExecutionType, EXPECTATION_UNITS, ExpectationAmount, Expectations, ExpectationUnit, FromtoItems, LlmExecutionTools, LlmTemplateJson, ModelRequirements, ModelVariant, Parameters, Prompt, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptDialogJson, PromptResult, 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, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, }; | ||
export { AvailableModel, client_id, CommonExecutionToolsOptions, ExecutionReportJson, ExecutionTools, ExecutionType, EXPECTATION_UNITS, ExpectationAmount, Expectations, ExpectationUnit, FromtoItems, LlmExecutionTools, LlmTemplateJson, 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, }; | ||
/** | ||
* TODO: Delete type aliases (from ../types/typeAliases) that are not exported here | ||
*/ |
import type OpenAI from 'openai'; | ||
import type { Prompt } from '../../../../types/Prompt'; | ||
import type { PromptResult } from '../../../PromptResult'; | ||
import type { PromptResultUsage } from '../../../PromptResult'; | ||
/** | ||
@@ -7,3 +9,5 @@ * Computes the usage of the OpenAI API based on the response from OpenAI | ||
* @throws {PromptbookExecutionError} If the usage is not defined in the response from OpenAI | ||
* @private internal util of `OpenAiExecutionTools` | ||
*/ | ||
export declare function computeOpenaiUsage(rawResponse: Pick<OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion, 'model' | 'usage'>): PromptResult['usage']; | ||
export declare function computeOpenaiUsage(promptContent: Prompt['content'], // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer | ||
resultContent: PromptResult['content'], rawResponse: Pick<OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion, 'model' | 'usage'>): PromptResultUsage; |
@@ -1,3 +0,4 @@ | ||
import type { number_positive_or_zero } from '../types/typeAliases'; | ||
import type { number_tokens } from '../types/typeAliases'; | ||
import type { KebabCase } from 'type-fest'; | ||
import type { ExpectationUnit } from '../types/PromptbookJson/PromptTemplateJson'; | ||
import type { number_positive } from '../types/typeAliases'; | ||
import type { number_usd } from '../types/typeAliases'; | ||
@@ -51,18 +52,3 @@ import type { string_date_iso8601 } from '../types/typeAliases'; | ||
*/ | ||
readonly usage: { | ||
/** | ||
* Cost of the execution in USD | ||
* | ||
* If the cost is unknown, the value is `'UNKNOWN'` | ||
*/ | ||
price: (number_positive_or_zero & number_usd) | 'UNKNOWN'; | ||
/** | ||
* Number of tokens used in the input aka. `prompt_tokens` | ||
*/ | ||
inputTokens: number_tokens | 'UNKNOWN'; | ||
/** | ||
* Number of tokens used in the output aka. `completion_tokens` | ||
*/ | ||
outputTokens: number_tokens | 'UNKNOWN'; | ||
}; | ||
readonly usage: PromptResultUsage; | ||
/** | ||
@@ -74,2 +60,41 @@ * Raw response from the model | ||
/** | ||
* Usage statistics for one or many prompt results | ||
*/ | ||
export type PromptResultUsage = { | ||
/** | ||
* Cost of the execution in USD | ||
* | ||
* Note: If the cost is unknown, the value 0 and isUncertain is true | ||
*/ | ||
price: UncertainNumber; | ||
/** | ||
* Number of whatever used in the input aka. `prompt_tokens` | ||
*/ | ||
input: PromptResultUsageCounts; | ||
/** | ||
* Number of tokens used in the output aka. `completion_tokens` | ||
*/ | ||
output: PromptResultUsageCounts; | ||
}; | ||
/** | ||
* Record of all possible measurable units | ||
*/ | ||
export type PromptResultUsageCounts = Record<`${KebabCase<'TOKENS' | ExpectationUnit>}Count`, UncertainNumber>; | ||
/** | ||
* Number which can be uncertain | ||
* | ||
* Note: If the value is completelly unknown, the value 0 and isUncertain is true | ||
* Note: Not using NaN or null because it looses the value which is better to be uncertain then not to be at all | ||
*/ | ||
export type UncertainNumber = { | ||
/** | ||
* The numeric value | ||
*/ | ||
value: number_usd & (number_positive | 0); | ||
/** | ||
* Is the value uncertain | ||
*/ | ||
isUncertain?: true; | ||
}; | ||
/** | ||
* TODO: [π§ ] Maybe timing more accurate then seconds? | ||
@@ -76,0 +101,0 @@ * TODO: [π§ ] Should here be link to the prompt? |
@@ -6,7 +6,7 @@ import type { ExpectFormatCommand } from '../Command'; | ||
import type { number_integer } from '../typeAliases'; | ||
import type { string_markdown_text } from '../typeAliases'; | ||
import type { number_positive_or_zero } from '../typeAliases'; | ||
import type { number_positive } from '../typeAliases'; | ||
import type { string_javascript } from '../typeAliases'; | ||
import type { string_javascript_name } from '../typeAliases'; | ||
import type { string_markdown } from '../typeAliases'; | ||
import type { string_markdown_text } from '../typeAliases'; | ||
import type { string_name } from '../typeAliases'; | ||
@@ -52,3 +52,3 @@ import type { string_prompt } from '../typeAliases'; | ||
*/ | ||
export type ExpectationAmount = number_integer & number_positive_or_zero; | ||
export type ExpectationAmount = number_integer & (number_positive | 0); | ||
/** | ||
@@ -55,0 +55,0 @@ * Template for simple concatenation of strings |
@@ -396,7 +396,5 @@ /** | ||
*/ | ||
export type number_tokens = number_integer & number_positive_or_zero; | ||
export type number_tokens = number_integer & (number_positive | 0); | ||
export type number_positive = number; | ||
export type number_negative = number; | ||
export type number_positive_or_zero = number; | ||
export type number_negative_or_zero = number; | ||
export type number_integer = number; | ||
@@ -403,0 +401,0 @@ /** |
{ | ||
"name": "@promptbook/remote-client", | ||
"version": "0.54.1", | ||
"version": "0.55.0-0", | ||
"description": "Library to supercharge your use of large language models", | ||
@@ -50,3 +50,3 @@ "private": false, | ||
"peerDependencies": { | ||
"@promptbook/core": "0.54.1" | ||
"@promptbook/core": "0.55.0-0" | ||
}, | ||
@@ -53,0 +53,0 @@ "main": "./umd/index.umd.js", |
@@ -14,2 +14,3 @@ import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString'; | ||
import { UnexpectedError } from '../errors/UnexpectedError'; | ||
import { addPromptResultUsage } from '../execution/addPromptResultUsage'; | ||
import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful'; | ||
@@ -34,3 +35,3 @@ import { createPromptbookExecutor } from '../execution/createPromptbookExecutor'; | ||
export { ExecutionTypes, PROMPTBOOK_VERSION }; | ||
export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, isPassingExpectations, prettifyPromptbookString, }; | ||
export { addPromptResultUsage, assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, isPassingExpectations, prettifyPromptbookString, }; | ||
export { createPromptbookLibraryFromDirectory, createPromptbookLibraryFromSources, createPromptbookLibraryFromUrl, createPromptbookSublibrary, SimplePromptbookLibrary, }; | ||
@@ -37,0 +38,0 @@ export { SimplePromptInterfaceTools }; |
import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionToolsOptions'; | ||
import type { ExecutionTools } from '../execution/ExecutionTools'; | ||
import type { AvailableModel, LlmExecutionTools } from '../execution/LlmExecutionTools'; | ||
import type { PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult } from '../execution/PromptResult'; | ||
import type { PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, UncertainNumber } from '../execution/PromptResult'; | ||
import type { PromptbookExecutor } from '../execution/PromptbookExecutor'; | ||
@@ -24,5 +24,5 @@ import type { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools'; | ||
import { FromtoItems } from '../utils/FromtoItems'; | ||
export { AvailableModel, client_id, CommonExecutionToolsOptions, ExecutionReportJson, ExecutionTools, ExecutionType, EXPECTATION_UNITS, ExpectationAmount, Expectations, ExpectationUnit, FromtoItems, LlmExecutionTools, LlmTemplateJson, ModelRequirements, ModelVariant, Parameters, Prompt, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptDialogJson, PromptResult, 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, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, }; | ||
export { AvailableModel, client_id, CommonExecutionToolsOptions, ExecutionReportJson, ExecutionTools, ExecutionType, EXPECTATION_UNITS, ExpectationAmount, Expectations, ExpectationUnit, FromtoItems, LlmExecutionTools, LlmTemplateJson, 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, }; | ||
/** | ||
* TODO: Delete type aliases (from ../types/typeAliases) that are not exported here | ||
*/ |
import type OpenAI from 'openai'; | ||
import type { Prompt } from '../../../../types/Prompt'; | ||
import type { PromptResult } from '../../../PromptResult'; | ||
import type { PromptResultUsage } from '../../../PromptResult'; | ||
/** | ||
@@ -7,3 +9,5 @@ * Computes the usage of the OpenAI API based on the response from OpenAI | ||
* @throws {PromptbookExecutionError} If the usage is not defined in the response from OpenAI | ||
* @private internal util of `OpenAiExecutionTools` | ||
*/ | ||
export declare function computeOpenaiUsage(rawResponse: Pick<OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion, 'model' | 'usage'>): PromptResult['usage']; | ||
export declare function computeOpenaiUsage(promptContent: Prompt['content'], // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer | ||
resultContent: PromptResult['content'], rawResponse: Pick<OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion, 'model' | 'usage'>): PromptResultUsage; |
@@ -1,3 +0,4 @@ | ||
import type { number_positive_or_zero } from '../types/typeAliases'; | ||
import type { number_tokens } from '../types/typeAliases'; | ||
import type { KebabCase } from 'type-fest'; | ||
import type { ExpectationUnit } from '../types/PromptbookJson/PromptTemplateJson'; | ||
import type { number_positive } from '../types/typeAliases'; | ||
import type { number_usd } from '../types/typeAliases'; | ||
@@ -51,18 +52,3 @@ import type { string_date_iso8601 } from '../types/typeAliases'; | ||
*/ | ||
readonly usage: { | ||
/** | ||
* Cost of the execution in USD | ||
* | ||
* If the cost is unknown, the value is `'UNKNOWN'` | ||
*/ | ||
price: (number_positive_or_zero & number_usd) | 'UNKNOWN'; | ||
/** | ||
* Number of tokens used in the input aka. `prompt_tokens` | ||
*/ | ||
inputTokens: number_tokens | 'UNKNOWN'; | ||
/** | ||
* Number of tokens used in the output aka. `completion_tokens` | ||
*/ | ||
outputTokens: number_tokens | 'UNKNOWN'; | ||
}; | ||
readonly usage: PromptResultUsage; | ||
/** | ||
@@ -74,2 +60,41 @@ * Raw response from the model | ||
/** | ||
* Usage statistics for one or many prompt results | ||
*/ | ||
export type PromptResultUsage = { | ||
/** | ||
* Cost of the execution in USD | ||
* | ||
* Note: If the cost is unknown, the value 0 and isUncertain is true | ||
*/ | ||
price: UncertainNumber; | ||
/** | ||
* Number of whatever used in the input aka. `prompt_tokens` | ||
*/ | ||
input: PromptResultUsageCounts; | ||
/** | ||
* Number of tokens used in the output aka. `completion_tokens` | ||
*/ | ||
output: PromptResultUsageCounts; | ||
}; | ||
/** | ||
* Record of all possible measurable units | ||
*/ | ||
export type PromptResultUsageCounts = Record<`${KebabCase<'TOKENS' | ExpectationUnit>}Count`, UncertainNumber>; | ||
/** | ||
* Number which can be uncertain | ||
* | ||
* Note: If the value is completelly unknown, the value 0 and isUncertain is true | ||
* Note: Not using NaN or null because it looses the value which is better to be uncertain then not to be at all | ||
*/ | ||
export type UncertainNumber = { | ||
/** | ||
* The numeric value | ||
*/ | ||
value: number_usd & (number_positive | 0); | ||
/** | ||
* Is the value uncertain | ||
*/ | ||
isUncertain?: true; | ||
}; | ||
/** | ||
* TODO: [π§ ] Maybe timing more accurate then seconds? | ||
@@ -76,0 +101,0 @@ * TODO: [π§ ] Should here be link to the prompt? |
@@ -6,7 +6,7 @@ import type { ExpectFormatCommand } from '../Command'; | ||
import type { number_integer } from '../typeAliases'; | ||
import type { string_markdown_text } from '../typeAliases'; | ||
import type { number_positive_or_zero } from '../typeAliases'; | ||
import type { number_positive } from '../typeAliases'; | ||
import type { string_javascript } from '../typeAliases'; | ||
import type { string_javascript_name } from '../typeAliases'; | ||
import type { string_markdown } from '../typeAliases'; | ||
import type { string_markdown_text } from '../typeAliases'; | ||
import type { string_name } from '../typeAliases'; | ||
@@ -52,3 +52,3 @@ import type { string_prompt } from '../typeAliases'; | ||
*/ | ||
export type ExpectationAmount = number_integer & number_positive_or_zero; | ||
export type ExpectationAmount = number_integer & (number_positive | 0); | ||
/** | ||
@@ -55,0 +55,0 @@ * Template for simple concatenation of strings |
@@ -396,7 +396,5 @@ /** | ||
*/ | ||
export type number_tokens = number_integer & number_positive_or_zero; | ||
export type number_tokens = number_integer & (number_positive | 0); | ||
export type number_positive = number; | ||
export type number_negative = number; | ||
export type number_positive_or_zero = number; | ||
export type number_negative_or_zero = number; | ||
export type number_integer = number; | ||
@@ -403,0 +401,0 @@ /** |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
461678
524
7924