@convo-lang/convo-lang
Version:
The language of AI
1,121 lines (1,120 loc) • 49.3 kB
TypeScript
import type { ConversationOptions } from "./Conversation";
import { ConvoExecutionContext } from "./ConvoExecutionContext";
import { ConvoDocumentReference } from "./convo-rag-types";
import { ConvoBaseType, ConvoCompletion, ConvoCompletionMessage, ConvoCompletionService, ConvoFlowController, ConvoFunction, ConvoMessage, ConvoMessageModificationAction, ConvoMessageTemplate, ConvoMetadata, ConvoModelAlias, ConvoModelInfo, ConvoPrintFunction, ConvoScope, ConvoScopeError, ConvoScopeFunction, ConvoStatement, ConvoTag, ConvoThreadFilter, ConvoTokenUsage, ConvoType, FlatConvoConversation, FlatConvoConversationBase, FlatConvoMessage, OptionalConvoValue, ParsedContentJsonOrString, StandardConvoSystemMessage, convoObjFlag } from "./convo-types";
export declare const convoBodyFnName = "__body";
export declare const convoArgsName = "__args";
export declare const convoResultReturnName = "__return";
export declare const convoResultErrorName = "__error";
export declare const convoDisableAutoCompleteName = "__disableAutoComplete";
export declare const convoStructFnName = "struct";
export declare const convoNewFnName = "new";
export declare const convoMapFnName = "map";
export declare const convoArrayFnName = "array";
export declare const convoJsonMapFnName = "jsonMap";
export declare const convoJsonArrayFnName = "jsonArray";
export declare const convoSwitchFnName = "switch";
export declare const convoCaseFnName = "case";
export declare const convoDefaultFnName = "default";
export declare const convoTestFnName = "test";
export declare const convoPipeFnName = "pipe";
export declare const convoLocalFunctionModifier = "local";
export declare const convoExternFunctionModifier = "extern";
export declare const convoCallFunctionModifier = "call";
export declare const convoInvokeFunctionModifier = "invoke";
export declare const convoInvokeFunctionName = "invoke";
export declare const convoGlobalRef = "convo";
export declare const convoEnumFnName = "enum";
export declare const convoMetadataKey: unique symbol;
export declare const convoCaptureMetadataTag = "captureMetadata";
export declare const defaultConversationName = "default";
export declare const convoMsgModifiers: {
/**
* When applied to the function the function is used as the default function of an agent
*/
readonly agent: "agent";
};
export declare const convoScopedModifiers: "agent"[];
export declare const defaultConvoTask = "default";
export declare const convoAnyModelName = "__any__";
export declare const convoRagTemplatePlaceholder = "$$RAG$$";
export declare const convoRoles: {
readonly user: "user";
readonly assistant: "assistant";
readonly system: "system";
/**
* Used to add a prefix to the previous content message. Prefixes are not seen by the user.
*/
readonly prefix: "prefix";
/**
* Used to add a suffix to the previous content message. Suffixes are not seen by the user.
*/
readonly suffix: "suffix";
/**
* Appends content to the previous content message
*/
readonly append: "append";
/**
* Prepends content to the previous content message
*/
readonly prepend: "prepend";
/**
* Used to replace the content of the previous content message
*/
readonly replace: "replace";
/**
* Used to replace the content of the previous content message before sending to an LLM. The
* user will continue to see the previous content message.
*/
readonly replaceForModel: "replaceForModel";
/**
* Used to display message evaluated by inline / thinking prompts
*/
readonly thinking: "thinking";
/**
* Used to set variables set within inline / thinking prompts
*/
readonly thinkingResult: "thinkingResult";
/**
* Contains RAG content
*/
readonly rag: "rag";
/**
* Used to define a prefix to add to rag messages
*/
readonly ragPrefix: "ragPrefix";
/**
* Used to define a suffix to add to rag messages
*/
readonly ragSuffix: "ragSuffix";
/**
* A message used as a template to insert RAG content into. The value __RAG__ will be used replaced with the actual rag content
*/
readonly ragTemplate: "ragTemplate";
/**
* When encountered a conversation will executed the preceding message before continuing unless
* preceded by a flushed message.
*/
readonly queue: "queue";
/**
* signals a queue has been flushed
*/
readonly flush: "flush";
/**
* Starts an insertion block. Insertion blocks are used to reorder messages in a flattened conversation.
*/
readonly insert: "insert";
/**
* Ends an insertion block.
*/
readonly insertEnd: "insertEnd";
/**
* No op role. Messages with this role are completely ignored
*/
readonly nop: "nop";
/**
* Used to track transform results including tokens used by transforms
*/
readonly transformResult: "transformResult";
/**
* Starts a parallel execution block
*/
readonly parallel: "parallel";
/**
* Ends a parallel execution block
*/
readonly parallelEnd: "parallelEnd";
/**
* Ends the definition of an agent
*/
readonly agentEnd: "agentEnd";
readonly call: "call";
readonly do: "do";
readonly result: "result";
readonly define: "define";
readonly debug: "debug";
readonly end: "end";
};
/**
* Reserved role names in Convo-Lang that have special meaning and cannot be used as custom roles.
* These roles are used for system functionality like function calls, execution blocks, and debugging.
*/
export declare const convoReservedRoles: readonly ["call", "do", "result", "define", "debug", "end", "thinking"];
export declare const convoFunctions: {
readonly queryImage: "queryImage";
readonly getState: "getState";
/**
* When called __rag with be set to true and and params passed will be added the the __ragParams
* array. If __ragParams is not an array it will be set to an array first. Duplicated values
* will not be added to __ragParams.
*/
readonly enableRag: "enableRag";
/**
* Disables and clears all rag params
*/
readonly clearRag: "clearRag";
/**
* Defines a form that a user can be guided through
*/
readonly defineForm: "defineForm";
readonly today: "today";
readonly uuid: "uuid";
readonly shortUuid: "shortUuid";
readonly getVar: "getVar";
readonly setVar: "setVar";
readonly idx: "idx";
readonly describeScene: "describeScene";
readonly readDoc: "readDoc";
/**
* States the default value of a variable.
*/
readonly setDefault: "setDefault";
/**
* Returns an XML list of agents available to the current conversation.
*/
readonly getAgentList: "getAgentList";
/**
* Explicitly enables a transform by name
*/
readonly enableTransform: "enableTransform";
/**
* Explicitly enables all transforms
*/
readonly enableAllTransforms: "enableAllTransforms";
/**
* Pushes a conversation task on to the task stack. The task will be display in the UI
* while a completion is in progress
*/
readonly pushConvoTask: "pushConvoTask";
/**
* Pops the last convo task off the stack
*/
readonly popConvoTask: "popConvoTask";
/**
* Reads a JSON value from the virtual file system
*/
readonly fsRead: "fsRead";
/**
* Writes a JSON value to the virtual file system and returns the written value.
*/
readonly fsWrite: "fsWrite";
/**
* Delete a file or directory from the virtual file system
*/
readonly fsRemove: "fsRemove";
/**
* Creates a directory in the virtual file system
*/
readonly fsMkDir: "fsMkDir";
/**
* Checks if a path exists in the virtual file system
*/
readonly fsExists: "fsExists";
/**
* Joins file paths
*/
readonly joinPaths: "joinPaths";
/**
* Returns true if all values passed to the function are undefined
*/
readonly isUndefined: "isUndefined";
/**
* Returns the passed in value as milliseconds
*/
readonly secondMs: "secondMs";
/**
* Returns the passed in value as milliseconds
*/
readonly minuteMs: "minuteMs";
/**
* Returns the passed in value as milliseconds
*/
readonly hourMs: "hourMs";
/**
* Returns the passed in value as milliseconds
*/
readonly dayMs: "dayMs";
/**
* Finds an item in an array using shallow comparison.
*/
readonly aryFindMatch: "aryFindMatch";
/**
* Removes the first matching item in an array using shallow comparison.
*/
readonly aryRemoveMatch: "aryRemoveMatch";
};
/**
* reserved system variables
*/
export declare const convoVars: {
readonly __return: "__return";
/**
* Used to enabled prompt caching. A value of true will use the default prompt cached which
* by default uses the `ConvoLocalStorageCache`. If assigned a string a cache with a matching
* type will be used.
*/
readonly __cache: "__cache";
/**
* In environments that have access to the filesystem __cwd defines the current working directory.
*/
readonly __cwd: "__cwd";
/**
* Path to the current convo file
*/
readonly __file: "__file";
/**
* When set to true debugging information will be added to conversations.
*/
readonly __debug: "__debug";
/**
* Sets the default model
*/
readonly __model: "__model";
/**
* Sets the default completion endpoint
*/
readonly __endpoint: "__endpoint";
/**
* Endpoint to a convo compatible endpoint
*/
readonly __convoEndpoint: "__convoEndpoint";
/**
* API key to send to completions endpoint. The `apiKey` of the `FlatConvoConversationBase` will
* be populated by this variable if defined.
*/
readonly __apiKey: "__apiKey";
/**
* Sets the default user id of the conversation
*/
readonly __userId: "__userId";
/**
* When set to true time tracking will be enabled.
*/
readonly __trackTime: "__trackTime";
/**
* When set to true token usage tracking will be enabled.
*/
readonly __trackTokenUsage: "__trackTokenUsage";
/**
* When set to true the model used as a completion provider will be tracked.
*/
readonly __trackModel: "__trackModel";
/**
* When defined __visionSystemMessage will be injected into the system message of conversations
* with vision capabilities. __visionSystemMessage will override the default vision
* system message.
*/
readonly __visionSystemMessage: "__visionSystemMessage";
/**
* The default system message used for completing vision requests. Vision requests are typically
* completed in a separate conversation that supports vision messages. By default the system
* message of the conversation that triggered the vision request will be used.
*/
readonly __visionServiceSystemMessage: "__visionServiceSystemMessage";
/**
* Response used with the system is not able to generate a vision response.
*/
readonly __defaultVisionResponse: "__defaultVisionResponse";
/**
* A reference to markdown vars.
*/
readonly __md: "__md";
/**
* Enables retrieval augmented generation (RAG). The value of the __rag can either be true,
* false or a number. The value indicates the number of rag results that should be sent to the
* LLM by default all rag message will be sent to the LLM. When setting the number of rag
* messages to a fixed number only the last N number of rag messages will be sent to the LLM.
* Setting __rag to a fixed number can help to reduce prompt size.
*/
readonly __rag: "__rag";
/**
* An object that will be passed to the rag callback of a conversation. If the value is not an
* object it is ignored.
*/
readonly __ragParams: "__ragParams";
/**
* The tolerance that determines if matched rag content should be included as contact.
*/
readonly __ragTol: "__ragTol";
/**
* Sets the current thread filter. Can either be a string or a ConvoThreadFilter. If __threadFilter
* is a string it will be converted into a filter that looks like `{includeThreads:[__threadId]}`.
*/
readonly __threadFilter: "__threadFilter";
/**
* A reference to a SceneCtrl that is capable of describing the current scene the user is viewing.
*/
readonly __sceneCtrl: "__sceneCtrl";
/**
* The last described scene added to the conversation
*/
readonly __lastDescribedScene: "__lastDescribedScene";
/**
* Used by agents to define the voice they use
*/
readonly __voice: "__voice";
/**
* used to indicate that forms have been enabled
*/
readonly __formsEnabled: "__formsEnabled";
/**
* Default array of forms
*/
readonly __forms: "__forms";
/**
* Array of transforms names that have explicity been enabled. Transforms are enabled by default
* unless they have the `transformOptional` tag applied. Adding "all" to the list will explicity
* enable all components.
*/
readonly __explicitlyEnabledTransforms: "__explicitlyEnabledTransforms";
/**
* Name of the currently executing trigger
*/
readonly __trigger: "__trigger";
/**
* If true inline prompt messages should be written to debug output
*/
readonly __debugInline: "__debugInline";
};
export declare const convoImportModifiers: {
/**
* Only system messages should be imported
*/
readonly system: "system";
/**
* Content messages should be ignored
*/
readonly ignoreContent: "ignoreContent";
};
export declare const defaultConvoRagTol = 1.2;
export declare const convoEvents: {
/**
* Occurs when a user message is added to a conversation
*
* Functions listening to the `user` event will be called after user messages are
* appended. The return value of the function will either replaces the content of the user
* message or will be set as the messages prefix or suffix. If the function return false, null or
* undefined it is ignored and the next function listening to the `user` event will be called.
*
* @usage (@)on user [replace|append|prepend|prefix|suffix] [condition]
*/
readonly user: "user";
/**
* Occurs when an assistant message is added to a conversation.
*
* Functions listening to the `assistant` event will be called after assistant messages are
* appended. The return value of the function will either replaces the content of the assistant
* message or will be set as the messages prefix or suffix. If the function return false, null or
* undefined it is ignored and the next function listening to the `assistant` event will be called.
*
* @usage (@)on assistant [replace|append|prepend|prefix|suffix] [condition]
*/
readonly assistant: "assistant";
};
export declare const convoTags: {
/**
* When applied to a user message and the message is the last message in a conversation the message
* is considered a conversation initializer.
*/
readonly init: "init";
/**
* Defines an event listener for a message
*/
readonly on: "on";
/**
* Enable rag for a message. The value of the tag will be added as a rag path
*/
readonly ragForMsg: "ragForMsg";
/**
* Enables rag for the current conversation
*/
readonly rag: "rag";
/**
* Defines the start index and length of the actual rag content without prefix and suffix
*/
readonly ragContentRage: "ragContentRage";
/**
* Manually labels a message
*/
readonly label: "label";
/**
* Clears all content messages that precede the messages with the exception of system messages.
* If the value of "system" is given as the tags value system message will also be cleared.
*/
readonly clear: "clear";
/**
* Prevents a message from being clear when followed by a message with a `@clear` tag applied.
*/
readonly noClear: "noClear";
/**
* Enables caching for the message the tag is applied to. No value of a value of true will use
* the default prompt cached which by default uses the `ConvoLocalStorageCache`. If assigned
* a string a cache with a matching type will be used.
*/
readonly cache: "cache";
/**
* When applied to a function the return value of the function will not be used to generate a
* new assistant message.
*/
readonly disableAutoComplete: "disableAutoComplete";
/**
* Disables triggers on the message the tag is applied to.
*/
readonly disableTriggers: "disableTriggers";
/**
* Forces a message to be included in triggers. If the tag defines a value the value will be used
* to match which trigger the message is included in.
*/
readonly includeInTriggers: "includeInTriggers";
/**
* Excludes a message from being included in triggers. If the tag defines a value the value will
* be used to match the trigger it is excluded from.
*/
readonly excludeFromTriggers: "excludeFromTriggers";
/**
* When applied to a content message the message will be appended to the conversation after calling the
* function specified by the tag's value. When applied to a function message the content of the
* tag will be appended as a user message.
*/
readonly afterCall: "afterCall";
/**
* When used with the `afterCall` tag the appended message will be hidden from the user but
* visible to the LLM
*/
readonly afterCallHide: "afterCallHide";
/**
* When used with the `afterCall` tag the appended message will use the given role
*/
readonly afterCallRole: "afterCallRole";
/**
* Indicates a message was created by a afterCall tag
*/
readonly createdAfterCalling: "createdAfterCalling";
/**
* Used to indicate that a message should be evaluated at the edge of a conversation with the
* latest state. (@)edge is most commonly used with system message to ensure that all injected values
* are updated with the latest state of the conversation.
*/
readonly edge: "edge";
/**
* Used to track the time messages are created.
*/
readonly time: "time";
/**
* Used to track the number of tokens a message used
*/
readonly tokenUsage: "tokenUsage";
/**
* Used to track the model used to generate completions
*/
readonly model: "model";
/**
* Sets the requested model to complete a message with
*/
readonly responseModel: "responseModel";
/**
* Used to track the endpoint to generate completions
*/
readonly endpoint: "endpoint";
/**
* Sets the requested endpoint to complete a message with
*/
readonly responseEndpoint: "responseEndpoint";
/**
* Sets the format as message should be responded to with.
*/
readonly responseFormat: "responseFormat";
/**
* Causes the response of the tagged message to be assigned to a variable
*/
readonly assign: "assign";
/**
* When used with a message the json tag is short and for `@responseFormat json`
*/
readonly json: "json";
/**
* The format of a message
*/
readonly format: "format";
/**
* Used to assign the content or jsonValue of a message to a variable
*/
readonly assignTo: "assignTo";
/**
* Used to enable capabilities. Only the first and last message in the conversation are used
* to determine current capabilities. Multiple capability tags can be
* applied to a message and multiple capabilities can be specified by separating them with a
* comma.
*/
readonly capability: "capability";
/**
* Shorthand for `@capability vision`
* Enables vision for all messages in a conversation
*/
readonly enableVision: "enableVision";
/**
* Shorthand for `@capability visionFunction`
* The visionFunction capability adds vision support by passing vision messages to a vision model
* and exposing vision capabilities as a function.
*/
readonly enabledVisionFunction: "enabledVisionFunction";
/**
* Enables vision for the message the tag is applied to
*/
readonly vision: "vision";
/**
* Sets the task a message is part of. By default messages are part of the "default" task
*/
readonly task: "task";
/**
* Can be used by functions to display a task message while the function is executing.
*/
readonly taskName: "taskName";
/**
* Can be used by functions to display a task message while the function is executing.
*/
readonly taskDescription: "taskDescription";
/**
* Sets the max number of non-system messages that should be included in a task completion
*/
readonly maxTaskMessageCount: "maxTaskMessageCount";
/**
* Defines what triggers a task
*/
readonly taskTrigger: "taskTrigger";
/**
* Defines a message as a template
*/
readonly template: "template";
/**
* used to track the name of templates used to generate messages
*/
readonly sourceTemplate: "sourceTemplate";
/**
* Used to mark a message as a component. The value can be "render" or "input". The default
* value is "render" if no value is given. When the "input" value is used the rendered component
* will take input from a user then write the input received to the executing conversation.
*/
readonly component: "component";
/**
* When applied to a message the message should be rendered but not sent to LLMs
*/
readonly renderOnly: "renderOnly";
/**
* Controls where a message is rendered. By default messages are rendered in the default chat
* view, but applications can define different render targets.
*/
readonly renderTarget: "renderTarget";
/**
* Sets the renderTarget of the message to "hidden"
*/
readonly hidden: "hidden";
readonly toolId: "toolId";
/**
* When applied to the last content or component messages auto scrolling will be disabled
*/
readonly disableAutoScroll: "disableAutoScroll";
/**
* When applied to a message the content of the message will be parsed as markdown
*/
readonly markdown: "markdown";
/**
* When applied to a message the content of the message will be parsed as markdown and the
* elements of the markdown will be auto assigned to vars
*/
readonly markdownVars: "markdownVars";
/**
* When applied to a message the message is conditionally added to the flattened view of a
* conversation. When the condition is false the message will not be visible to the user
* or the LLM.
*
* @note The example below uses (@) instead of the at symbol because of a limitation of jsdoc.
*
* The example below will only render and send the second system message to the LLM
* @example
*
* ``` convo
* > define
* animal = 'dog'
*
* (@)condition animal frog
* > system
* You are a frog and you like to hop around.
*
* (@)condition animal dog
* > system
* You are a dog and you like to eat dirt.
* ```
*/
readonly condition: "condition";
/**
* When applied to a message the message is completely disregarded and removed from the conversation
*/
readonly disabled: "disabled";
/**
* A URL to the source of the message. Typically used with RAG.
*/
readonly sourceUrl: "sourceUrl";
/**
* The ID of the source content of the message. Typically used with RAG.
*/
readonly sourceId: "sourceId";
/**
* The name of the source content of the message. Typically used with RAG.
*/
readonly sourceName: "sourceName";
/**
* When applied to a message the message becomes a clickable suggestion that when clicked will
* add a new user message with the content of the message. If the suggestion tag defines a value
* that value will be displayed on the clickable button instead of the message content but the
* message content will still be used as the user messaged added to the conversation when clicked.
* Suggestion message are render only and not seen by LLMs.
*/
readonly suggestion: "suggestion";
/**
* A title display above a group of suggestions
*/
readonly suggestionTitle: "suggestionTitle";
/**
* Sets the threadId of the current message and all following messages. Using the `@thread` tag
* without a value will clear the current thread id.
*/
readonly thread: "thread";
/**
* Used to mark a function as a node output.
*/
readonly output: "output";
/**
* Used to mark a function as an error callback
*/
readonly errorCallback: "errorCallback";
/**
* Used to import external convo script code
*/
readonly import: "import";
/**
* Causes a message to be concatenated with the previous message. Both the message the tag
* is attached to and the previous message must be content messages or the tag is ignored.
* When a message is concatenated to another message all other tags except the condition
* tag are ignored.
*/
readonly concat: "concat";
/**
* Instructs the LLM to call the specified function. The values "none", "required", "auto" have
* a special meaning. If no name is given the special "required" value is used.
* - none: tells the LLM to not call any functions
* - required: tells the LLM it must call a function, any function.
* - auto: tells the LLM it can call a function respond with a text response. This is the default behaviour.
*/
readonly call: "call";
/**
* Causes the message to be evaluated as code. The code should be contained in a markdown code block.
*/
readonly eval: "eval";
/**
* Id of the user that created the message
*/
readonly userId: "userId";
/**
* Causes all white space in a content message to be preserved. By define all content message
* whitespace is preserved.
*/
readonly preSpace: "preSpace";
/**
* Indicates a message is the system message used to give an LLM instructions on how to use
* agents
*/
readonly agentSystem: "agentSystem";
/**
* Defines capabilities for a message
*/
readonly cap: "cap";
/**
* Conversation ID
*/
readonly cid: "cid";
/**
* Adds a message to a transform group. Transform groups are used to transform assistant output.
* The transform tags value can be the name of a type or empty. Transform groups are ran after all
* text responses from the assistant. Transform messages are not added to the flattened conversation.
*/
readonly transform: "transform";
/**
* Sets the name of the transform group a message will be added to when the transform tag is used.
*/
readonly transformGroup: "transformGroup";
/**
* If present on a transform message the source message processed will be hidden from the user
* but still visible to the LLM
*/
readonly transformHideSource: "transformHideSource";
/**
* Overrides `transformHideSource` and `transformRemoveSource`
*/
readonly transformKeepSource: "transformKeepSource";
/**
* If present on a transform message the source message processed will not be added to the
* conversation
*/
readonly transformRemoveSource: "transformRemoveSource";
/**
* If present the transformed message has the `renderOnly` tag applied to it causing it to be
* visible to the user but not the LLM.
*/
readonly transformRenderOnly: "transformRenderOnly";
/**
* A transform condition that will control if the component tag can be passed to the created message
*/
readonly transformComponentCondition: "transformComponentCondition";
/**
* Messages created by the transform will include the defined tag
* @example (@)transformTag renderTarget sideBar
*/
readonly transformTag: "transformTag";
/**
* A shortcut tag combines the `transform`, `transformTag`, `transformRenderOnly`, `transformComponentCondition`
* and `transformHideSource` tags to create a transform that renders a
* component based on the data structure of a named
* struct.
* @usage (@)transformComponent [groupName] {componentName} {propType} [?[!] condition]
*
* Renders the CarView component after every assistant message. The transform is using the default transform group.
* @example (@)transformComponent CarView CarProps
*
* Renders the CatPickerView component if the transformed message is a json object with the "type" key is set to cat.
* The transform is in the CatPicker transform group.
* @example (@)transformComponent CatPicker CatPickerView AnimalPrefs ? type cat
*
* Renders the AnimalsOtherThanPickerView component if the transformed message is a json object with the "type" key is NOT set to cat.
* The transform is in the default transform group.
* @example (@)transformComponent AnimalsOtherThanPickerView AnimalPrefs ?! type cat
*/
readonly transformComponent: "transformComponent";
/**
* Applied to messages created by a transform
*/
readonly createdByTransform: "createdByTransform";
/**
* When applied to a message the message will be included in all transform prompts. It is common
* to apply includeInTransforms to system messages
*/
readonly includeInTransforms: "includeInTransforms";
/**
* Describes what the result of the transform is
*/
readonly transformDescription: "transformDescription";
/**
* If applied to a transform message it will not be passed through a filter prompt
*/
readonly transformRequired: "transformRequired";
/**
* When applied to a message the transform filter will be used to select which transforms to
* to select. The default filter will list all transform groups and their descriptions to select
* the best fitting transform for the assistants response
*/
readonly transformFilter: "transformFilter";
/**
* If applied to a transform message the transform must be explicity enabled applying the `enableTransform`
* tag to another message or calling the enableTransform function.
*/
readonly transformOptional: "transformOptional";
/**
* Applied to transform output messages when overwritten by a transform with a higher priority
*/
readonly overwrittenByTransform: "overwrittenByTransform";
/**
* Explicitly enables a transform. Transforms are enabled by default unless the transform has
* the `transformOptional` tag applied.
*/
readonly enableTransform: "enableTransform";
/**
* Defines a component to render a function result
*/
readonly renderer: "renderer";
/**
* Indicates a message is a standard system message. Standard system messages are used to
* implement common patterns such as the moderator pattern.
*/
readonly stdSystem: "stdSystem";
/**
* Prevents a message from accepting modifiers and allows modifiers to flow through the message
*/
readonly disableModifiers: "disableModifiers";
/**
* Attached to a message to indicate the user has reached their limit of tokens
*/
readonly tokenLimit: "tokenLimit";
readonly router: "router";
readonly routeTo: "routeTo";
readonly routeFrom: "routeFrom";
};
/**
* Tags that are allowed to have dynamic expressions as the value when using the equals operator.
* @example (@)condition = eq(name "Bob")
*/
export declare const convoDynamicTags: string[];
/**
* Tags whom have a dynamic expression will be evaluated as an anonymous type
*/
export declare const convoAnonTypeTags: string[];
/**
* Prefix used to define anonymous types
*/
export declare const convoAnonTypePrefix = "AnonType_";
/**
* JSDoc tags can be used in combination with the Convo-Lang CLI to import types, components and
* functions from TypeScript.
*/
export declare const convoJsDocTags: {
/**
* Marks a function or class as a convo component
*/
readonly convoComponent: "convoComponent";
/**
* When used with a component the source message that gets transform into the component should be
* kept visible in the conversation
*/
readonly convoKeepSource: "convoKeepSource";
/**
* Used to ignore properties in a type
*/
readonly convoIgnore: "convoIgnore";
/**
* Marks a interface or type as a type to define in convo
*/
readonly convoType: "convoType";
/**
* Marks a function as a function to define in convo
*/
readonly convoFn: "convoFn";
/**
* Used with the convoFn tag to mark a function as local. When a function is local it is not
* exposed to the LLM but can be called from convo scripts.
*/
readonly convoLocal: "convoLocal";
};
export declare const convoTaskTriggers: {
/**
* Triggers a text message is received. Function calls will to trigger.
*/
readonly onResponse: "onResponse";
};
export declare const commonConvoCacheTypes: {
localStorage: string;
memory: string;
vfs: string;
userVfs: string;
};
/**
* In the browser the default cache type is local storage and on the backend vfs is the default cache type.
*/
export declare const defaultConvoCacheType: string;
export declare const convoDateFormat = "yyyy-MM-dd'T'HH:mm:ssxxx";
export declare const defaultConvoRenderTarget = "default";
export declare const defaultConvoTransformGroup = "default";
export declare const getConvoDateString: (date?: Date | number) => string;
export declare const defaultConvoVisionSystemMessage: string;
export declare const defaultConvoVisionResponse = "Unable to answer or respond to questions or requests for the given image or images";
export declare const allowedConvoDefinitionFunctions: readonly ["new", "struct", "map", "array", "enum", "jsonMap", "jsonArray", "getState", "enableRag", "clearRag", "defineForm", "uuid", "shortUuid", "getVar", "setVar", "idx", "setDefault", "enableTransform", "enableAllTransforms", "isUndefined", "secondMs", "minuteMs", "hourMs", "dayMs", "aryFindMatch", "aryRemoveMatch", "setObjDefaults", "is", "and", "or", "not", "eq", "gt", "gte", "lt", "lte", "isIn", "contains", "regexMatch", "starMatch", "deepCompare", "add", "sub", "mul", "div", "mod", "pow", "inc", "dec", "rand", "now", "dateTime", "encodeURI", "encodeURIComponent"];
export declare const passthroughConvoInputType = "FlatConvoConversation";
export declare const passthroughConvoOutputType = "ConvoCompletionMessageAry";
export declare const createOptionalConvoValue: (value: any) => OptionalConvoValue;
export declare const createConvoType: (typeDef: Omit<ConvoType, typeof convoObjFlag>) => ConvoType;
export declare const createConvoBaseTypeDef: (type: ConvoBaseType) => ConvoType;
export declare const makeAnyConvoType: <T>(type: ConvoBaseType, value: T) => T;
interface CreateConvoScopeFunctionOverloads {
(): ConvoScopeFunction;
(fn: ConvoScopeFunction): ConvoScopeFunction;
(flowCtrl: ConvoFlowController, fn?: ConvoScopeFunction): ConvoScopeFunction;
}
export declare const createConvoScopeFunction: CreateConvoScopeFunctionOverloads;
export declare const isConvoScopeFunction: (value: any) => value is ConvoScopeFunction;
export declare const setConvoScopeError: (scope: ConvoScope | null | undefined, error: ConvoScopeError | string) => void;
export declare const convoTagMapToCode: (tagsMap: Record<string, string | undefined>, append?: string, tab?: string) => string;
export declare const containsConvoTag: (tags: ConvoTag[] | null | undefined, tagName: string) => boolean;
export declare const getConvoTag: (tags: ConvoTag[] | null | undefined, tagName: string) => ConvoTag | undefined;
export declare const getConvoFnMessageByTag: (tag: string, messages: ConvoMessage[] | null | undefined, startIndex?: number) => ConvoMessage | undefined;
export interface FindConvoMessageOptions {
tag?: string;
tagValue?: string;
role?: string;
startIndex?: number;
}
export declare const findConvoMessage: (messages: ConvoMessage[] | null | undefined, { tag, tagValue, role, startIndex, }: FindConvoMessageOptions) => ConvoMessage | undefined;
export declare const getConvoFnByTag: (tag: string, messages: ConvoMessage[] | null | undefined, startIndex?: number) => ConvoFunction | undefined;
export declare const convoTagsToMap: (tags: ConvoTag[], exe: ConvoExecutionContext) => Record<string, string | undefined>;
export declare const mapToConvoTags: (map: Record<string, string | undefined>) => ConvoTag[];
export declare const getFlatConvoTagValues: (name: string, tags: Record<string, string | undefined> | null | undefined) => string[];
export declare const parseConvoTransformTag: (value: string) => ConvoTag | undefined;
export declare const createConvoMetadataForStatement: (statement: ConvoStatement) => ConvoMetadata;
export declare const getConvoMetadata: (value: any) => ConvoMetadata | undefined;
export declare const getConvoStructPropertyCount: (value: any) => number;
export declare const convoLabeledScopeFnParamsToObj: (scope: ConvoScope, fnParams: ConvoStatement[]) => Record<string, any>;
export declare const convoLabeledScopeParamsToObj: (scope: ConvoScope) => Record<string, any>;
export declare const convoParamsToObj: (scope: ConvoScope, unlabeledMap?: string[], unlabeledKey?: string | boolean, fallbackFnParams?: ConvoStatement[]) => Record<string, any>;
export declare const isReservedConvoRole: (role: string) => boolean;
export declare const isValidConvoRole: (role: string) => boolean;
export declare const isValidConvoIdentifier: (role: string) => boolean;
export declare const formatConvoMessage: (role: string, content: string, prefix?: string) => string;
export interface EscapeConvoMessageContentOptions {
removeNewLines?: boolean;
}
export declare const escapeConvo: (content: string | null | undefined, isStartOfMessage?: boolean, options?: EscapeConvoMessageContentOptions) => string;
export declare const escapeConvoMessageContent: (content: string | null | undefined, isStartOfMessage?: boolean, options?: EscapeConvoMessageContentOptions) => string;
export declare const spreadConvoArgs: (args: Record<string, any>, format?: boolean) => string;
export declare const defaultConvoPrintFunction: ConvoPrintFunction;
export declare const collapseConvoPipes: (statement: ConvoStatement) => number;
export declare const convoDescriptionToCommentOut: (description: string, tab: string | undefined, out: string[]) => void;
export declare const convoDescriptionToComment: (description: string, tab?: string) => string;
export declare const convoStringToCommentOut: (str: string, tab: string | undefined, out: string[]) => void;
export declare const convoStringToComment: (str: string, tab?: string) => string;
export declare const isValidConvoVarName: (name: string) => boolean;
export declare const isValidConvoFunctionName: (name: string) => boolean;
export declare const isValidConvoTypeName: (typeName: string) => boolean;
export declare const validateConvoVarName: (name: string) => void;
export declare const validateConvoFunctionName: (name: string) => void;
export declare const validateConvoTypeName: (name: string) => void;
export declare const convoUsageTokensToString: (usage: Partial<ConvoTokenUsage>) => string;
export declare const convoPartialUsageTokensToUsage: (usage: Partial<ConvoTokenUsage>) => ConvoTokenUsage;
export declare const parseConvoUsageTokens: (str: string) => ConvoTokenUsage;
export declare const addConvoUsageTokens: (to: Partial<ConvoTokenUsage>, from: Partial<ConvoTokenUsage> | string) => void;
export declare const createEmptyConvoTokenUsage: () => ConvoTokenUsage;
export declare const resetConvoUsageTokens: (usage: ConvoTokenUsage) => void;
export declare const isConvoTokenUsageEmpty: (usage: ConvoTokenUsage) => boolean;
/**
* The token price used when the input or output token price of a model is unknown. This value is
* set high to $150 per 1M tokens to avoid losing money.
*/
export declare const unknownConvoTokenPrice: number;
export declare const calculateConvoTokenUsage: (model: string, models: ConvoModelInfo[], inputTokens?: number, outputTokens?: number) => ConvoTokenUsage;
export declare const isConvoJsonMessage: (content: string | null | undefined) => boolean;
/**
* Parses message content as json if the content is in a json markdown code block
*/
export declare const parseConvoJsonOrStringMessage: (content: string | null | undefined, returnJsonAsString?: boolean) => ParsedContentJsonOrString;
export declare const parseConvoJsonMessage: (json: string, expectArray?: boolean) => any;
export declare const removeDanglingConvoUserMessage: (code: string) => string;
export declare const concatConvoCode: (a: string, b: string) => string;
export declare const concatConvoCodeAndAppendEmptyUserMessage: (a: string, b: string) => string;
export declare const isConvoMessageIncludedInTask: (msg: ConvoMessage, task: string) => boolean;
export declare const parseConvoMessageTemplate: (msg: ConvoMessage, template: string) => ConvoMessageTemplate;
export declare const getConvoStatementSource: (statement: ConvoStatement, code: string) => string;
/**
* If the value is empty, null or undefined true is returned, otherwise the Boolean
* constructor is used to parse the value.
*/
export declare const parseConvoBooleanTag: (value: string | null | undefined) => boolean;
export declare const getFlatConvoTagBoolean: (message: FlatConvoMessage | ConvoCompletionMessage | null | undefined, tagName: string) => boolean;
export declare const shouldDisableConvoAutoScroll: (messages: FlatConvoMessage[]) => boolean;
export declare const convoRagDocRefToMessage: (flat: FlatConvoConversation, docs: ConvoDocumentReference | null | undefined | (ConvoDocumentReference | null | undefined)[], role: string) => ConvoMessage | undefined;
export declare const escapeConvoTagValue: (value: string) => string;
export declare const convoMessageToString: (msg: ConvoMessage) => string;
export declare const getLastCompletionMessage: (messages: FlatConvoMessage[]) => FlatConvoMessage | undefined;
export declare const isConvoThreadFilterMatch: (filter: ConvoThreadFilter, tid: string | undefined | null) => boolean;
export declare const mergeConvoOptions: (source: ConversationOptions | null | undefined, ...overrides: (ConversationOptions | null | undefined)[]) => ConversationOptions;
export declare const getLastConvoMessageWithRole: <T extends ConvoMessage | FlatConvoMessage>(messages: T[] | undefined | null, role: string) => T | undefined;
export declare const getLastNonCalledConvoFlatMessage: (messages: FlatConvoMessage[]) => FlatConvoMessage | undefined;
export declare const getLastCalledConvoMessage: (messages: ConvoMessage[], startIndex?: number) => ConvoMessage | undefined;
export interface CreateTextConvoCompletionMessageOptions {
flat: FlatConvoConversationBase;
role: string;
content: string | null | undefined;
model: string;
models?: ConvoModelInfo[];
inputTokens?: number;
outputTokens?: number;
tokenPrice?: number;
tags?: Record<string, string | undefined>;
defaults?: ConvoCompletionMessage;
}
export declare const createTextConvoCompletionMessage: ({ flat, role, content, model, models, inputTokens, outputTokens, tokenPrice, defaults, }: CreateTextConvoCompletionMessageOptions) => ConvoCompletionMessage;
export interface CreateFunctionCallConvoCompletionMessageOptions {
flat: FlatConvoConversationBase;
model: string;
toolId?: string;
callFn: string;
callParams: Record<string, any> | undefined;
models?: ConvoModelInfo[];
inputTokens?: number;
outputTokens?: number;
tokenPrice?: number;
defaults?: ConvoCompletionMessage;
}
export declare const createFunctionCallConvoCompletionMessage: ({ flat, model, toolId, callFn, callParams, models, inputTokens, outputTokens, tokenPrice, defaults, }: CreateFunctionCallConvoCompletionMessageOptions) => ConvoCompletionMessage;
export declare const getSerializableFlatConvoConversation: (flat: FlatConvoConversation | FlatConvoConversationBase) => FlatConvoConversationBase;
export declare const flatConvoConversationToBase: (flat: FlatConvoConversation | FlatConvoConversationBase) => FlatConvoConversationBase;
export interface NormalizedFlatMessageListOptions {
/**
* Disables all processing of messages
*/
disableAll?: boolean;
/**
* If true rag messages will not be added to user message content
*/
disableRag?: boolean;
/**
* If true all system messages should be merged into a single message
*/
mergeSystemMessages?: boolean;
}
/**
* Returns the full content of the message including prefix and suffix
*/
export declare const getFullFlatConvoMessageContent: (msg: FlatConvoMessage) => string;
/**
* Normalizes flat messages before sending to LLMs. This function is typically used by converter.
*/
export declare const getNormalizedFlatMessageList: (flat: FlatConvoConversationBase, options?: NormalizedFlatMessageListOptions) => FlatConvoMessage[];
export declare const formatConvoContentSpace: (content: string) => string;
/**
* Converts the flat conversation to a string for display purposes. This function does not
* preserve all of the information of the conversation and should not be used for purposes
* outside of logging and display. For example all code in define, do and function bodies are
* lost and not part of the output of this function.
*/
export declare const getFlattenConversationDisplayString: (flat: FlatConvoConversation, includeConsoleHeaderFooter?: boolean) => string;
export interface ConversationSuggestions {
title?: string;
suggestions: string[];
messages: FlatConvoMessage[];
}
export declare const getLastConvoSuggestions: (messages: FlatConvoMessage[]) => ConversationSuggestions | undefined;
export declare const evalConvoTransformCondition: (transformContent: string, condition: string | null | undefined) => boolean;
export declare const getConvoDebugLabelComment: (label: string) => string;
export declare const isConvoModelAliasMatch: (name: string, alias: ConvoModelAlias) => boolean;
export declare const insertSystemMessageIntoFlatConvo: (msg: string, flat: FlatConvoConversation) => void;
export declare const getConvoCompletionServiceModelsAsync: (service: ConvoCompletionService<any, any>, disableCache?: boolean | undefined) => Promise<ConvoModelInfo[]>;
export declare const getConvoMessageModificationAction: (str: string) => ConvoMessageModificationAction | undefined;
/**
* Appends a value to the prefix of a flat conversation message.
* If a prefix already exists, the new value is concatenated with optional separation.
*
* @param msg - The flat conversation message to modify
* @param value - The string value to append to the prefix
* @param sep - Whether to add separator (double newlines) between existing and new content
*/
export declare const appendFlatConvoMessagePrefix: (msg: FlatConvoMessage, value: string, sep?: boolean) => void;
/**
* Appends a value to the suffix of a flat conversation message.
* If a suffix already exists, the new value is concatenated with optional separation.
*
* @param msg - The flat conversation message to modify
* @param value - The string value to append to the suffix
* @param sep - Whether to add separator (double newlines) between existing and new content
*/
export declare const appendFlatConvoMessageSuffix: (msg: FlatConvoMessage, value: string, sep?: boolean) => void;
/**
* Converts a flat convo message to a completion message
*/
export declare const convertFlatConvoMessageToCompletionMessage: (msg: FlatConvoMessage) => ConvoCompletionMessage;
export declare const getConvoSystemMessage: (type: StandardConvoSystemMessage) => string;
export declare const getFlatConvoMessageCachedJsonValue: (msg: FlatConvoMessage | null | undefined) => any;
export declare const setFlatConvoMessageCachedJsonValue: (msg: FlatConvoMessage | null | undefined, value: any) => any;
export declare const getFlatConvoMessageCondition: (msg: FlatConvoMessage | null | undefined) => ConvoTag;
export declare const setFlatConvoMessageCondition: (msg: FlatConvoMessage | null | undefined, tag: ConvoTag) => void;
/**
* Converts the messages into static convo lang with all expressions evaluated
*/
export declare const flatConvoMessagesToTextView: (messages: FlatConvoMessage[] | null | undefined) => string;
export declare const getAssumedConvoCompletionValue: (completion: ConvoCompletion) => any;
export {};