diff --git a/genaisrc/genaiscript.d.ts b/genaisrc/genaiscript.d.ts index df355fd9fa..c0a6426d2c 100644 --- a/genaisrc/genaiscript.d.ts +++ b/genaisrc/genaiscript.d.ts @@ -225,6 +225,11 @@ interface ModelOptions extends ModelConnectionOptions { * Budget of tokens to apply the prompt flex renderer. */ flexTokens?: number + + /** + * A list of model ids and their maximum number of concurrent requests. + */ + modelConcurrency?: Record } interface EmbeddingsModelConnectionOptions { @@ -711,11 +716,19 @@ type PromptSystemArgs = Omit< | "responseType" | "responseSchema" | "files" + | "modelConcurrency" > type StringLike = string | WorkspaceFile | WorkspaceFile[] -interface FenceOptions { +interface LineNumberingOptions { + /** + * Prepend each line with a line numbers. Helps with generating diffs. + */ + lineNumbers?: boolean +} + +interface FenceOptions extends LineNumberingOptions { /** * Language of the fenced code block. Defaults to "markdown". */ @@ -730,11 +743,6 @@ interface FenceOptions { | "toml" | string - /** - * Prepend each line with a line numbers. Helps with generating diffs. - */ - lineNumbers?: boolean - /** * JSON schema identifier */ @@ -775,6 +783,13 @@ interface DefOptions extends FenceOptions, ContextExpansionOptions, DataFilter { ignoreEmpty?: boolean } +/** + * Options for the `defDiff` command. + */ +interface DefDiffOptions + extends ContextExpansionOptions, + LineNumberingOptions {} + interface DefImagesOptions { detail?: "high" | "low" /** @@ -1096,14 +1111,14 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown * @param content html string or file * @param options */ - HTMLToMarkdown(content: string | WorkspaceFile): string + HTMLToMarkdown(content: string | WorkspaceFile): Promise /** * Extracts the contents of a zip archive file @@ -1264,17 +1279,238 @@ interface HTML { convertTablesToJSON( html: string, options?: HTMLTableToJSONOptions - ): object[][] + ): Promise /** * Converts HTML markup to plain text * @param html */ - convertToText(html: string): string + convertToText(html: string): Promise /** * Converts HTML markup to markdown * @param html */ - convertToMarkdown(html: string): string + convertToMarkdown(html: string): Promise +} + +interface GitHubOptions { + owner: string + repo: string + baseUrl?: string + auth?: string + ref?: string + refName?: string +} + +type GitHubWorkflowRunStatus = + | "completed" + | "action_required" + | "cancelled" + | "failure" + | "neutral" + | "skipped" + | "stale" + | "success" + | "timed_out" + | "in_progress" + | "queued" + | "requested" + | "waiting" + | "pending" + +interface GitHubWorkflowRun { + id: number + name?: string + display_title: string + status: string + conclusion: string + html_url: string + created_at: string + head_branch: string + head_sha: string +} + +interface GitHubWorkflowJob { + id: number + run_id: number + status: string + conclusion: string + name: string + html_url: string + logs_url: string + logs: string + started_at: string + completed_at: string + content: string +} + +interface GitHubIssue { + id: number + body?: string + title: string + number: number + state: string + state_reason?: "completed" | "reopened" | "not_planned" | null + html_url: string +} + +interface GitHubComment { + id: number + body?: string + created_at: string + updated_at: string + html_url: string +} + +interface GitHubPullRequest extends GitHubIssue {} + +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + +interface GitHubWorkflow { + id: number + name: string + path: string +} + +interface GitHubPaginationOptions { + page?: number + per_page?: number +} + +interface GitHubFile extends WorkspaceFile { + type: "file" | "dir" | "submodule" | "symlink" + size: number +} + +interface GitHub { + /** + * Gets connection information for octokit + */ + info(): Promise + + /** + * Lists workflows in a GitHub repository + */ + listWorkflows(options?: GitHubPaginationOptions): Promise + + /** + * Lists workflow runs for a given workflow + * @param workflowId + * @param options + */ + listWorkflowRuns( + workflow_id: string | number, + options?: { + branch?: string + event?: string + status?: GitHubWorkflowRunStatus + } & GitHubPaginationOptions + ): Promise + + /** + * Downloads a GitHub Action workflow run log + * @param runId + */ + listWorkflowJobs( + runId: number, + options?: GitHubPaginationOptions + ): Promise + + /** + * Lists issues for a given repository + * @param options + */ + listIssues( + options?: { + state?: "open" | "closed" | "all" + labels?: string + sort?: "created" | "updated" | "comments" + direction?: "asc" | "desc" + } & GitHubPaginationOptions + ): Promise + + /** + * Lists comments for a given issue + * @param issue_number + * @param options + */ + listIssueComments( + issue_number: number, + options?: GitHubPaginationOptions + ): Promise + + /** + * Lists pull requests for a given repository + * @param options + */ + listPullRequests( + options?: { + state?: "open" | "closed" | "all" + sort?: "created" | "updated" | "popularity" | "long-running" + direction?: "asc" | "desc" + } & GitHubPaginationOptions + ): Promise + + /** + * Lists comments for a given pull request + * @param pull_number + * @param options + */ + listPullRequestReviewComments( + pull_number: number, + options?: GitHubPaginationOptions + ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: GitHubPaginationOptions + ): Promise + + /** + * Lists branches in a GitHub repository + */ + listBranches(options?: GitHubPaginationOptions): Promise + + /** + * Lists tags in a GitHub repository + */ + listRepositoryLanguages(): Promise> + + /** + * Lists tags in a GitHub repository + */ + getRepositoryContent( + path?: string, + options?: { + ref?: string + glob?: string + downloadContent?: boolean + maxDownloadSize?: number + type?: (typeof GitHubFile)["type"] + } + ): Promise } interface MD { @@ -1329,11 +1565,23 @@ interface INI { stringify(value: any): string } +interface CSVStringifyOptions { + delimiter?: string + header?: boolean +} + +/** + * Interface representing CSV operations. + */ interface CSV { /** - * Parses a CSV string to an array of objects - * @param text - * @param options + * Parses a CSV string to an array of objects. + * + * @param text - The CSV string to parse. + * @param options - Optional settings for parsing. + * @param options.delimiter - The delimiter used in the CSV string. Defaults to ','. + * @param options.headers - An array of headers to use. If not provided, headers will be inferred from the first row. + * @returns An array of objects representing the parsed CSV data. */ parse( text: string, @@ -1344,9 +1592,22 @@ interface CSV { ): object[] /** - * Converts an array of object that represents a data table to a markdown table - * @param csv - * @param options + * Converts an array of objects to a CSV string. + * + * @param csv - The array of objects to convert. + * @param options - Optional settings for stringifying. + * @param options.headers - An array of headers to use. If not provided, headers will be inferred from the object keys. + * @returns A CSV string representing the data. + */ + stringify(csv: object[], options?: CSVStringifyOptions): string + + /** + * Converts an array of objects that represents a data table to a markdown table. + * + * @param csv - The array of objects to convert. + * @param options - Optional settings for markdown conversion. + * @param options.headers - An array of headers to use. If not provided, headers will be inferred from the object keys. + * @returns A markdown string representing the data table. */ markdownify(csv: object[], options?: { headers?: string[] }): string } @@ -1512,7 +1773,7 @@ interface FileOutputOptions { } interface FileOutput { - pattern: string + pattern: string[] description?: string options?: FileOutputOptions } @@ -1556,11 +1817,21 @@ interface ChatTurnGenerationContext { options?: ImportTemplateOptions ): void writeText(body: Awaitable, options?: WriteTextOptions): void + assistant( + text: Awaitable, + options?: Omit + ): void $(strings: TemplateStringsArray, ...args: any[]): PromptTemplateString fence(body: StringLike, options?: FenceOptions): void def( name: string, - body: string | WorkspaceFile | WorkspaceFile[] | ShellOutput | Fenced, + body: + | string + | WorkspaceFile + | WorkspaceFile[] + | ShellOutput + | Fenced + | RunPromptResult, options?: DefOptions ): string defData( @@ -1568,6 +1839,12 @@ interface ChatTurnGenerationContext { data: object[] | object, options?: DefDataOptions ): string + defDiff( + name: string, + left: T, + right: T, + options?: DefDiffOptions + ): string console: PromptGenerationConsole } @@ -1605,7 +1882,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string, + pattern: string | string[], description?: string, options?: FileOutputOptions ): void @@ -2255,7 +2532,7 @@ interface ShellHost { } interface ContainerPortBinding { - containerPort: OptionsOrString<"80/tcp"> + containerPort: OptionsOrString<"8000/tcp"> hostPort: string | number } @@ -2295,12 +2572,45 @@ interface ContainerOptions { ports?: ElementOrArray } +interface PromiseQueue { + /** + * Adds a new promise to the queue + * @param fn + */ + add( + function_: (...arguments_: Arguments) => Awaitable, + ...arguments_: Arguments + ): Promise + + /** + * Runs all the functions in the queue with limited concurrency + * @param fns + */ + all(fns: (() => Awaitable)[]): Promise + + /** + * Applies a function to all the values in the queue with limited concurrency + * @param values + * @param fn + */ + mapAll( + values: T[], + fn: (value: T, ...arguments_: Arguments) => Awaitable, + ...arguments_: Arguments + ): Promise +} + interface PromptHost extends ShellHost { /** * Starts a container * @param options container creation options */ container(options?: ContainerOptions): Promise + + /** + * Create a new promise queue to run async functions with limited concurrency + */ + promiseQueue(concurrency: number): PromiseQueue } interface ContainerHost extends ShellHost { @@ -2439,7 +2749,13 @@ declare function fence(body: StringLike, options?: FenceOptions): void */ declare function def( name: string, - body: string | WorkspaceFile | WorkspaceFile[] | ShellOutput | Fenced, + body: + | string + | WorkspaceFile + | WorkspaceFile[] + | ShellOutput + | Fenced + | RunPromptResult, options?: DefOptions ): string @@ -2449,7 +2765,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string, + pattern: string | string[], description?: string, options?: FileOutputOptions ): void @@ -2548,6 +2864,11 @@ declare var AICI: AICI */ declare var host: PromptHost +/** + * Access to GitHub queries for the current repository + */ +declare var github: GitHub + /** * Fetches a given URL and returns the response. * @param url @@ -2592,6 +2913,19 @@ declare function defData( options?: DefDataOptions ): string +/** + * Renders a diff of the two given values + * @param left + * @param right + * @param options + */ +declare function defDiff( + name: string, + left: T, + right: T, + options?: DefDiffOptions +): string + /** * Cancels the current prompt generation/execution with the given reason. * @param reason diff --git a/scripts/nightly.yaml b/scripts/nightly.yaml index 5e595a8f56..510aa7cfdc 100644 --- a/scripts/nightly.yaml +++ b/scripts/nightly.yaml @@ -92,7 +92,7 @@ stages: - script: echo '##vso[task.prependpath]/tmp/arm-toolchain/aarch64-none-linux-gnu/libc/usr/bin' - script: echo $PATH - script: stat /tmp/arm-toolchain/bin/aarch64-none-linux-gnu-gcc - - script: python scripts/mk_unix_dist.py --nodotnet --nojava --arch=arm64 + - script: python scripts/mk_unix_dist.py --nodotnet --java --arch=arm64 - task: CopyFiles@2 inputs: sourceFolder: dist