diff --git a/packages/sample/src/aici/genaiscript.d.ts b/packages/sample/src/aici/genaiscript.d.ts index 1c368828ae..dce3dae41c 100644 --- a/packages/sample/src/aici/genaiscript.d.ts +++ b/packages/sample/src/aici/genaiscript.d.ts @@ -124,6 +124,11 @@ interface ModelOptions { * A deterministic integer seed to use for the model. */ seed?: number + + /** + * Default value for emitting line numbers in fenced code blocks. + */ + lineNumbers?: boolean /** * Use AICI controller */ diff --git a/packages/sample/src/tla/genaiscript.d.ts b/packages/sample/src/tla/genaiscript.d.ts index 331f8aaf35..dce3dae41c 100644 --- a/packages/sample/src/tla/genaiscript.d.ts +++ b/packages/sample/src/tla/genaiscript.d.ts @@ -129,6 +129,10 @@ interface ModelOptions { * Default value for emitting line numbers in fenced code blocks. */ lineNumbers?: boolean + /** + * Use AICI controller + */ + aici?: boolean } interface PromptTemplate extends PromptLike, ModelOptions { @@ -352,11 +356,6 @@ interface ExpansionVariables { */ files: LinkedFile[] - /** - * If the contents of this variable occurs in output, an error message will be shown to the user. - */ - error: string - /** * current prompt template */ @@ -673,6 +672,60 @@ interface Parsers { annotations(content: string | LinkedFile): Diagnostic[] } +interface AICIGenOptions { + /** + * Make sure the generated text is one of the options. + */ + options?: string[] + /** + * Make sure the generated text matches given regular expression. + */ + regex?: string | RegExp + /** + * Make sure the generated text matches given yacc-like grammar. + */ + yacc?: string + /** + * Make sure the generated text is a substring of the given string. + */ + substring?: string + /** + * Used together with `substring` - treat the substring as ending the substring + * (typically '"' or similar). + */ + substringEnd?: string + /** + * Store result of the generation (as bytes) into a shared variable. + */ + storeVar?: string + /** + * Stop generation when the string is generated (the result includes the string and any following bytes (from the same token)). + */ + stopAt?: string + /** + * Stop generation when the given number of tokens have been generated. + */ + maxTokens?: number +} + +interface AICINode { + type: "aici" + name: "gen" +} + +interface AICIGenNode extends AICINode { + name: "gen" + options: AICIGenOptions +} + +interface AICI { + /** + * Generate a string that matches given constraints. + * If the tokens do not map cleanly into strings, it will contain Unicode replacement characters. + */ + gen(options: AICIGenOptions): AICIGenNode +} + interface YAML { /** * Converts an object to its YAML representation @@ -811,6 +864,11 @@ interface PromptGenerationOutput { * A map of file updates */ fileEdits: Record + + /** + * Generated variables, typically from AICI.gen + */ + genVars: Record } interface PromptContext extends RunPromptContext { @@ -853,6 +911,7 @@ interface PromptContext extends RunPromptContext { YAML: YAML CSV: CSV INI: INI + AICI: AICI } @@ -950,6 +1009,16 @@ declare var fs: FileSystem */ declare var YAML: YAML +/** + * INI parsing and stringifying. + */ +declare var INI: INI + +/** + * AICI operations + */ +declare var AICI: AICI + /** * Fetches a given URL and returns the response. * @param url