@promptbook/remote-server
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
106 lines (105 loc) • 2.92 kB
TypeScript
import type { string_model_name } from '../types/string_model_name';
import type { string_prompt } from '../types/string_prompt';
import type { string_date_iso8601 } from '../types/string_token';
import type { ToolCall } from '../types/ToolCall';
import type { TODO_object } from '../utils/organization/TODO_object';
import type { EmbeddingVector } from './EmbeddingVector';
import type { Usage } from './Usage';
/**
* Prompt result is the simplest concept of execution.
* It is the result of executing one prompt _(NOT a template)_.
*
* @see https://github.com/webgptorg/promptbook#prompt-result
*/
export type PromptResult = CompletionPromptResult | ChatPromptResult | ImagePromptResult | EmbeddingPromptResult;
/**
* Completion prompt result
*
* Note:It contains only the newly generated text NOT the whole completion
* Note: [🚉] This is fully serializable as JSON
*/
export type CompletionPromptResult = CommonPromptResult;
/**
* Chat prompt result
*
* Note: [🚉] This is fully serializable as JSON
*/
export type ChatPromptResult = CommonPromptResult & {
/**
* Optional tool calls made during the execution
*/
readonly toolCalls?: ReadonlyArray<ToolCall>;
};
/**
* Image prompt result
*
* Note: [🚉] This is fully serializable as JSON
*/
export type ImagePromptResult = CommonPromptResult;
/**
* Embedding prompt result
*
* Note: [🚉] This is fully serializable as JSON
*/
export type EmbeddingPromptResult = Omit<CommonPromptResult, 'content'> & {
/**
* The response from the model
*/
content: EmbeddingVector;
};
/**
* Common properties for all prompt results
*
* Note: [🚉] This is fully serializable as JSON
*
* @private just abstract the common properties of the prompt results
*/
export type CommonPromptResult = {
/**
* Text response from the model
*/
readonly content: string;
/**
* Name of the model used to generate the response
*/
readonly modelName: string_model_name;
/**
* Timing
*/
readonly timing: {
/**
* Start of the execution
*/
readonly start: string_date_iso8601;
/**
* First token generated
*/
readonly firstToken?: string_date_iso8601;
/**
* End of the execution
*/
readonly complete: string_date_iso8601;
};
/**
* Usage of the prompt execution
*/
readonly usage: Usage;
/**
* Exact text of the prompt (with all replacements)
*
* Note: This contains redundant information
*/
readonly rawPromptContent: string_prompt;
/**
* Raw request to the model
*
* Note: This contains redundant information
*/
readonly rawRequest: TODO_object | null;
/**
* Raw response from the model
*
* Note: This contains redundant information
*/
readonly rawResponse: TODO_object;
};