From 1e946019c89021d68e1fc9959ef0586b806c4b90 Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Wed, 6 Nov 2024 16:37:02 +0000 Subject: [PATCH 01/19] add ai rag provider meant to work with vercel ai sdk --- packages/ai/src/types.ts | 134 ++++ packages/driver/package.json | 1 + packages/driver/src/cli.mts | 6 + packages/driver/src/utils.ts | 16 +- packages/edgedb-rag-sdk/README.md | 1 + packages/edgedb-rag-sdk/package.json | 60 ++ .../src/convert-to-edgedb-rag-messages.ts | 93 +++ .../src/edgedb-embedding-model.ts | 104 +++ .../src/edgedb-embedding-settings.ts | 38 + packages/edgedb-rag-sdk/src/edgedb-error.ts | 17 + .../src/edgedb-rag-language-model.ts | 653 ++++++++++++++++++ .../edgedb-rag-sdk/src/edgedb-rag-provider.ts | 92 +++ .../edgedb-rag-sdk/src/edgedb-rag-settings.ts | 162 +++++ packages/edgedb-rag-sdk/src/index.ts | 2 + packages/edgedb-rag-sdk/src/utils.ts | 64 ++ packages/edgedb-rag-sdk/tsconfig.json | 7 + 16 files changed, 1446 insertions(+), 4 deletions(-) create mode 100644 packages/edgedb-rag-sdk/README.md create mode 100644 packages/edgedb-rag-sdk/package.json create mode 100644 packages/edgedb-rag-sdk/src/convert-to-edgedb-rag-messages.ts create mode 100644 packages/edgedb-rag-sdk/src/edgedb-embedding-model.ts create mode 100644 packages/edgedb-rag-sdk/src/edgedb-embedding-settings.ts create mode 100644 packages/edgedb-rag-sdk/src/edgedb-error.ts create mode 100644 packages/edgedb-rag-sdk/src/edgedb-rag-language-model.ts create mode 100644 packages/edgedb-rag-sdk/src/edgedb-rag-provider.ts create mode 100644 packages/edgedb-rag-sdk/src/edgedb-rag-settings.ts create mode 100644 packages/edgedb-rag-sdk/src/index.ts create mode 100644 packages/edgedb-rag-sdk/src/utils.ts create mode 100644 packages/edgedb-rag-sdk/tsconfig.json diff --git a/packages/ai/src/types.ts b/packages/ai/src/types.ts index 9e4d0c8f4..40dd806b0 100644 --- a/packages/ai/src/types.ts +++ b/packages/ai/src/types.ts @@ -1,5 +1,139 @@ export type ChatParticipantRole = "system" | "user" | "assistant" | "tool"; +import { z } from "zod"; +export type ChatParticipantRole = "system" | "user" | "assistant" | "tool"; + +export type Prompt = + | { name: string; custom?: EdgeDBRagMessage } + | { id: string; custom?: EdgeDBRagMessage[] } + | { custom: EdgeDBRagMessage[] }; + +export interface AIOptions { + model: string; + prompt?: Prompt; +} + +export interface QueryContext { + query: string; + variables?: Record; + globals?: Record; + max_object_count?: number; +} + +export interface RAGRequest { + model: string; + prompt?: Prompt; + context: QueryContext; + query: string; + stream?: boolean; +} + +export type EdgeDBRagMessage = + | EdgeDBSystemMessage + | EdgeDBUserMessage + | EdgeDBAssistantMessage + | EdgeDBToolMessage; + +export interface EdgeDBSystemMessage { + role: "system"; + content: string; +} + +export interface EdgeDBUserMessage { + role: "user"; + content: { type: "text"; text: string }[]; +} + +export interface EdgeDBAssistantMessage { + role: "assistant"; + content: string; + tool_calls?: { + id: string; + type: "function"; + function: { name: string; arguments: string }; + }[]; +} + +export interface EdgeDBToolMessage { + role: "tool"; + content: string; + tool_call_id: string; +} + +export type StreamingMessage = z.infer; + +const _edgedbRagChunkSchema = z.discriminatedUnion("type", [ + z.object({ + type: z.literal("message_start"), + message: z.object({ + id: z.string(), + model: z.string(), + role: z.enum(["assistant", "system", "user"]), + usage: z + .object({ + prompt_tokens: z.number(), + completion_tokens: z.number(), + }) + .nullish(), + }), + }), + z.object({ + type: z.literal("content_block_start"), + index: z.number(), + content_block: z.discriminatedUnion("type", [ + z.object({ + type: z.literal("text"), + text: z.string(), + }), + z.object({ + type: z.literal("tool_use"), + id: z.string().nullish(), + name: z.string(), + args: z.string().nullish(), + }), + ]), + }), + z.object({ + type: z.literal("content_block_delta"), + index: z.number(), + delta: z.discriminatedUnion("type", [ + z.object({ + type: z.literal("text_delta"), + text: z.string(), + }), + z.object({ + type: z.literal("tool_call_delta"), + args: z.string(), // partial json + }), + ]), + logprobs: z + .object({ + tokens: z.array(z.string()), + token_logprobs: z.array(z.number()), + top_logprobs: z.array(z.record(z.string(), z.number())).nullable(), + }) + .nullish(), + }), + z.object({ + type: z.literal("content_block_stop"), + index: z.number(), + }), + z.object({ + type: z.literal("message_delta"), + delta: z.object({ stop_reason: z.string() }), + usage: z.object({ completion_tokens: z.number() }).nullish(), + }), + z.object({ + type: z.literal("message_stop"), + }), + z.object({ + type: z.literal("error"), + error: z.object({ + type: z.string(), + message: z.string(), + }), + }), +]); export type Prompt = | { name: string } | { id: string } diff --git a/packages/driver/package.json b/packages/driver/package.json index 0aea8ad48..72eff1686 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -28,6 +28,7 @@ "@js-temporal/polyfill": "0.4.3", "@repo/tsconfig": "*", "@types/jest": "^29.5.12", + "@types/node": "^22.7.5", "@types/semver": "^7.5.8", "@types/shell-quote": "^1.7.5", "@types/which": "^3.0.3", diff --git a/packages/driver/src/cli.mts b/packages/driver/src/cli.mts index 401b2c1fc..32b29bdb1 100644 --- a/packages/driver/src/cli.mts +++ b/packages/driver/src/cli.mts @@ -95,6 +95,12 @@ async function main(args: string[]) { async function whichEdgeDbCli() { debug("Checking if CLI is in PATH..."); const locations = await which("edgedb", { nothrow: true, all: true }); + + if (locations == null) { + debug(" - No CLI found in PATH."); + return null; + } + for (const location of locations) { const actualLocation = await fs.realpath(location); debug( diff --git a/packages/driver/src/utils.ts b/packages/driver/src/utils.ts index 6bac038bb..f155ed9b4 100644 --- a/packages/driver/src/utils.ts +++ b/packages/driver/src/utils.ts @@ -72,8 +72,8 @@ export interface CryptoUtils { const _tokens = new WeakMap(); export type AuthenticatedFetch = ( - path: string, - init: RequestInit, + path: RequestInfo | URL, + init?: RequestInit, ) => Promise; export async function getAuthenticatedFetch( @@ -94,10 +94,18 @@ export async function getAuthenticatedFetch( _tokens.set(config, token); } - return (path: string, init: RequestInit) => { + return (input: RequestInfo | URL, init?: RequestInit) => { + let path: string; + + if (typeof input === "string") { + path = input; + } else if (input instanceof Request) { + path = input.url; + } else path = input.toString(); + const url = new URL(path, databaseUrl); - const headers = new Headers(init.headers); + const headers = new Headers(init?.headers); if (config.user !== undefined) { headers.append("X-EdgeDB-User", config.user); diff --git a/packages/edgedb-rag-sdk/README.md b/packages/edgedb-rag-sdk/README.md new file mode 100644 index 000000000..bac6eea68 --- /dev/null +++ b/packages/edgedb-rag-sdk/README.md @@ -0,0 +1 @@ +# AI SDK - EdgeDB Provider diff --git a/packages/edgedb-rag-sdk/package.json b/packages/edgedb-rag-sdk/package.json new file mode 100644 index 000000000..f51cddf09 --- /dev/null +++ b/packages/edgedb-rag-sdk/package.json @@ -0,0 +1,60 @@ +{ + "name": "@edgedb/rag-sdk", + "version": "0.0.1", + "license": "Apache-2.0", + "sideEffects": false, + "main": "./dist/index.js", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "files": [ + "/dist" + ], + "scripts": { + "build": "tsc --project tsconfig.json", + "clean": "rm -rf dist", + "lint": "eslint \"./**/*.ts*\"", + "type-check": "tsc --noEmit", + "prettier-check": "prettier --check \"./**/*.ts*\"" + }, + "exports": { + "./package.json": "./package.json", + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.mjs", + "require": "./dist/index.js" + } + }, + "dependencies": { + "@ai-sdk/provider": "0.0.24", + "@ai-sdk/provider-utils": "^1.0.20" + }, + "devDependencies": { + "@repo/tsconfig": "*", + "@types/node": "^18", + "tsup": "^8", + "typescript": "5.5.4", + "zod": "3.23.8", + "edgedb": "*" + }, + "peerDependencies": { + "zod": "^3.0.0", + "edgedb": "^1.5.0" + }, + "engines": { + "node": ">=18" + }, + "publishConfig": { + "access": "public" + }, + "homepage": "https://sdk.vercel.ai/docs", + "repository": { + "type": "git", + "url": "git+https://github.com/vercel/ai.git" + }, + "bugs": { + "url": "https://github.com/vercel/ai/issues" + }, + "keywords": [ + "ai" + ] +} diff --git a/packages/edgedb-rag-sdk/src/convert-to-edgedb-rag-messages.ts b/packages/edgedb-rag-sdk/src/convert-to-edgedb-rag-messages.ts new file mode 100644 index 000000000..148c52272 --- /dev/null +++ b/packages/edgedb-rag-sdk/src/convert-to-edgedb-rag-messages.ts @@ -0,0 +1,93 @@ +import { type LanguageModelV1Prompt } from "@ai-sdk/provider"; +import type { EdgeDBRagMessage } from "./edgedb-rag-settings"; + +export function convertToEdgeDBRagMessages( + prompt: LanguageModelV1Prompt, +): EdgeDBRagMessage[] { + const messages: EdgeDBRagMessage[] = []; + + for (const { role, content } of prompt) { + switch (role) { + case "system": { + messages.push({ role: "system", content }); + break; + } + + case "user": { + messages.push({ + role: "user", + content: content.map((part) => { + switch (part.type) { + case "text": { + return { type: "text", text: part.text }; + } + default: { + throw new Error(`Unsupported type: ${part.type}`); + } + } + }), + }); + break; + } + + case "assistant": { + let text = ""; + const toolCalls: { + id: string; + type: "function"; + function: { name: string; arguments: string }; + }[] = []; + + for (const part of content) { + switch (part.type) { + case "text": { + text += part.text; + break; + } + case "tool-call": { + toolCalls.push({ + id: part.toolCallId, + type: "function", + function: { + name: part.toolName, + arguments: JSON.stringify(part.args), + }, + }); + break; + } + + default: { + const _exhaustiveCheck: never = part; + throw new Error(`Unsupported part: ${_exhaustiveCheck}`); + } + } + } + + messages.push({ + role: "assistant", + content: text, + tool_calls: toolCalls.length > 0 ? toolCalls : undefined, + }); + break; + } + + case "tool": { + for (const toolResponse of content) { + messages.push({ + role: "tool", + content: JSON.stringify(toolResponse.result), + tool_call_id: toolResponse.toolCallId, + }); + } + break; + } + + default: { + const _exhaustiveCheck: never = role; + throw new Error(`Unsupported role: ${_exhaustiveCheck}`); + } + } + } + + return messages; +} diff --git a/packages/edgedb-rag-sdk/src/edgedb-embedding-model.ts b/packages/edgedb-rag-sdk/src/edgedb-embedding-model.ts new file mode 100644 index 000000000..87f48208d --- /dev/null +++ b/packages/edgedb-rag-sdk/src/edgedb-embedding-model.ts @@ -0,0 +1,104 @@ +import { + type EmbeddingModelV1, + TooManyEmbeddingValuesForCallError, +} from "@ai-sdk/provider"; +import { + createJsonResponseHandler, + type FetchFunction, + postJsonToApi, +} from "@ai-sdk/provider-utils"; +import { z } from "zod"; +import { + isMistralEmbeddingModel, + type EdgeDBEmbeddingModelId, + type EdgeDBEmbeddingSettings, +} from "./edgedb-embedding-settings"; +import { edgedbFailedResponseHandler } from "./edgedb-error"; + +interface EdgeDBEmbeddingConfig { + provider: string; + fetch?: FetchFunction; +} + +export class EdgeDBEmbeddingModel implements EmbeddingModelV1 { + readonly specificationVersion = "v1"; + readonly modelId: EdgeDBEmbeddingModelId; + + private readonly config: EdgeDBEmbeddingConfig; + private readonly settings: EdgeDBEmbeddingSettings; + + constructor( + modelId: EdgeDBEmbeddingModelId, + settings: EdgeDBEmbeddingSettings, + config: EdgeDBEmbeddingConfig, + ) { + this.modelId = modelId; + this.settings = settings; + this.config = config; + } + + get provider(): string { + return this.config.provider; + } + + // Mistral provider uses 32 by default, OpenAI uses 2048 + get maxEmbeddingsPerCall(): number { + return ( + this.settings.maxEmbeddingsPerCall ?? + (isMistralEmbeddingModel(this.modelId) ? 32 : 2048) + ); + } + + // I didn't find any usage of this in the vercel provider + get supportsParallelCalls(): boolean { + return this.settings.supportsParallelCalls ?? true; + } + + async doEmbed({ + values, + abortSignal, + headers, + }: Parameters["doEmbed"]>[0]): Promise< + Awaited["doEmbed"]>> + > { + if (values.length > this.maxEmbeddingsPerCall) { + throw new TooManyEmbeddingValuesForCallError({ + provider: this.provider, + modelId: this.modelId, + maxEmbeddingsPerCall: this.maxEmbeddingsPerCall, + values, + }); + } + + const { responseHeaders, value: response } = await postJsonToApi({ + url: `embeddings`, + headers, + body: { + model: this.modelId, + input: values, + encoding_format: "float", + dimensions: this.settings.dimensions, + user: this.settings.user, + }, + failedResponseHandler: edgedbFailedResponseHandler, + successfulResponseHandler: createJsonResponseHandler( + EdgeDBTextEmbeddingResponseSchema, + ), + abortSignal, + fetch: this.config.fetch, + }); + + return { + embeddings: response.data.map((item) => item.embedding), + usage: response.usage + ? { tokens: response.usage.prompt_tokens } + : undefined, + rawResponse: { headers: responseHeaders }, + }; + } +} + +const EdgeDBTextEmbeddingResponseSchema = z.object({ + data: z.array(z.object({ embedding: z.array(z.number()) })), + usage: z.object({ prompt_tokens: z.number() }).nullish(), +}); diff --git a/packages/edgedb-rag-sdk/src/edgedb-embedding-settings.ts b/packages/edgedb-rag-sdk/src/edgedb-embedding-settings.ts new file mode 100644 index 000000000..794bba9bc --- /dev/null +++ b/packages/edgedb-rag-sdk/src/edgedb-embedding-settings.ts @@ -0,0 +1,38 @@ +export type EdgeDBEmbeddingModelId = + | "text-embedding-ada-002" + | "text-embedding-3-small" + | "text-embedding-3-large" + | "mistral-embed" + | (string & {}); + +export function isMistralEmbeddingModel( + model: EdgeDBEmbeddingModelId, +): boolean { + return model === "mistral-embed"; +} + +export interface EdgeDBEmbeddingSettings { + /** +Override the maximum number of embeddings per call. + */ + maxEmbeddingsPerCall?: number; + + /** +Override the parallelism of embedding calls. + */ + supportsParallelCalls?: boolean; + + // OpenAI only + + /** +The number of dimensions the resulting output embeddings should have. +Only supported in text-embedding-3 and later models. + */ + dimensions?: number; + + /** +A unique identifier representing your end-user, which can help OpenAI to +monitor and detect abuse. +*/ + user?: string; +} diff --git a/packages/edgedb-rag-sdk/src/edgedb-error.ts b/packages/edgedb-rag-sdk/src/edgedb-error.ts new file mode 100644 index 000000000..481833530 --- /dev/null +++ b/packages/edgedb-rag-sdk/src/edgedb-error.ts @@ -0,0 +1,17 @@ +import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils"; +import { z } from "zod"; + +const edgedbErrorDataSchema = z.object({ + object: z.literal("error"), + message: z.string(), + type: z.string(), + param: z.string().nullable(), + code: z.string().nullable(), +}); + +export type EdgedDBErrorData = z.infer; + +export const edgedbFailedResponseHandler = createJsonErrorResponseHandler({ + errorSchema: edgedbErrorDataSchema, + errorToMessage: (data) => data.message, +}); diff --git a/packages/edgedb-rag-sdk/src/edgedb-rag-language-model.ts b/packages/edgedb-rag-sdk/src/edgedb-rag-language-model.ts new file mode 100644 index 000000000..6e650c3ca --- /dev/null +++ b/packages/edgedb-rag-sdk/src/edgedb-rag-language-model.ts @@ -0,0 +1,653 @@ +import { z } from "zod"; +import type { + LanguageModelV1, + LanguageModelV1StreamPart, + LanguageModelV1CallWarning, + LanguageModelV1FinishReason, + LanguageModelV1ProviderMetadata, + LanguageModelV1LogProbs, +} from "@ai-sdk/provider"; +import { + type ParseResult, + createEventSourceResponseHandler, + createJsonResponseHandler, + postJsonToApi, + generateId, +} from "@ai-sdk/provider-utils"; +import { + type EdgeDBRagConfig, + type EdgeDBRagModelId, + type EdgeDBRagSettings, + isAnthropicModel, + isOpenAIModel, +} from "./edgedb-rag-settings"; +import { edgedbFailedResponseHandler } from "./edgedb-error"; +import { + mapEdgedbRagStopReason, + getResponseMetadata, + mapOpenAICompletionLogProbs, +} from "./utils"; +import { convertToEdgeDBRagMessages } from "./convert-to-edgedb-rag-messages"; +// import type { JSONSchema7 } from "json-schema"; + +export interface EdgeDBLanguageModel extends LanguageModelV1 { + withSettings(settings: Partial): EdgeDBRagLanguageModel; +} + +export class EdgeDBRagLanguageModel implements EdgeDBLanguageModel { + readonly specificationVersion = "v1"; + readonly defaultObjectGenerationMode = "json"; + readonly supportsImageUrls = false; + + readonly modelId: EdgeDBRagModelId; + readonly settings: EdgeDBRagSettings; + + private readonly config: EdgeDBRagConfig; + + constructor( + modelId: EdgeDBRagModelId, + settings: EdgeDBRagSettings, + config: EdgeDBRagConfig, + ) { + this.modelId = modelId; + this.settings = settings; + this.config = config; + } + + get provider(): string { + return this.config.provider; + } + + withSettings(settings: Partial) { + return new EdgeDBRagLanguageModel( + this.modelId, + { ...this.settings, ...settings }, + this.config, + ); + } + + private getArgs({ + // it's not really deprecated since the v2 is not out yet that accepts toolChoice, and tools at the top level + mode, + prompt, + maxTokens, + temperature, + topP, + topK, + frequencyPenalty, + presencePenalty, + stopSequences, + responseFormat, + seed, + // providerMetadata: exists in the Vercel SDK d.ts but none of the providers use it + }: Parameters[0]) { + const type = mode.type; + + const warnings: LanguageModelV1CallWarning[] = []; + + if (frequencyPenalty != null) { + warnings.push({ + type: "unsupported-setting", + setting: "frequencyPenalty", + }); + } + + if (presencePenalty != null) { + warnings.push({ + type: "unsupported-setting", + setting: "presencePenalty", + }); + } + + if (stopSequences != null) { + warnings.push({ + type: "unsupported-setting", + setting: "stopSequences", + }); + } + + if (isAnthropicModel(this.modelId) && seed != null) { + warnings.push({ + type: "unsupported-setting", + setting: "seed", + }); + } + + if (!isAnthropicModel(this.modelId) && topK != null) { + warnings.push({ + type: "unsupported-setting", + setting: "topK", + }); + } + + if (responseFormat != null && responseFormat.type !== "text") { + warnings.push({ + type: "unsupported-setting", + setting: "responseFormat", + details: "JSON response format is not supported.", + }); + } + + // if ( + // responseFormat != null && + // responseFormat.type === "json" + // // && responseFormat.schema != null + // ) { + // warnings.push({ + // type: "unsupported-setting", + // setting: "responseFormat", + // details: "JSON response is not supported", + // // details: "JSON response format schema is not supported", + // }); + // } + + const baseArgs = { + model: this.modelId, + messages: convertToEdgeDBRagMessages(prompt), + temperature, + max_tokens: maxTokens, + top_p: topP, + seed, + // response_format: ... + + // Mistral only + safe_prompt: this.settings.safePrompt, + + // Anthropic only + top_k: topK, + + // OpenAI only + echo: this.settings.echo, + logit_bias: this.settings.logitBias, + logprobs: this.settings.logprobs, + user: this.settings.user, + }; + + switch (type) { + case "regular": { + return { + args: { + ...baseArgs, + ...prepareToolsAndToolChoice(mode, this.modelId), + }, + warnings, + }; + } + + // case 'object-json': { + // } + + // case 'object-tool': { + // } + + default: { + throw new Error(`Unsupported type: ${type}`); + } + } + } + + async doGenerate( + options: Parameters[0], + ): Promise>> { + const { args, warnings } = this.getArgs(options); + const { messages } = args; + + const { responseHeaders, value: response } = await postJsonToApi({ + url: `rag`, + headers: options.headers, + body: { + ...args, + context: this.settings.context, + ...((this.settings.prompt || messages.length > 1) && { + prompt: { + ...this.settings.prompt, + ...(messages.length > 1 && { + custom: [...(this.settings.prompt?.custom || []), ...messages], + }), + }, + }), + query: [...messages].reverse().find((msg) => msg.role === "user")! + .content[0].text, + stream: false, + }, + failedResponseHandler: edgedbFailedResponseHandler, + successfulResponseHandler: createJsonResponseHandler( + edgedbRagResponseSchema, + ), + abortSignal: options.abortSignal, + fetch: this.config.fetch, + }); + + const { messages: rawPrompt, ...rawSettings } = args; + + const { text, finish_reason, usage, logprobs, tool_calls } = response; + + return { + text: text ?? undefined, + toolCalls: tool_calls?.map((toolCall) => ({ + toolCallType: "function", + toolCallId: toolCall.id ?? generateId(), + toolName: toolCall.name, + args: JSON.stringify(toolCall.args), + })), + finishReason: mapEdgedbRagStopReason(finish_reason), + logprobs: mapOpenAICompletionLogProbs(logprobs), + usage: { + promptTokens: usage.prompt_tokens, + completionTokens: usage.completion_tokens, + }, + rawCall: { rawPrompt, rawSettings }, + rawResponse: { headers: responseHeaders }, + response: getResponseMetadata(response), + warnings, + }; + } + + async doStream( + options: Parameters[0], + ): Promise>> { + const { args, warnings } = this.getArgs(options); + const { messages } = args; + + const { responseHeaders, value: response } = await postJsonToApi({ + url: `rag`, + headers: options.headers, + body: { + ...args, + context: this.settings.context, + ...((this.settings.prompt || messages.length > 1) && { + prompt: { + ...this.settings.prompt, + ...(messages.length > 1 && { + custom: [...(this.settings.prompt?.custom || []), ...messages], + }), + }, + }), + query: [...messages].reverse().find((msg) => msg.role === "user")! + .content[0].text, + stream: true, + }, + failedResponseHandler: edgedbFailedResponseHandler, + successfulResponseHandler: + createEventSourceResponseHandler(edgedbRagChunkSchema), + abortSignal: options.abortSignal, + fetch: this.config.fetch, + }); + + const { messages: rawPrompt, ...rawSettings } = args; + + let finishReason: LanguageModelV1FinishReason = "unknown"; + let logprobs: LanguageModelV1LogProbs; + const usage: { promptTokens: number; completionTokens: number } = { + promptTokens: Number.NaN, + completionTokens: Number.NaN, + }; + + const toolCallContentBlocks: Record< + number, + { + toolCallId: string; + toolName: string; + args: string; + } + > = {}; + + const providerMetadata: LanguageModelV1ProviderMetadata | undefined = + undefined; + + return { + stream: response.pipeThrough( + new TransformStream< + ParseResult>, + LanguageModelV1StreamPart + >({ + transform(chunk, controller) { + if (!chunk.success) { + controller.enqueue({ type: "error", error: chunk.error }); + return; + } + + const value = chunk.value; + switch (value.type) { + case "message_start": { + if (value.message.usage != null) { + usage.promptTokens = value.message.usage.prompt_tokens; + usage.completionTokens = + value.message.usage.completion_tokens; + } + controller.enqueue({ + type: "response-metadata", + id: value.message.id ?? undefined, + modelId: value.message.model ?? undefined, + }); + return; + } + + case "content_block_start": { + { + const contentBlockType = value.content_block.type; + + switch (contentBlockType) { + case "text": { + return; + } + + case "tool_use": { + toolCallContentBlocks[value.index] = { + toolCallId: value.content_block.id || generateId(), + toolName: value.content_block.name, + args: value.content_block.args ?? "", + }; + return; + } + + default: { + const _exhaustiveCheck: never = contentBlockType; + throw new Error( + `Unsupported content block type: ${_exhaustiveCheck}`, + ); + } + } + } + } + + case "content_block_stop": { + // when finishing a tool call block, send the full tool call: + if (toolCallContentBlocks[value.index] != null) { + const contentBlock = toolCallContentBlocks[value.index]; + + controller.enqueue({ + type: "tool-call", + toolCallType: "function", + toolCallId: contentBlock.toolCallId, + toolName: contentBlock.toolName, + args: contentBlock.args, + }); + + delete toolCallContentBlocks[value.index]; + } + + return; + } + + case "content_block_delta": { + const deltaType = value.delta.type; + const mappedLogprobs = mapOpenAICompletionLogProbs( + value?.logprobs, + ); + if (mappedLogprobs?.length) { + if (logprobs === undefined) logprobs = []; + logprobs.push(...mappedLogprobs); + } + + switch (deltaType) { + case "text_delta": { + controller.enqueue({ + type: "text-delta", + textDelta: value.delta.text, + }); + + return; + } + + case "tool_call_delta": { + const contentBlock = toolCallContentBlocks[value.index]; + + controller.enqueue({ + type: "tool-call-delta", + toolCallType: "function", + toolCallId: contentBlock.toolCallId, + toolName: contentBlock.toolName, + argsTextDelta: value.delta.args, + }); + + contentBlock.args += value.delta.args; + + return; + } + + default: { + const _exhaustiveCheck: never = deltaType; + throw new Error( + `Unsupported delta type: ${_exhaustiveCheck}`, + ); + } + } + } + + case "message_delta": { + finishReason = mapEdgedbRagStopReason(value.delta.stop_reason); + if (value.usage) { + usage.completionTokens = value.usage.completion_tokens; + } + return; + } + + case "message_stop": { + controller.enqueue({ + type: "finish", + finishReason, + usage, + logprobs, + // can hold things like Antropic cache_creation_input_tokens and cache_read_input_tokens + providerMetadata, + }); + return; + } + + case "error": { + controller.enqueue({ type: "error", error: value.error }); + return; + } + + default: { + const _exhaustiveCheck: never = value; + throw new Error(`Unsupported chunk type: ${_exhaustiveCheck}`); + } + } + }, + }), + ), + rawCall: { rawPrompt, rawSettings }, + rawResponse: { headers: responseHeaders }, + warnings, + }; + } +} + +const edgedbRagResponseSchema = z.object({ + id: z.string().nullish(), + model: z.string().nullish(), + created: z.number().nullish(), + text: z.string().nullish(), + finish_reason: z.string().nullish(), + usage: z.object({ + prompt_tokens: z.number(), + completion_tokens: z.number(), + }), + logprobs: z + .object({ + tokens: z.array(z.string()), + token_logprobs: z.array(z.number()), + top_logprobs: z.array(z.record(z.string(), z.number())).nullable(), + }) + .nullish(), + tool_calls: z + .array( + z.object({ + id: z.string().nullish(), + type: z.literal("function"), + name: z.string(), + args: z.unknown(), + }), + ) + .nullish(), +}); + +const edgedbRagChunkSchema = z.discriminatedUnion("type", [ + z.object({ + type: z.literal("message_start"), + message: z.object({ + id: z.string(), + model: z.string(), + role: z.enum(["assistant", "system", "user"]), + usage: z + .object({ + prompt_tokens: z.number(), + completion_tokens: z.number(), + }) + .nullish(), + }), + }), + z.object({ + type: z.literal("content_block_start"), + index: z.number(), + content_block: z.discriminatedUnion("type", [ + z.object({ + type: z.literal("text"), + text: z.string(), + }), + z.object({ + type: z.literal("tool_use"), + id: z.string().nullish(), + name: z.string(), + args: z.string().nullish(), + }), + ]), + }), + z.object({ + type: z.literal("content_block_delta"), + index: z.number(), + delta: z.discriminatedUnion("type", [ + z.object({ + type: z.literal("text_delta"), + text: z.string(), + }), + z.object({ + type: z.literal("tool_call_delta"), + args: z.string(), // partial json + }), + ]), + logprobs: z + .object({ + tokens: z.array(z.string()), + token_logprobs: z.array(z.number()), + top_logprobs: z.array(z.record(z.string(), z.number())).nullable(), + }) + .nullish(), + }), + z.object({ + type: z.literal("content_block_stop"), + index: z.number(), + }), + z.object({ + type: z.literal("message_delta"), + delta: z.object({ stop_reason: z.string() }), + usage: z.object({ completion_tokens: z.number() }).nullish(), + }), + z.object({ + type: z.literal("message_stop"), + }), + // we don't ever return error event from the ext but probably we should + z.object({ + type: z.literal("error"), + error: z.object({ + type: z.string(), + message: z.string(), + }), + }), +]); + +// doesn't support atm structured outputs with OpenAI type regular +function prepareToolsAndToolChoice( + mode: Parameters[0]["mode"] & { + type: "regular"; + }, + model: EdgeDBRagModelId, +) { + const isOpenAI = isOpenAIModel(model); + const isAnthropic = isAnthropicModel(model); + + // when the tools array is empty, change it to undefined to prevent errors: + const tools = mode.tools?.length ? mode.tools : undefined; + + if (tools == null) { + return { tools: undefined, tool_choice: undefined }; + } + + const toolChoice = mode.toolChoice; + + const mappedTools = tools.map((tool) => + isAnthropic + ? { + name: tool.name, + description: tool.description, + input_schema: tool.parameters, + } + : { + type: "function", + function: { + name: tool.name, + description: tool.description, + parameters: tool.parameters, + }, + }, + ); + + if (toolChoice == null) { + return { tools: mappedTools, tool_choice: undefined }; + } + + const type = toolChoice.type; + + switch (type) { + case "auto": + return { + tools: mappedTools, + tool_choice: isAnthropic ? { type: "auto" } : "auto", + }; + case "none": + return isAnthropic + ? { tools: undefined, tool_choice: undefined } + : { tools: mappedTools, tool_choice: type }; + case "required": + return { + tools: mappedTools, + tool_choice: isAnthropic + ? { type: "any" } + : isOpenAI + ? "required" + : "any", + }; + + // mistral does not support tool mode directly, + // so we filter the tools and force the tool choice through 'any' + case "tool": + return isAnthropic + ? { + tools: mappedTools, + tool_choice: { type: "tool", name: toolChoice.toolName }, + } + : isOpenAI + ? { + tools: mappedTools, + tool_choice: { + type: "function", + function: { + name: toolChoice.toolName, + }, + }, + } + : { + tools: mappedTools.filter( + (tool) => tool.function!.name === toolChoice.toolName, + ), + tool_choice: "any", + }; + + default: { + const _exhaustiveCheck: never = type; + throw new Error(`Unsupported tool choice type: ${_exhaustiveCheck}`); + } + } +} diff --git a/packages/edgedb-rag-sdk/src/edgedb-rag-provider.ts b/packages/edgedb-rag-sdk/src/edgedb-rag-provider.ts new file mode 100644 index 000000000..d18c1cf20 --- /dev/null +++ b/packages/edgedb-rag-sdk/src/edgedb-rag-provider.ts @@ -0,0 +1,92 @@ +import { type Client, createClient } from "edgedb"; +import type { ResolvedConnectConfig } from "edgedb/dist/conUtils.js"; +import { getHTTPSCRAMAuth } from "edgedb/dist/httpScram.js"; +import { cryptoUtils } from "edgedb/dist/browserCrypto.js"; +import { getAuthenticatedFetch } from "edgedb/dist/utils.js"; +import type { + EmbeddingModelV1, + LanguageModelV1, + ProviderV1, +} from "@ai-sdk/provider"; +import { + EdgeDBRagLanguageModel, + type EdgeDBLanguageModel, +} from "./edgedb-rag-language-model"; +import type { + EdgeDBRagModelId, + EdgeDBRagSettings, +} from "./edgedb-rag-settings"; +import { EdgeDBEmbeddingModel } from "./edgedb-embedding-model"; +import type { + EdgeDBEmbeddingModelId, + EdgeDBEmbeddingSettings, +} from "./edgedb-embedding-settings"; + +const httpSCRAMAuth = getHTTPSCRAMAuth(cryptoUtils); + +export interface EdgeDBRagProvider extends ProviderV1 { + (modelId: EdgeDBRagModelId | EdgeDBEmbeddingModelId): LanguageModelV1; + + languageModel( + modelId: EdgeDBRagModelId, + settings?: EdgeDBRagSettings, + ): EdgeDBLanguageModel; + + textEmbeddingModel: ( + modelId: EdgeDBEmbeddingModelId, + settings?: EdgeDBEmbeddingSettings, + ) => EmbeddingModelV1; +} + +export async function createEdgeDBRag( + client: Client, +): Promise { + const connectConfig: ResolvedConnectConfig = ( + await (client as any).pool._getNormalizedConnectConfig() + ).connectionParams; + + const fetch = await getAuthenticatedFetch( + connectConfig, + httpSCRAMAuth, + "ext/ai/", + ); + + const createChatModel = ( + modelId: EdgeDBRagModelId, + settings: EdgeDBRagSettings = {}, + ) => + new EdgeDBRagLanguageModel(modelId, settings, { + provider: "edgedb.rag", + fetch, + }); + + const createEmbeddingModel = ( + modelId: EdgeDBEmbeddingModelId, + settings: EdgeDBEmbeddingSettings = {}, + ) => { + return new EdgeDBEmbeddingModel(modelId, settings, { + provider: "edgedb.embedding", + fetch, + }); + }; + + const provider = function (modelId: EdgeDBRagModelId) { + if (new.target) { + throw new Error( + "The EdgeDB model function cannot be called with the new keyword.", + ); + } + + return createChatModel(modelId); + }; + + provider.languageModel = createChatModel; + provider.textEmbeddingModel = createEmbeddingModel; + + return provider; +} + +/** +Default EdgeDB provider instance. + */ +export const edgedbRag = createEdgeDBRag(createClient()); diff --git a/packages/edgedb-rag-sdk/src/edgedb-rag-settings.ts b/packages/edgedb-rag-sdk/src/edgedb-rag-settings.ts new file mode 100644 index 000000000..9a0090673 --- /dev/null +++ b/packages/edgedb-rag-sdk/src/edgedb-rag-settings.ts @@ -0,0 +1,162 @@ +import type { FetchFunction } from "@ai-sdk/provider-utils"; + +export type OpenAIModelId = + | "gpt-4o" + | "gpt-4o-mini" + | "gpt-4-turbo-preview" + | "gpt-4-turbo" + | "gpt-3.5-turbo" + | "gpt-4"; + +export type MistralModelId = + | "ministral-8b-latest" + | "ministral-3b-latest" + | "mistral-small-latest" + | "mistral-medium-latest" // will be deprecated "soon" + | "mistral-large-latest" + | "codestral-latest" + | "pixtral-12b-2409" // free model + | "open-mistral-nemo" // free model + | "open-codestral-mamba"; // free model + +export type AnthropicModelId = + | "claude-3-5-sonnet-20240620" + | "claude-3-haiku-20240307" + | "claude-3-sonnet-20240229" + | "claude-3-opus-20240229"; + +export type EdgeDBRagModelId = + | OpenAIModelId + | MistralModelId + | AnthropicModelId + | (string & {}); + +export function isAnthropicModel(model: EdgeDBRagModelId): boolean { + return ( + model === "claude-3-5-sonnet-20240620" || + model === "claude-3-haiku-20240307" || + model === "claude-3-sonnet-20240229" || + model === "claude-3-opus-20240229" + ); +} + +export function isOpenAIModel(model: EdgeDBRagModelId): boolean { + return ( + model === "gpt-4o" || + model === "gpt-4o-mini" || + model === "gpt-4-turbo-preview" || + model === "gpt-4-turbo" || + model === "gpt-3.5-turbo" || + model === "gpt-4" + ); +} + +export type Prompt = + | { name: string; custom?: EdgeDBRagMessage[] } + | { id: string; custom?: EdgeDBRagMessage[] } + | { custom: EdgeDBRagMessage[] }; + +export interface QueryContext { + query: string; + variables?: Record; + globals?: Record; + max_object_count?: number; +} + +export interface EdgeDBRagConfig { + provider: string; + fetch: FetchFunction; +} + +export interface EdgeDBRagSettings { + context?: QueryContext; + prompt?: Prompt; + + // Mistral only: + + /** +Whether to inject a safety prompt before all conversations. +Defaults to `false`. + */ + safePrompt?: boolean; + + // OpenAI only + + /** +Echo back the prompt in addition to the completion. + */ + echo?: boolean; + + /** +Modify the likelihood of specified tokens appearing in the completion. + +Accepts a JSON object that maps tokens (specified by their token ID in +the GPT tokenizer) to an associated bias value from -100 to 100. You +can use this tokenizer tool to convert text to token IDs. Mathematically, +the bias is added to the logits generated by the model prior to sampling. +The exact effect will vary per model, but values between -1 and 1 should +decrease or increase likelihood of selection; values like -100 or 100 +should result in a ban or exclusive selection of the relevant token. + +As an example, you can pass {"50256": -100} to prevent the <|endoftext|> +token from being generated. + */ + logitBias?: Record; + + /** +Return the log probabilities of the tokens. Including logprobs will increase +the response size and can slow down response times. However, it can +be useful to better understand how the model is behaving. + +Setting to true will return the log probabilities of the tokens that +were generated. + +Setting to a number will return the log probabilities of the top n +tokens that were generated. + */ + logprobs?: boolean | number; + + /** +A unique identifier representing your end-user, which can help OpenAI to +monitor and detect abuse. Learn more. + */ + user?: string; + + // Anthropic only: + + // Enable Anthropic cache control (beta feature). This will add the beta header and + // allow you to use provider-specific cacheControl metadata. + // cacheControl?: boolean; +} + +export type EdgeDBRagMessage = + | EdgeDBSystemMessage + | EdgeDBUserMessage + | EdgeDBAssistantMessage + | EdgeDBToolMessage; + +export interface EdgeDBSystemMessage { + role: "system"; + content: string; +} + +export interface EdgeDBUserMessage { + role: "user"; + content: { type: "text"; text: string }[]; +} + +export interface EdgeDBAssistantMessage { + role: "assistant"; + content: string; + tool_calls?: { + id: string; + type: "function"; + function: { name: string; arguments: string }; + }[]; +} + +export interface EdgeDBToolMessage { + role: "tool"; + content: string; + tool_call_id: string; +} diff --git a/packages/edgedb-rag-sdk/src/index.ts b/packages/edgedb-rag-sdk/src/index.ts new file mode 100644 index 000000000..470dc540e --- /dev/null +++ b/packages/edgedb-rag-sdk/src/index.ts @@ -0,0 +1,2 @@ +export { createEdgeDBRag, edgedbRag } from "./edgedb-rag-provider"; +export type { EdgeDBRagProvider } from "./edgedb-rag-provider"; diff --git a/packages/edgedb-rag-sdk/src/utils.ts b/packages/edgedb-rag-sdk/src/utils.ts new file mode 100644 index 000000000..0cc07170e --- /dev/null +++ b/packages/edgedb-rag-sdk/src/utils.ts @@ -0,0 +1,64 @@ +import type { LanguageModelV1FinishReason } from "@ai-sdk/provider"; +import type { LanguageModelV1LogProbs } from "@ai-sdk/provider"; + +export function mapEdgedbRagStopReason( + finishReason: string | null | undefined, +): LanguageModelV1FinishReason { + switch (finishReason) { + case "stop": + case "end_turn": + case "stop_sequence": + return "stop"; + case "length": + case "model_length": + case "max_tokens": + return "length"; + case "tool_calls": + case "tool_use": + case "function_call": + return "tool-calls"; + // case "content_filter": + // return "content-filter"; + default: + return "unknown"; + } +} + +export function getResponseMetadata({ + id, + model, + created, +}: { + id?: string | undefined | null; + model?: string | undefined | null; + created?: number | undefined | null; +}) { + return { + id: id ?? undefined, + modelId: model ?? undefined, + timestamp: created != null ? new Date(created * 1000) : undefined, + }; +} + +interface OpenAICompletionLogProps { + tokens: string[]; + token_logprobs: number[]; + top_logprobs: Record[] | null; +} + +export function mapOpenAICompletionLogProbs( + logprobs: OpenAICompletionLogProps | null | undefined, +): LanguageModelV1LogProbs | undefined { + return logprobs?.tokens.map((token, index) => ({ + token, + logprob: logprobs.token_logprobs[index], + topLogprobs: logprobs.top_logprobs + ? Object.entries(logprobs.top_logprobs[index]).map( + ([token, logprob]) => ({ + token, + logprob, + }), + ) + : [], + })); +} diff --git a/packages/edgedb-rag-sdk/tsconfig.json b/packages/edgedb-rag-sdk/tsconfig.json new file mode 100644 index 000000000..fcef8b4e0 --- /dev/null +++ b/packages/edgedb-rag-sdk/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "@repo/tsconfig/client.json", + "compilerOptions": { + "outDir": "./dist" + }, + "include": ["src/**/*"] +} From cc676afcc8f44fe31974685705e4484360a1b3da Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Wed, 6 Nov 2024 17:13:02 +0000 Subject: [PATCH 02/19] Add readme for the edgedb-rag-provider --- packages/edgedb-rag-sdk/README.md | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/packages/edgedb-rag-sdk/README.md b/packages/edgedb-rag-sdk/README.md index bac6eea68..e44c215e1 100644 --- a/packages/edgedb-rag-sdk/README.md +++ b/packages/edgedb-rag-sdk/README.md @@ -1 +1,43 @@ # AI SDK - EdgeDB Provider + +The provider for the [Vercel AI SDK](https://sdk.vercel.ai/docs) contains language model support for +the OpenAi, Mistral and Anthropic chat and completion APIs that implements EdgeDB RAG and embedding model support for the OpenAI and Mistral embeddings API. + +## Setup + +The EdgeDB provider is available in the `@edgedb/ai-sdk` module. You can install it with: + +```bash +npm i @edgedb/ai-sdk +``` + +## Provider Instance + +You can import the default provider instance `edgedbRag` from `@edgedb/ai-sdk`: + +```ts +import { edgedbRag } from "@edgedb/ai-sdk"; +``` + +## Example + +```ts +import { generateText } from "ai"; +import { createClient } from "edgedb"; +import { edgedbRag } from "@edgedb/ai-sdk"; + +const textModel = (await edgedbRag).languageModel("gpt-4-turbo-preview"); + +const { text } = await generateText({ + model: textModel.withSettings({ + context: { query: "your context" }, + }), + prompt: "your prompt", +}); + +console.log(text); +``` + +## Documentation + +Please check out the **[EdgeDB provider documentation](https://docs.edgedb.com)** for more information. From 660a5c2f850f1521fcb316e3c9d15495fe571f6b Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Fri, 8 Nov 2024 09:09:55 +0000 Subject: [PATCH 03/19] Rename @edgedb/rag-sdk to @edgedb/vercel-ai-provider --- deno.lock | 129 ++-- packages/ai/src/types.ts | 76 -- .../README.md | 14 +- .../package.json | 3 +- .../src/convert-to-edgedb-rag-messages.ts | 0 .../src/edgedb-embedding-model.ts | 0 .../src/edgedb-embedding-settings.ts | 0 .../src/edgedb-error.ts | 0 .../src/edgedb-rag-language-model.ts | 0 .../src/edgedb-rag-provider.ts | 2 +- .../src/edgedb-rag-settings.ts | 0 .../src/index.ts | 0 .../src/utils.ts | 0 .../tsconfig.json | 0 yarn.lock | 689 +++++++++++++++++- 15 files changed, 765 insertions(+), 148 deletions(-) rename packages/{edgedb-rag-sdk => vercel-ai-provider}/README.md (65%) rename packages/{edgedb-rag-sdk => vercel-ai-provider}/package.json (93%) rename packages/{edgedb-rag-sdk => vercel-ai-provider}/src/convert-to-edgedb-rag-messages.ts (100%) rename packages/{edgedb-rag-sdk => vercel-ai-provider}/src/edgedb-embedding-model.ts (100%) rename packages/{edgedb-rag-sdk => vercel-ai-provider}/src/edgedb-embedding-settings.ts (100%) rename packages/{edgedb-rag-sdk => vercel-ai-provider}/src/edgedb-error.ts (100%) rename packages/{edgedb-rag-sdk => vercel-ai-provider}/src/edgedb-rag-language-model.ts (100%) rename packages/{edgedb-rag-sdk => vercel-ai-provider}/src/edgedb-rag-provider.ts (98%) rename packages/{edgedb-rag-sdk => vercel-ai-provider}/src/edgedb-rag-settings.ts (100%) rename packages/{edgedb-rag-sdk => vercel-ai-provider}/src/index.ts (100%) rename packages/{edgedb-rag-sdk => vercel-ai-provider}/src/utils.ts (100%) rename packages/{edgedb-rag-sdk => vercel-ai-provider}/tsconfig.json (100%) diff --git a/deno.lock b/deno.lock index 2a72433f9..c40dcfef3 100644 --- a/deno.lock +++ b/deno.lock @@ -1,30 +1,25 @@ { - "version": "3", - "packages": { - "specifiers": { - "npm:@types/node": "npm:@types/node@18.16.19", - "npm:fast-check": "npm:fast-check@3.20.0", - "npm:typescript": "npm:typescript@5.5.4" + "version": "4", + "specifiers": { + "npm:@types/node@*": "18.16.19", + "npm:fast-check@*": "3.20.0", + "npm:typescript@*": "5.5.4" + }, + "npm": { + "@types/node@18.16.19": { + "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==" }, - "npm": { - "@types/node@18.16.19": { - "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==", - "dependencies": {} - }, - "fast-check@3.20.0": { - "integrity": "sha512-pZIjqLpOZgdSLecec4GKC3Zq5702MZ34upMKxojnNVSWA0K64V3pXOBT1Wdsrc3AphLtzRBbsi8bRWF4TUGmUg==", - "dependencies": { - "pure-rand": "pure-rand@6.1.0" - } - }, - "pure-rand@6.1.0": { - "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==", - "dependencies": {} - }, - "typescript@5.5.4": { - "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", - "dependencies": {} - } + "fast-check@3.20.0": { + "integrity": "sha512-pZIjqLpOZgdSLecec4GKC3Zq5702MZ34upMKxojnNVSWA0K64V3pXOBT1Wdsrc3AphLtzRBbsi8bRWF4TUGmUg==", + "dependencies": [ + "pure-rand" + ] + }, + "pure-rand@6.1.0": { + "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==" + }, + "typescript@5.5.4": { + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==" } }, "redirects": { @@ -315,12 +310,12 @@ "integration-tests/legacy": { "packageJson": { "dependencies": [ - "npm:@edgedb/generate", + "npm:@edgedb/generate@*", "npm:@tsconfig/node-lts@^20.1.3", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", "npm:conditional-type-checks@^1.0.6", - "npm:edgedb", + "npm:edgedb@*", "npm:jest@^29.7.0", "npm:ts-jest@^29.1.4", "npm:typescript@^5.5.2" @@ -330,13 +325,13 @@ "integration-tests/lts": { "packageJson": { "dependencies": [ - "npm:@arktype/attest@^0.7.8", - "npm:@edgedb/generate", + "npm:@arktype/attest@~0.7.8", + "npm:@edgedb/generate@*", "npm:@tsconfig/node-lts@^20.1.3", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", "npm:conditional-type-checks@^1.0.6", - "npm:edgedb", + "npm:edgedb@*", "npm:fast-check@^3.19.0", "npm:jest@^29.7.0", "npm:superjson@1.13.3", @@ -348,12 +343,12 @@ "integration-tests/nightly": { "packageJson": { "dependencies": [ - "npm:@edgedb/generate", + "npm:@edgedb/generate@*", "npm:@tsconfig/node-lts@^20.1.3", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", "npm:conditional-type-checks@^1.0.6", - "npm:edgedb", + "npm:edgedb@*", "npm:jest@^29.7.0", "npm:ts-jest@^29.1.4", "npm:typescript@^5.5.2" @@ -363,12 +358,12 @@ "integration-tests/stable": { "packageJson": { "dependencies": [ - "npm:@edgedb/generate", + "npm:@edgedb/generate@*", "npm:@tsconfig/node-lts@^20.1.3", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", "npm:conditional-type-checks@^1.0.6", - "npm:edgedb", + "npm:edgedb@*", "npm:jest@^29.7.0", "npm:ts-jest@^29.1.4", "npm:typescript@^5.5.2" @@ -378,10 +373,10 @@ "packages/ai": { "packageJson": { "dependencies": [ - "npm:@repo/tsconfig", + "npm:@repo/tsconfig@*", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", - "npm:edgedb", + "npm:edgedb@*", "npm:eventsource-parser@^1.1.2", "npm:jest@29.7.0", "npm:ts-jest@29.1.4", @@ -392,12 +387,12 @@ "packages/auth-core": { "packageJson": { "dependencies": [ - "npm:@repo/tsconfig", + "npm:@repo/tsconfig@*", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", - "npm:edgedb", + "npm:edgedb@*", "npm:jest@29.7.0", - "npm:jwt-decode@^4.0.0", + "npm:jwt-decode@4", "npm:ts-jest@29.1.4", "npm:typescript@^5.5.2" ] @@ -406,11 +401,11 @@ "packages/auth-express": { "packageJson": { "dependencies": [ - "npm:@edgedb/auth-core@^0.2.1", - "npm:@repo/tsconfig", + "npm:@edgedb/auth-core@~0.2.1", + "npm:@repo/tsconfig@*", "npm:@types/express@^4.17.21", "npm:@types/node@^20.12.13", - "npm:edgedb", + "npm:edgedb@*", "npm:express@^4.19.2", "npm:typescript@^5.5.2" ] @@ -420,10 +415,10 @@ "packageJson": { "dependencies": [ "npm:@edgedb/auth-core@0.2.1", - "npm:@repo/tsconfig", + "npm:@repo/tsconfig@*", "npm:@types/node@^20.12.13", "npm:@types/react@^18.3.3", - "npm:edgedb", + "npm:edgedb@*", "npm:next@14.2.3", "npm:react@^18.3.1", "npm:typescript@^5.5.2" @@ -433,12 +428,12 @@ "packages/auth-remix": { "packageJson": { "dependencies": [ - "npm:@edgedb/auth-core@^0.2.1", + "npm:@edgedb/auth-core@~0.2.1", "npm:@remix-run/server-runtime@^2.9.2", - "npm:@repo/tsconfig", + "npm:@repo/tsconfig@*", "npm:@types/node@^20.12.13", - "npm:cookie@^0.6.0", - "npm:edgedb", + "npm:cookie@0.6", + "npm:edgedb@*", "npm:typescript@^5.5.2" ] } @@ -446,11 +441,11 @@ "packages/auth-sveltekit": { "packageJson": { "dependencies": [ - "npm:@edgedb/auth-core@^0.2.1", - "npm:@repo/tsconfig", + "npm:@edgedb/auth-core@~0.2.1", + "npm:@repo/tsconfig@*", "npm:@sveltejs/kit@^2.5.10", "npm:@types/node@^20.12.13", - "npm:edgedb", + "npm:edgedb@*", "npm:svelte@^4.2.17", "npm:typescript@^5.5.2", "npm:vite@^5.2.12" @@ -460,7 +455,7 @@ "packages/create": { "packageJson": { "dependencies": [ - "npm:@clack/prompts@^0.7.0", + "npm:@clack/prompts@0.7", "npm:@types/debug@^4.1.12", "npm:@types/node@^20.12.13", "npm:debug@^4.3.4", @@ -476,15 +471,17 @@ "packageJson": { "dependencies": [ "npm:@js-temporal/polyfill@0.4.3", - "npm:@repo/tsconfig", + "npm:@petamoriken/float16@^3.8.7", + "npm:@repo/tsconfig@*", "npm:@types/jest@^29.5.12", + "npm:@types/node@^22.7.5", "npm:@types/semver@^7.5.8", "npm:@types/shell-quote@^1.7.5", "npm:@types/which@^3.0.3", "npm:debug@^4.3.4", - "npm:env-paths@^3.0.0", + "npm:env-paths@3", "npm:fast-check@^3.19.0", - "npm:get-stdin@^9.0.0", + "npm:get-stdin@9", "npm:globby@^14.0.1", "npm:jest-environment-jsdom@^29.7.0", "npm:jest@29.7.0", @@ -493,7 +490,7 @@ "npm:ts-jest@29.1.4", "npm:tsx@^4.11.0", "npm:typescript@^5.5.2", - "npm:which@^4.0.0" + "npm:which@4" ] } }, @@ -501,19 +498,33 @@ "packageJson": { "dependencies": [ "npm:@iarna/toml@^2.2.5", - "npm:@repo/tsconfig", + "npm:@repo/tsconfig@*", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", "npm:conditional-type-checks@^1.0.6", "npm:debug@^4.3.4", - "npm:edgedb", - "npm:esbuild@^0.21.4", + "npm:edgedb@*", + "npm:esbuild@~0.21.4", "npm:globby@^14.0.1", "npm:jest@^29.7.0", "npm:ts-jest@^29.1.4", "npm:typescript@^5.5.2" ] } + }, + "packages/vercel-ai-provider": { + "packageJson": { + "dependencies": [ + "npm:@ai-sdk/provider-utils@^1.0.20", + "npm:@ai-sdk/provider@0.0.24", + "npm:@repo/tsconfig@*", + "npm:@types/node@18", + "npm:edgedb@*", + "npm:tsup@8", + "npm:typescript@5.5.4", + "npm:zod@3.23.8" + ] + } } } } diff --git a/packages/ai/src/types.ts b/packages/ai/src/types.ts index 40dd806b0..b071ed037 100644 --- a/packages/ai/src/types.ts +++ b/packages/ai/src/types.ts @@ -1,4 +1,3 @@ -export type ChatParticipantRole = "system" | "user" | "assistant" | "tool"; import { z } from "zod"; export type ChatParticipantRole = "system" | "user" | "assistant" | "tool"; @@ -134,78 +133,3 @@ const _edgedbRagChunkSchema = z.discriminatedUnion("type", [ }), }), ]); -export type Prompt = - | { name: string } - | { id: string } - | { custom: { role: ChatParticipantRole; content: string }[] }; - -export interface AIOptions { - model: string; - prompt?: Prompt; -} - -export interface QueryContext { - query: string; - variables?: Record; - globals?: Record; - max_object_count?: number; -} - -export interface RAGRequest { - model: string; - prompt?: Prompt; - context: QueryContext; - query: string; - stream?: boolean; -} - -export interface MessageStart { - type: "message_start"; - message: { - role: "assistant" | "system" | "user"; - id: string; - model: string; - }; -} - -export interface ContentBlockStart { - type: "content_block_start"; - index: number; - content_block: { - text: string; - type: "text"; - }; -} - -export interface ContentBlockDelta { - type: "content_block_delta"; - delta: { - type: "text_delta"; - text: string; - }; - index: number; -} - -export interface ContentBlockStop { - type: "content_block_stop"; - index: number; -} - -export interface MessageDelta { - type: "message_delta"; - delta: { - stop_reason: "stop"; - }; -} - -export interface MessageStop { - type: "message_stop"; -} - -export type StreamingMessage = - | MessageStart - | ContentBlockStart - | ContentBlockDelta - | ContentBlockStop - | MessageDelta - | MessageStop; diff --git a/packages/edgedb-rag-sdk/README.md b/packages/vercel-ai-provider/README.md similarity index 65% rename from packages/edgedb-rag-sdk/README.md rename to packages/vercel-ai-provider/README.md index e44c215e1..88b233178 100644 --- a/packages/edgedb-rag-sdk/README.md +++ b/packages/vercel-ai-provider/README.md @@ -1,22 +1,22 @@ -# AI SDK - EdgeDB Provider +# Provider for the Vercel AI SDK The provider for the [Vercel AI SDK](https://sdk.vercel.ai/docs) contains language model support for -the OpenAi, Mistral and Anthropic chat and completion APIs that implements EdgeDB RAG and embedding model support for the OpenAI and Mistral embeddings API. +the OpenAi, Mistral and Anthropic chat and completion APIs that implements EdgeDB RAG, and embedding model support for the OpenAI and Mistral embeddings API. ## Setup -The EdgeDB provider is available in the `@edgedb/ai-sdk` module. You can install it with: +Provider is available in the `@edgedb/vercel-ai-provider` module. You can install it with: ```bash -npm i @edgedb/ai-sdk +npm i @edgedb/vercel-ai-provider ``` ## Provider Instance -You can import the default provider instance `edgedbRag` from `@edgedb/ai-sdk`: +You can import the default provider instance `edgedbRag` from `@edgedb/vercel-ai-provider`: ```ts -import { edgedbRag } from "@edgedb/ai-sdk"; +import { edgedbRag } from "@edgedb/vercel-ai-provider"; ``` ## Example @@ -24,7 +24,7 @@ import { edgedbRag } from "@edgedb/ai-sdk"; ```ts import { generateText } from "ai"; import { createClient } from "edgedb"; -import { edgedbRag } from "@edgedb/ai-sdk"; +import { edgedbRag } from "@edgedb/vercel-ai-provider"; const textModel = (await edgedbRag).languageModel("gpt-4-turbo-preview"); diff --git a/packages/edgedb-rag-sdk/package.json b/packages/vercel-ai-provider/package.json similarity index 93% rename from packages/edgedb-rag-sdk/package.json rename to packages/vercel-ai-provider/package.json index f51cddf09..671b9cdb3 100644 --- a/packages/edgedb-rag-sdk/package.json +++ b/packages/vercel-ai-provider/package.json @@ -1,5 +1,6 @@ { - "name": "@edgedb/rag-sdk", + "name": "@edgedb/vercel-ai-provider", + "description": "Provider for the Vercel AI SDK", "version": "0.0.1", "license": "Apache-2.0", "sideEffects": false, diff --git a/packages/edgedb-rag-sdk/src/convert-to-edgedb-rag-messages.ts b/packages/vercel-ai-provider/src/convert-to-edgedb-rag-messages.ts similarity index 100% rename from packages/edgedb-rag-sdk/src/convert-to-edgedb-rag-messages.ts rename to packages/vercel-ai-provider/src/convert-to-edgedb-rag-messages.ts diff --git a/packages/edgedb-rag-sdk/src/edgedb-embedding-model.ts b/packages/vercel-ai-provider/src/edgedb-embedding-model.ts similarity index 100% rename from packages/edgedb-rag-sdk/src/edgedb-embedding-model.ts rename to packages/vercel-ai-provider/src/edgedb-embedding-model.ts diff --git a/packages/edgedb-rag-sdk/src/edgedb-embedding-settings.ts b/packages/vercel-ai-provider/src/edgedb-embedding-settings.ts similarity index 100% rename from packages/edgedb-rag-sdk/src/edgedb-embedding-settings.ts rename to packages/vercel-ai-provider/src/edgedb-embedding-settings.ts diff --git a/packages/edgedb-rag-sdk/src/edgedb-error.ts b/packages/vercel-ai-provider/src/edgedb-error.ts similarity index 100% rename from packages/edgedb-rag-sdk/src/edgedb-error.ts rename to packages/vercel-ai-provider/src/edgedb-error.ts diff --git a/packages/edgedb-rag-sdk/src/edgedb-rag-language-model.ts b/packages/vercel-ai-provider/src/edgedb-rag-language-model.ts similarity index 100% rename from packages/edgedb-rag-sdk/src/edgedb-rag-language-model.ts rename to packages/vercel-ai-provider/src/edgedb-rag-language-model.ts diff --git a/packages/edgedb-rag-sdk/src/edgedb-rag-provider.ts b/packages/vercel-ai-provider/src/edgedb-rag-provider.ts similarity index 98% rename from packages/edgedb-rag-sdk/src/edgedb-rag-provider.ts rename to packages/vercel-ai-provider/src/edgedb-rag-provider.ts index d18c1cf20..ce7922fbc 100644 --- a/packages/edgedb-rag-sdk/src/edgedb-rag-provider.ts +++ b/packages/vercel-ai-provider/src/edgedb-rag-provider.ts @@ -87,6 +87,6 @@ export async function createEdgeDBRag( } /** -Default EdgeDB provider instance. +Default provider instance. */ export const edgedbRag = createEdgeDBRag(createClient()); diff --git a/packages/edgedb-rag-sdk/src/edgedb-rag-settings.ts b/packages/vercel-ai-provider/src/edgedb-rag-settings.ts similarity index 100% rename from packages/edgedb-rag-sdk/src/edgedb-rag-settings.ts rename to packages/vercel-ai-provider/src/edgedb-rag-settings.ts diff --git a/packages/edgedb-rag-sdk/src/index.ts b/packages/vercel-ai-provider/src/index.ts similarity index 100% rename from packages/edgedb-rag-sdk/src/index.ts rename to packages/vercel-ai-provider/src/index.ts diff --git a/packages/edgedb-rag-sdk/src/utils.ts b/packages/vercel-ai-provider/src/utils.ts similarity index 100% rename from packages/edgedb-rag-sdk/src/utils.ts rename to packages/vercel-ai-provider/src/utils.ts diff --git a/packages/edgedb-rag-sdk/tsconfig.json b/packages/vercel-ai-provider/tsconfig.json similarity index 100% rename from packages/edgedb-rag-sdk/tsconfig.json rename to packages/vercel-ai-provider/tsconfig.json diff --git a/yarn.lock b/yarn.lock index 0e7c7eb45..8f1b631c5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,30 @@ # yarn lockfile v1 +"@ai-sdk/provider-utils@^1.0.20": + version "1.0.22" + resolved "https://registry.yarnpkg.com/@ai-sdk/provider-utils/-/provider-utils-1.0.22.tgz#5397a193587709796d012fc04e2df9903b70852f" + integrity sha512-YHK2rpj++wnLVc9vPGzGFP3Pjeld2MwhKinetA0zKXOoHAT/Jit5O8kZsxcSlJPu9wvcGT1UGZEjZrtO7PfFOQ== + dependencies: + "@ai-sdk/provider" "0.0.26" + eventsource-parser "^1.1.2" + nanoid "^3.3.7" + secure-json-parse "^2.7.0" + +"@ai-sdk/provider@0.0.24": + version "0.0.24" + resolved "https://registry.yarnpkg.com/@ai-sdk/provider/-/provider-0.0.24.tgz#e794f4255a833c47aeffcd8f6808a79b2a6b1f06" + integrity sha512-XMsNGJdGO+L0cxhhegtqZ8+T6nn4EoShS819OvCgI2kLbYTIvk0GWFGD0AXJmxkxs3DrpsJxKAFukFR7bvTkgQ== + dependencies: + json-schema "0.4.0" + +"@ai-sdk/provider@0.0.26": + version "0.0.26" + resolved "https://registry.yarnpkg.com/@ai-sdk/provider/-/provider-0.0.26.tgz#52c3d5eb65cf7592c77c78decadf77cbec978934" + integrity sha512-dQkfBDs2lTYpKM8389oopPdQgIU007GQyCbuPPrV+K6MtSII3HBfE0stUIMXUb44L+LK1t6GXPP7wjSzjO6uKg== + dependencies: + json-schema "^0.4.0" + "@ampproject/remapping@^2.2.0", "@ampproject/remapping@^2.2.1": version "2.3.0" resolved "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz" @@ -515,6 +539,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.4.tgz#f83eb142df3ca7b49531c1ed680b81e484316508" integrity sha512-Zrm+B33R4LWPLjDEVnEqt2+SLTATlru1q/xYKVn8oVTbiRBGmK2VIMoIYGJDGyftnGaC788IuzGFAlb7IQ0Y8A== +"@esbuild/aix-ppc64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.24.0.tgz#b57697945b50e99007b4c2521507dc613d4a648c" + integrity sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw== + "@esbuild/android-arm64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.20.2.tgz#db1c9202a5bc92ea04c7b6840f1bbe09ebf9e6b9" @@ -525,6 +554,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.21.4.tgz#dd328039daccd6033b2d1e536c054914bfc92287" integrity sha512-fYFnz+ObClJ3dNiITySBUx+oNalYUT18/AryMxfovLkYWbutXsct3Wz2ZWAcGGppp+RVVX5FiXeLYGi97umisA== +"@esbuild/android-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.24.0.tgz#1add7e0af67acefd556e407f8497e81fddad79c0" + integrity sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w== + "@esbuild/android-arm@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.20.2.tgz#3b488c49aee9d491c2c8f98a909b785870d6e995" @@ -535,6 +569,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.21.4.tgz#76767a989720a97b206ea14c52af6e4589e48b0d" integrity sha512-E7H/yTd8kGQfY4z9t3nRPk/hrhaCajfA3YSQSBrst8B+3uTcgsi8N+ZWYCaeIDsiVs6m65JPCaQN/DxBRclF3A== +"@esbuild/android-arm@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.24.0.tgz#ab7263045fa8e090833a8e3c393b60d59a789810" + integrity sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew== + "@esbuild/android-x64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.20.2.tgz#3b1628029e5576249d2b2d766696e50768449f98" @@ -545,6 +584,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.21.4.tgz#14a8ae3c35702d882086efb5a8f8d7b0038d8d35" integrity sha512-mDqmlge3hFbEPbCWxp4fM6hqq7aZfLEHZAKGP9viq9wMUBVQx202aDIfc3l+d2cKhUJM741VrCXEzRFhPDKH3Q== +"@esbuild/android-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.24.0.tgz#e8f8b196cfdfdd5aeaebbdb0110983460440e705" + integrity sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ== + "@esbuild/darwin-arm64@0.20.2": version "0.20.2" resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.20.2.tgz" @@ -555,6 +599,11 @@ resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.4.tgz" integrity sha512-72eaIrDZDSiWqpmCzVaBD58c8ea8cw/U0fq/PPOTqE3c53D0xVMRt2ooIABZ6/wj99Y+h4ksT/+I+srCDLU9TA== +"@esbuild/darwin-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.24.0.tgz#2d0d9414f2acbffd2d86e98253914fca603a53dd" + integrity sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw== + "@esbuild/darwin-x64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.20.2.tgz#90ed098e1f9dd8a9381695b207e1cff45540a0d0" @@ -565,6 +614,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.21.4.tgz#db623553547a5fe3502a63aa88306e9023178482" integrity sha512-uBsuwRMehGmw1JC7Vecu/upOjTsMhgahmDkWhGLWxIgUn2x/Y4tIwUZngsmVb6XyPSTXJYS4YiASKPcm9Zitag== +"@esbuild/darwin-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.24.0.tgz#33087aab31a1eb64c89daf3d2cf8ce1775656107" + integrity sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA== + "@esbuild/freebsd-arm64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.2.tgz#d71502d1ee89a1130327e890364666c760a2a911" @@ -575,6 +629,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.4.tgz#91cbad647c079bf932086fbd4749d7f563df67b8" integrity sha512-8JfuSC6YMSAEIZIWNL3GtdUT5NhUA/CMUCpZdDRolUXNAXEE/Vbpe6qlGLpfThtY5NwXq8Hi4nJy4YfPh+TwAg== +"@esbuild/freebsd-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.24.0.tgz#bb76e5ea9e97fa3c753472f19421075d3a33e8a7" + integrity sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA== + "@esbuild/freebsd-x64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.20.2.tgz#aa5ea58d9c1dd9af688b8b6f63ef0d3d60cea53c" @@ -585,6 +644,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.21.4.tgz#723299b9859ccbe5532fecbadba3ac33019ba8e8" integrity sha512-8d9y9eQhxv4ef7JmXny7591P/PYsDFc4+STaxC1GBv0tMyCdyWfXu2jBuqRsyhY8uL2HU8uPyscgE2KxCY9imQ== +"@esbuild/freebsd-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.24.0.tgz#e0e2ce9249fdf6ee29e5dc3d420c7007fa579b93" + integrity sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ== + "@esbuild/linux-arm64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.20.2.tgz#055b63725df678379b0f6db9d0fa85463755b2e5" @@ -595,6 +659,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.21.4.tgz#531743f861e1ef6e50b874d6c784cda37aa5e685" integrity sha512-/GLD2orjNU50v9PcxNpYZi+y8dJ7e7/LhQukN3S4jNDXCKkyyiyAz9zDw3siZ7Eh1tRcnCHAo/WcqKMzmi4eMQ== +"@esbuild/linux-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.24.0.tgz#d1b2aa58085f73ecf45533c07c82d81235388e75" + integrity sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g== + "@esbuild/linux-arm@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.20.2.tgz#76b3b98cb1f87936fbc37f073efabad49dcd889c" @@ -605,6 +674,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.21.4.tgz#1144b5654764960dd97d90ddf0893a9afc63ad91" integrity sha512-2rqFFefpYmpMs+FWjkzSgXg5vViocqpq5a1PSRgT0AvSgxoXmGF17qfGAzKedg6wAwyM7UltrKVo9kxaJLMF/g== +"@esbuild/linux-arm@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.24.0.tgz#8e4915df8ea3e12b690a057e77a47b1d5935ef6d" + integrity sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw== + "@esbuild/linux-ia32@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.20.2.tgz#c0e5e787c285264e5dfc7a79f04b8b4eefdad7fa" @@ -615,6 +689,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.21.4.tgz#c81b6f2ed3308d3b75ccefb5ac63bc4cf3a9d2e9" integrity sha512-pNftBl7m/tFG3t2m/tSjuYeWIffzwAZT9m08+9DPLizxVOsUl8DdFzn9HvJrTQwe3wvJnwTdl92AonY36w/25g== +"@esbuild/linux-ia32@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.24.0.tgz#8200b1110666c39ab316572324b7af63d82013fb" + integrity sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA== + "@esbuild/linux-loong64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.20.2.tgz#a6184e62bd7cdc63e0c0448b83801001653219c5" @@ -625,6 +704,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.21.4.tgz#87b6af7cd0f2551653955fc2dc465b7f4464af0a" integrity sha512-cSD2gzCK5LuVX+hszzXQzlWya6c7hilO71L9h4KHwqI4qeqZ57bAtkgcC2YioXjsbfAv4lPn3qe3b00Zt+jIfQ== +"@esbuild/linux-loong64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.24.0.tgz#6ff0c99cf647504df321d0640f0d32e557da745c" + integrity sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g== + "@esbuild/linux-mips64el@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.20.2.tgz#d08e39ce86f45ef8fc88549d29c62b8acf5649aa" @@ -635,6 +719,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.21.4.tgz#fec73cd39490a0c45d052bef03e011a0ad366c06" integrity sha512-qtzAd3BJh7UdbiXCrg6npWLYU0YpufsV9XlufKhMhYMJGJCdfX/G6+PNd0+v877X1JG5VmjBLUiFB0o8EUSicA== +"@esbuild/linux-mips64el@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.24.0.tgz#3f720ccd4d59bfeb4c2ce276a46b77ad380fa1f3" + integrity sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA== + "@esbuild/linux-ppc64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.20.2.tgz#8d252f0b7756ffd6d1cbde5ea67ff8fd20437f20" @@ -645,6 +734,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.21.4.tgz#ea3b5e13b0fc8666bd4c6f7ea58bd1830f3e6e78" integrity sha512-yB8AYzOTaL0D5+2a4xEy7OVvbcypvDR05MsB/VVPVA7nL4hc5w5Dyd/ddnayStDgJE59fAgNEOdLhBxjfx5+dg== +"@esbuild/linux-ppc64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.24.0.tgz#9d6b188b15c25afd2e213474bf5f31e42e3aa09e" + integrity sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ== + "@esbuild/linux-riscv64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.20.2.tgz#19f6dcdb14409dae607f66ca1181dd4e9db81300" @@ -655,6 +749,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.21.4.tgz#80d406f653fc6b193edaeb55ac88d4ac22c8f155" integrity sha512-Y5AgOuVzPjQdgU59ramLoqSSiXddu7F3F+LI5hYy/d1UHN7K5oLzYBDZe23QmQJ9PIVUXwOdKJ/jZahPdxzm9w== +"@esbuild/linux-riscv64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.24.0.tgz#f989fdc9752dfda286c9cd87c46248e4dfecbc25" + integrity sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw== + "@esbuild/linux-s390x@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.20.2.tgz#3c830c90f1a5d7dd1473d5595ea4ebb920988685" @@ -665,6 +764,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.21.4.tgz#9cbd26854b5b12cf22fb54c96cd1adffaf6ace6f" integrity sha512-Iqc/l/FFwtt8FoTK9riYv9zQNms7B8u+vAI/rxKuN10HgQIXaPzKZc479lZ0x6+vKVQbu55GdpYpeNWzjOhgbA== +"@esbuild/linux-s390x@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.24.0.tgz#29ebf87e4132ea659c1489fce63cd8509d1c7319" + integrity sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g== + "@esbuild/linux-x64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.20.2.tgz#86eca35203afc0d9de0694c64ec0ab0a378f6fff" @@ -675,6 +779,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.21.4.tgz#44dfe1c5cad855362c830c604dba97fbb16fc114" integrity sha512-Td9jv782UMAFsuLZINfUpoF5mZIbAj+jv1YVtE58rFtfvoKRiKSkRGQfHTgKamLVT/fO7203bHa3wU122V/Bdg== +"@esbuild/linux-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.24.0.tgz#4af48c5c0479569b1f359ffbce22d15f261c0cef" + integrity sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA== + "@esbuild/netbsd-x64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.20.2.tgz#e771c8eb0e0f6e1877ffd4220036b98aed5915e6" @@ -685,6 +794,16 @@ resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.21.4.tgz#89b97d823e1cc4bf8c4e5dc8f76c8d6ceb1c87f3" integrity sha512-Awn38oSXxsPMQxaV0Ipb7W/gxZtk5Tx3+W+rAPdZkyEhQ6968r9NvtkjhnhbEgWXYbgV+JEONJ6PcdBS+nlcpA== +"@esbuild/netbsd-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.24.0.tgz#1ae73d23cc044a0ebd4f198334416fb26c31366c" + integrity sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg== + +"@esbuild/openbsd-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.24.0.tgz#5d904a4f5158c89859fd902c427f96d6a9e632e2" + integrity sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg== + "@esbuild/openbsd-x64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.20.2.tgz#9a795ae4b4e37e674f0f4d716f3e226dd7c39baf" @@ -695,6 +814,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.21.4.tgz#080715bb4981c326364320d7b56835608e2bd98d" integrity sha512-IsUmQeCY0aU374R82fxIPu6vkOybWIMc3hVGZ3ChRwL9hA1TwY+tS0lgFWV5+F1+1ssuvvXt3HFqe8roCip8Hg== +"@esbuild/openbsd-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.24.0.tgz#4c8aa88c49187c601bae2971e71c6dc5e0ad1cdf" + integrity sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q== + "@esbuild/sunos-x64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.20.2.tgz#7df23b61a497b8ac189def6e25a95673caedb03f" @@ -705,6 +829,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.21.4.tgz#8d838a8ac80e211536490108b72fb0091a811626" integrity sha512-hsKhgZ4teLUaDA6FG/QIu2q0rI6I36tZVfM4DBZv3BG0mkMIdEnMbhc4xwLvLJSS22uWmaVkFkqWgIS0gPIm+A== +"@esbuild/sunos-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.24.0.tgz#8ddc35a0ea38575fa44eda30a5ee01ae2fa54dd4" + integrity sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA== + "@esbuild/win32-arm64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.20.2.tgz#f1ae5abf9ca052ae11c1bc806fb4c0f519bacf90" @@ -715,6 +844,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.21.4.tgz#94afb4c2ac89b0f09791606d6d93fdab322f81c8" integrity sha512-UUfMgMoXPoA/bvGUNfUBFLCh0gt9dxZYIx9W4rfJr7+hKe5jxxHmfOK8YSH4qsHLLN4Ck8JZ+v7Q5fIm1huErg== +"@esbuild/win32-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.24.0.tgz#6e79c8543f282c4539db684a207ae0e174a9007b" + integrity sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA== + "@esbuild/win32-ia32@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.20.2.tgz#241fe62c34d8e8461cd708277813e1d0ba55ce23" @@ -725,6 +859,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.21.4.tgz#822085cd52f2f1dd90eabb59346ffa779c0bab83" integrity sha512-yIxbspZb5kGCAHWm8dexALQ9en1IYDfErzjSEq1KzXFniHv019VT3mNtTK7t8qdy4TwT6QYHI9sEZabONHg+aw== +"@esbuild/win32-ia32@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.24.0.tgz#057af345da256b7192d18b676a02e95d0fa39103" + integrity sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw== + "@esbuild/win32-x64@0.20.2": version "0.20.2" resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.20.2.tgz#9c907b21e30a52db959ba4f80bb01a0cc403d5cc" @@ -735,6 +874,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.21.4.tgz#11ef0398f9abee161193461910a507ef0d4c0c32" integrity sha512-sywLRD3UK/qRJt0oBwdpYLBibk7KiRfbswmWRDabuncQYSlf8aLEEUor/oP6KRz8KEG+HoiVLBhPRD5JWjS8Sg== +"@esbuild/win32-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.24.0.tgz#168ab1c7e1c318b922637fad8f339d48b01e1244" + integrity sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA== + "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": version "4.4.0" resolved "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz" @@ -796,6 +940,18 @@ resolved "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz" integrity sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg== +"@isaacs/cliui@^8.0.2": + version "8.0.2" + resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" + integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA== + dependencies: + string-width "^5.1.2" + string-width-cjs "npm:string-width@^4.2.0" + strip-ansi "^7.0.1" + strip-ansi-cjs "npm:strip-ansi@^6.0.1" + wrap-ansi "^8.1.0" + wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" + "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz" @@ -1004,7 +1160,7 @@ "@types/yargs" "^17.0.8" chalk "^4.0.0" -"@jridgewell/gen-mapping@^0.3.5": +"@jridgewell/gen-mapping@^0.3.2", "@jridgewell/gen-mapping@^0.3.5": version "0.3.5" resolved "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz" integrity sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg== @@ -1120,6 +1276,11 @@ resolved "https://registry.yarnpkg.com/@petamoriken/float16/-/float16-3.8.7.tgz#16073fb1b9867eaa5b254573484d09100700aaa4" integrity sha512-/Ri4xDDpe12NT6Ex/DRgHzLlobiQXEW/hmG08w1wj/YU7hLemk97c+zHQFp0iZQ9r7YqgLEXZR2sls4HxBf9NA== +"@pkgjs/parseargs@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" + integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== + "@polka/url@^1.0.0-next.24": version "1.0.0-next.25" resolved "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.25.tgz" @@ -1148,81 +1309,171 @@ resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.18.0.tgz#bbd0e616b2078cd2d68afc9824d1fadb2f2ffd27" integrity sha512-Tya6xypR10giZV1XzxmH5wr25VcZSncG0pZIjfePT0OVBvqNEurzValetGNarVrGiq66EBVAFn15iYX4w6FKgQ== +"@rollup/rollup-android-arm-eabi@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.4.tgz#c460b54c50d42f27f8254c435a4f3b3e01910bc8" + integrity sha512-jfUJrFct/hTA0XDM5p/htWKoNNTbDLY0KRwEt6pyOA6k2fmk0WVwl65PdUdJZgzGEHWx+49LilkcSaumQRyNQw== + "@rollup/rollup-android-arm64@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.18.0.tgz#97255ef6384c5f73f4800c0de91f5f6518e21203" integrity sha512-avCea0RAP03lTsDhEyfy+hpfr85KfyTctMADqHVhLAF3MlIkq83CP8UfAHUssgXTYd+6er6PaAhx/QGv4L1EiA== +"@rollup/rollup-android-arm64@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.24.4.tgz#96e01f3a04675d8d5973ab8d3fd6bc3be21fa5e1" + integrity sha512-j4nrEO6nHU1nZUuCfRKoCcvh7PIywQPUCBa2UsootTHvTHIoIu2BzueInGJhhvQO/2FTRdNYpf63xsgEqH9IhA== + "@rollup/rollup-darwin-arm64@4.18.0": version "4.18.0" resolved "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.18.0.tgz" integrity sha512-IWfdwU7KDSm07Ty0PuA/W2JYoZ4iTj3TUQjkVsO/6U+4I1jN5lcR71ZEvRh52sDOERdnNhhHU57UITXz5jC1/w== +"@rollup/rollup-darwin-arm64@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.24.4.tgz#9b2ec23b17b47cbb2f771b81f86ede3ac6730bce" + integrity sha512-GmU/QgGtBTeraKyldC7cDVVvAJEOr3dFLKneez/n7BvX57UdhOqDsVwzU7UOnYA7AAOt+Xb26lk79PldDHgMIQ== + "@rollup/rollup-darwin-x64@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.18.0.tgz#e07d76de1cec987673e7f3d48ccb8e106d42c05c" integrity sha512-n2LMsUz7Ynu7DoQrSQkBf8iNrjOGyPLrdSg802vk6XT3FtsgX6JbE8IHRvposskFm9SNxzkLYGSq9QdpLYpRNA== +"@rollup/rollup-darwin-x64@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.24.4.tgz#f30e4ee6929e048190cf10e0daa8e8ae035b6e46" + integrity sha512-N6oDBiZCBKlwYcsEPXGDE4g9RoxZLK6vT98M8111cW7VsVJFpNEqvJeIPfsCzbf0XEakPslh72X0gnlMi4Ddgg== + +"@rollup/rollup-freebsd-arm64@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.24.4.tgz#c54b2373ec5bcf71f08c4519c7ae80a0b6c8e03b" + integrity sha512-py5oNShCCjCyjWXCZNrRGRpjWsF0ic8f4ieBNra5buQz0O/U6mMXCpC1LvrHuhJsNPgRt36tSYMidGzZiJF6mw== + +"@rollup/rollup-freebsd-x64@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.24.4.tgz#3bc53aa29d5a34c28ba8e00def76aa612368458e" + integrity sha512-L7VVVW9FCnTTp4i7KrmHeDsDvjB4++KOBENYtNYAiYl96jeBThFfhP6HVxL74v4SiZEVDH/1ILscR5U9S4ms4g== + "@rollup/rollup-linux-arm-gnueabihf@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.18.0.tgz#9f1a6d218b560c9d75185af4b8bb42f9f24736b8" integrity sha512-C/zbRYRXFjWvz9Z4haRxcTdnkPt1BtCkz+7RtBSuNmKzMzp3ZxdM28Mpccn6pt28/UWUCTXa+b0Mx1k3g6NOMA== +"@rollup/rollup-linux-arm-gnueabihf@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.24.4.tgz#c85aedd1710c9e267ee86b6d1ce355ecf7d9e8d9" + integrity sha512-10ICosOwYChROdQoQo589N5idQIisxjaFE/PAnX2i0Zr84mY0k9zul1ArH0rnJ/fpgiqfu13TFZR5A5YJLOYZA== + "@rollup/rollup-linux-arm-musleabihf@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.18.0.tgz#53618b92e6ffb642c7b620e6e528446511330549" integrity sha512-l3m9ewPgjQSXrUMHg93vt0hYCGnrMOcUpTz6FLtbwljo2HluS4zTXFy2571YQbisTnfTKPZ01u/ukJdQTLGh9A== +"@rollup/rollup-linux-arm-musleabihf@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.24.4.tgz#e77313408bf13995aecde281aec0cceb08747e42" + integrity sha512-ySAfWs69LYC7QhRDZNKqNhz2UKN8LDfbKSMAEtoEI0jitwfAG2iZwVqGACJT+kfYvvz3/JgsLlcBP+WWoKCLcw== + "@rollup/rollup-linux-arm64-gnu@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.18.0.tgz#99a7ba5e719d4f053761a698f7b52291cefba577" integrity sha512-rJ5D47d8WD7J+7STKdCUAgmQk49xuFrRi9pZkWoRD1UeSMakbcepWXPF8ycChBoAqs1pb2wzvbY6Q33WmN2ftw== +"@rollup/rollup-linux-arm64-gnu@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.24.4.tgz#633f632397b3662108cfaa1abca2a80b85f51102" + integrity sha512-uHYJ0HNOI6pGEeZ/5mgm5arNVTI0nLlmrbdph+pGXpC9tFHFDQmDMOEqkmUObRfosJqpU8RliYoGz06qSdtcjg== + "@rollup/rollup-linux-arm64-musl@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.18.0.tgz#f53db99a45d9bc00ce94db8a35efa7c3c144a58c" integrity sha512-be6Yx37b24ZwxQ+wOQXXLZqpq4jTckJhtGlWGZs68TgdKXJgw54lUUoFYrg6Zs/kjzAQwEwYbp8JxZVzZLRepQ== +"@rollup/rollup-linux-arm64-musl@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.24.4.tgz#63edd72b29c4cced93e16113a68e1be9fef88907" + integrity sha512-38yiWLemQf7aLHDgTg85fh3hW9stJ0Muk7+s6tIkSUOMmi4Xbv5pH/5Bofnsb6spIwD5FJiR+jg71f0CH5OzoA== + "@rollup/rollup-linux-powerpc64le-gnu@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.18.0.tgz#cbb0837408fe081ce3435cf3730e090febafc9bf" integrity sha512-hNVMQK+qrA9Todu9+wqrXOHxFiD5YmdEi3paj6vP02Kx1hjd2LLYR2eaN7DsEshg09+9uzWi2W18MJDlG0cxJA== +"@rollup/rollup-linux-powerpc64le-gnu@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.24.4.tgz#a9418a4173df80848c0d47df0426a0bf183c4e75" + integrity sha512-q73XUPnkwt9ZNF2xRS4fvneSuaHw2BXuV5rI4cw0fWYVIWIBeDZX7c7FWhFQPNTnE24172K30I+dViWRVD9TwA== + "@rollup/rollup-linux-riscv64-gnu@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.18.0.tgz#8ed09c1d1262ada4c38d791a28ae0fea28b80cc9" integrity sha512-ROCM7i+m1NfdrsmvwSzoxp9HFtmKGHEqu5NNDiZWQtXLA8S5HBCkVvKAxJ8U+CVctHwV2Gb5VUaK7UAkzhDjlg== +"@rollup/rollup-linux-riscv64-gnu@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.24.4.tgz#bc9c195db036a27e5e3339b02f51526b4ce1e988" + integrity sha512-Aie/TbmQi6UXokJqDZdmTJuZBCU3QBDA8oTKRGtd4ABi/nHgXICulfg1KI6n9/koDsiDbvHAiQO3YAUNa/7BCw== + "@rollup/rollup-linux-s390x-gnu@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.18.0.tgz#938138d3c8e0c96f022252a28441dcfb17afd7ec" integrity sha512-0UyyRHyDN42QL+NbqevXIIUnKA47A+45WyasO+y2bGJ1mhQrfrtXUpTxCOrfxCR4esV3/RLYyucGVPiUsO8xjg== +"@rollup/rollup-linux-s390x-gnu@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.24.4.tgz#1651fdf8144ae89326c01da5d52c60be63e71a82" + integrity sha512-P8MPErVO/y8ohWSP9JY7lLQ8+YMHfTI4bAdtCi3pC2hTeqFJco2jYspzOzTUB8hwUWIIu1xwOrJE11nP+0JFAQ== + "@rollup/rollup-linux-x64-gnu@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.18.0.tgz#1a7481137a54740bee1ded4ae5752450f155d942" integrity sha512-xuglR2rBVHA5UsI8h8UbX4VJ470PtGCf5Vpswh7p2ukaqBGFTnsfzxUBetoWBWymHMxbIG0Cmx7Y9qDZzr648w== +"@rollup/rollup-linux-x64-gnu@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.24.4.tgz#e473de5e4acb95fcf930a35cbb7d3e8080e57a6f" + integrity sha512-K03TljaaoPK5FOyNMZAAEmhlyO49LaE4qCsr0lYHUKyb6QacTNF9pnfPpXnFlFD3TXuFbFbz7tJ51FujUXkXYA== + "@rollup/rollup-linux-x64-musl@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.18.0.tgz#f1186afc601ac4f4fc25fac4ca15ecbee3a1874d" integrity sha512-LKaqQL9osY/ir2geuLVvRRs+utWUNilzdE90TpyoX0eNqPzWjRm14oMEE+YLve4k/NAqCdPkGYDaDF5Sw+xBfg== +"@rollup/rollup-linux-x64-musl@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.24.4.tgz#0af12dd2578c29af4037f0c834b4321429dd5b01" + integrity sha512-VJYl4xSl/wqG2D5xTYncVWW+26ICV4wubwN9Gs5NrqhJtayikwCXzPL8GDsLnaLU3WwhQ8W02IinYSFJfyo34Q== + "@rollup/rollup-win32-arm64-msvc@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.18.0.tgz#ed6603e93636a96203c6915be4117245c1bd2daf" integrity sha512-7J6TkZQFGo9qBKH0pk2cEVSRhJbL6MtfWxth7Y5YmZs57Pi+4x6c2dStAUvaQkHQLnEQv1jzBUW43GvZW8OFqA== +"@rollup/rollup-win32-arm64-msvc@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.24.4.tgz#e48e78cdd45313b977c1390f4bfde7ab79be8871" + integrity sha512-ku2GvtPwQfCqoPFIJCqZ8o7bJcj+Y54cZSr43hHca6jLwAiCbZdBUOrqE6y29QFajNAzzpIOwsckaTFmN6/8TA== + "@rollup/rollup-win32-ia32-msvc@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.18.0.tgz#14e0b404b1c25ebe6157a15edb9c46959ba74c54" integrity sha512-Txjh+IxBPbkUB9+SXZMpv+b/vnTEtFyfWZgJ6iyCmt2tdx0OF5WhFowLmnh8ENGNpfUlUZkdI//4IEmhwPieNg== +"@rollup/rollup-win32-ia32-msvc@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.24.4.tgz#a3fc8536d243fe161c796acb93eba43c250f311c" + integrity sha512-V3nCe+eTt/W6UYNr/wGvO1fLpHUrnlirlypZfKCT1fG6hWfqhPgQV/K/mRBXBpxc0eKLIF18pIOFVPh0mqHjlg== + "@rollup/rollup-win32-x64-msvc@4.18.0": version "4.18.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.18.0.tgz#5d694d345ce36b6ecf657349e03eb87297e68da4" integrity sha512-UOo5FdvOL0+eIVTgS4tIdbW+TtnBLWg1YBCcU2KWM7nuNwRz9bksDX1bekJJCpu25N1DVWaCwnT39dVQxzqS8g== +"@rollup/rollup-win32-x64-msvc@4.24.4": + version "4.24.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.24.4.tgz#e2a9d1fd56524103a6cc8a54404d9d3ebc73c454" + integrity sha512-LTw1Dfd0mBIEqUVCxbvTE/LLo+9ZxVC9k99v1v4ahg9Aak6FpqOfNu5kRkeTAn0wphoC4JU7No1/rL+bBCEwhg== + "@sinclair/typebox@^0.27.8": version "0.27.8" resolved "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz" @@ -1353,6 +1604,11 @@ resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz" integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== +"@types/estree@1.0.6": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50" + integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== + "@types/express-serve-static-core@^4.17.33": version "4.19.1" resolved "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.1.tgz" @@ -1438,6 +1694,13 @@ dependencies: undici-types "~5.26.4" +"@types/node@^18": + version "18.19.64" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.64.tgz#122897fb79f2a9ec9c979bded01c11461b2b1478" + integrity sha512-955mDqvO2vFf/oL7V3WiUtiz+BugyX8uVbaT2H8oj3+8dRyH2FLiNdowe7eNqRM7IOIZvzDH76EoAT+gwm6aIQ== + dependencies: + undici-types "~5.26.4" + "@types/node@^20.12.13": version "20.12.13" resolved "https://registry.npmjs.org/@types/node/-/node-20.12.13.tgz" @@ -1445,6 +1708,13 @@ dependencies: undici-types "~5.26.4" +"@types/node@^22.7.5": + version "22.9.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.9.0.tgz#b7f16e5c3384788542c72dc3d561a7ceae2c0365" + integrity sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ== + dependencies: + undici-types "~6.19.8" + "@types/normalize-package-data@^2.4.3": version "2.4.4" resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz" @@ -1699,6 +1969,11 @@ ansi-regex@^5.0.1: resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== +ansi-regex@^6.0.1: + version "6.1.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.1.0.tgz#95ec409c69619d6cb1b8b34f14b660ef28ebd654" + integrity sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA== + ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz" @@ -1718,6 +1993,16 @@ ansi-styles@^5.0.0: resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz" integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== +ansi-styles@^6.1.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" + integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== + +any-promise@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" + integrity sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A== + anymatch@^3.0.3: version "3.1.3" resolved "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz" @@ -1919,6 +2204,13 @@ buffer-from@^1.0.0: resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== +bundle-require@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/bundle-require/-/bundle-require-5.0.0.tgz#071521bdea6534495cf23e92a83f889f91729e93" + integrity sha512-GuziW3fSSmopcx4KRymQEJVbZUfqlCqcq7dvs6TYwKRZiegK/2buMxQTPs6MGlNv50wms1699qYO54R8XfRX4w== + dependencies: + load-tsconfig "^0.2.3" + busboy@1.6.0: version "1.6.0" resolved "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz" @@ -1931,6 +2223,11 @@ bytes@3.1.2: resolved "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz" integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== +cac@^6.7.14: + version "6.7.14" + resolved "https://registry.yarnpkg.com/cac/-/cac-6.7.14.tgz#804e1e6f506ee363cb0e3ccbb09cad5dd9870959" + integrity sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ== + call-bind@^1.0.7: version "1.0.7" resolved "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz" @@ -1994,6 +2291,13 @@ char-regex@^1.0.2: resolved "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz" integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw== +chokidar@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-4.0.1.tgz#4a6dff66798fb0f72a94f616abbd7e1a19f31d41" + integrity sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA== + dependencies: + readdirp "^4.0.1" + ci-info@^3.2.0: version "3.9.0" resolved "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz" @@ -2079,6 +2383,11 @@ combined-stream@^1.0.8: dependencies: delayed-stream "~1.0.0" +commander@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" + integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA== + concat-map@0.0.1: version "0.0.1" resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" @@ -2089,6 +2398,11 @@ conditional-type-checks@^1.0.6: resolved "https://registry.npmjs.org/conditional-type-checks/-/conditional-type-checks-1.0.6.tgz" integrity sha512-3vyi+yNcmKq+xl1sTX7Ta+4pUvjusMYbC6FSbrS6YJV8TI51wiRn24u4bfdFVhDKKH5GtpKQzxW7bqXbPWllgQ== +consola@^3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/consola/-/consola-3.2.3.tgz#0741857aa88cfa0d6fd53f1cff0375136e98502f" + integrity sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ== + content-disposition@0.5.4: version "0.5.4" resolved "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz" @@ -2136,7 +2450,7 @@ create-jest@^29.7.0: jest-util "^29.7.0" prompts "^2.0.1" -cross-spawn@^7.0.2, cross-spawn@^7.0.3: +cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -2198,6 +2512,13 @@ debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4: dependencies: ms "2.1.2" +debug@^4.3.7: + version "4.3.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52" + integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ== + dependencies: + ms "^2.1.3" + decimal.js@^10.4.2: version "10.4.3" resolved "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz" @@ -2286,6 +2607,11 @@ domexception@^4.0.0: dependencies: webidl-conversions "^7.0.0" +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + ee-first@1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz" @@ -2311,6 +2637,11 @@ emoji-regex@^8.0.0: resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== + encodeurl@~1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz" @@ -2403,6 +2734,36 @@ esbuild@^0.21.4: "@esbuild/win32-ia32" "0.21.4" "@esbuild/win32-x64" "0.21.4" +esbuild@^0.24.0: + version "0.24.0" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.24.0.tgz#f2d470596885fcb2e91c21eb3da3b3c89c0b55e7" + integrity sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ== + optionalDependencies: + "@esbuild/aix-ppc64" "0.24.0" + "@esbuild/android-arm" "0.24.0" + "@esbuild/android-arm64" "0.24.0" + "@esbuild/android-x64" "0.24.0" + "@esbuild/darwin-arm64" "0.24.0" + "@esbuild/darwin-x64" "0.24.0" + "@esbuild/freebsd-arm64" "0.24.0" + "@esbuild/freebsd-x64" "0.24.0" + "@esbuild/linux-arm" "0.24.0" + "@esbuild/linux-arm64" "0.24.0" + "@esbuild/linux-ia32" "0.24.0" + "@esbuild/linux-loong64" "0.24.0" + "@esbuild/linux-mips64el" "0.24.0" + "@esbuild/linux-ppc64" "0.24.0" + "@esbuild/linux-riscv64" "0.24.0" + "@esbuild/linux-s390x" "0.24.0" + "@esbuild/linux-x64" "0.24.0" + "@esbuild/netbsd-x64" "0.24.0" + "@esbuild/openbsd-arm64" "0.24.0" + "@esbuild/openbsd-x64" "0.24.0" + "@esbuild/sunos-x64" "0.24.0" + "@esbuild/win32-arm64" "0.24.0" + "@esbuild/win32-ia32" "0.24.0" + "@esbuild/win32-x64" "0.24.0" + escalade@^3.1.1, escalade@^3.1.2: version "3.1.2" resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz" @@ -2677,6 +3038,11 @@ fb-watchman@^2.0.0: dependencies: bser "2.1.1" +fdir@^6.4.2: + version "6.4.2" + resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.2.tgz#ddaa7ce1831b161bc3657bb99cb36e1622702689" + integrity sha512-KnhMXsKSPZlAhp7+IjUkRZKPb4fUyccpDrdFXbi4QL1qkmFh9kVY09Yox+n4MaOb3lHZ1Tv829C3oaaXoMYPDQ== + file-entry-cache@^8.0.0: version "8.0.0" resolved "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz" @@ -2733,6 +3099,14 @@ flatted@^3.2.9: resolved "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz" integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw== +foreground-child@^3.1.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.3.0.tgz#0ac8644c06e431439f8561db8ecf29a7b5519c77" + integrity sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg== + dependencies: + cross-spawn "^7.0.0" + signal-exit "^4.0.1" + form-data@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz" @@ -2824,6 +3198,18 @@ glob-parent@^6.0.2: dependencies: is-glob "^4.0.3" +glob@^10.3.10: + version "10.4.5" + resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.5.tgz#f4d9f0b90ffdbab09c9d77f5f29b4262517b0956" + integrity sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg== + dependencies: + foreground-child "^3.1.0" + jackspeak "^3.1.2" + minimatch "^9.0.4" + minipass "^7.1.2" + package-json-from-dist "^1.0.0" + path-scurry "^1.11.1" + glob@^7.1.3, glob@^7.1.4: version "7.2.3" resolved "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz" @@ -3190,6 +3576,15 @@ istanbul-reports@^3.1.3: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" +jackspeak@^3.1.2: + version "3.4.3" + resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.4.3.tgz#8833a9d89ab4acde6188942bd1c53b6390ed5a8a" + integrity sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw== + dependencies: + "@isaacs/cliui" "^8.0.2" + optionalDependencies: + "@pkgjs/parseargs" "^0.11.0" + jest-changed-files@^29.7.0: version "29.7.0" resolved "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.7.0.tgz" @@ -3562,6 +3957,11 @@ jest@29.7.0, jest@^29.7.0: import-local "^3.0.2" jest-cli "^29.7.0" +joycon@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/joycon/-/joycon-3.1.1.tgz#bce8596d6ae808f8b68168f5fc69280996894f03" + integrity sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw== + "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz" @@ -3644,6 +4044,11 @@ json-schema-traverse@^0.4.1: resolved "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== +json-schema@0.4.0, json-schema@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5" + integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA== + json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz" @@ -3702,11 +4107,21 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" +lilconfig@^3.1.1: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-3.1.2.tgz#e4a7c3cb549e3a606c8dcc32e5ae1005e62c05cb" + integrity sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow== + lines-and-columns@^1.1.6: version "1.2.4" resolved "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== +load-tsconfig@^0.2.3: + version "0.2.5" + resolved "https://registry.yarnpkg.com/load-tsconfig/-/load-tsconfig-0.2.5.tgz#453b8cd8961bfb912dea77eb6c168fe8cca3d3a1" + integrity sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg== + locate-character@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz" @@ -3736,6 +4151,11 @@ lodash.merge@^4.6.2: resolved "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== +lodash.sortby@^4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" + integrity sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA== + loose-envify@^1.1.0: version "1.4.0" resolved "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz" @@ -3748,6 +4168,11 @@ lru-cache@^10.0.1: resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz" integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ== +lru-cache@^10.2.0: + version "10.4.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119" + integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ== + lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" @@ -3855,6 +4280,11 @@ minimatch@^9.0.4: dependencies: brace-expansion "^2.0.1" +"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.1.2: + version "7.1.2" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.2.tgz#93a9626ce5e5e66bd4db86849e7515e92340a707" + integrity sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw== + mri@^1.1.0: version "1.2.0" resolved "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz" @@ -3875,11 +4305,20 @@ ms@2.1.2: resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@2.1.3: +ms@2.1.3, ms@^2.1.3: version "2.1.3" resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== +mz@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" + integrity sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q== + dependencies: + any-promise "^1.0.0" + object-assign "^4.0.1" + thenify-all "^1.0.0" + nanoid@^3.3.6, nanoid@^3.3.7: version "3.3.7" resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz" @@ -3960,6 +4399,11 @@ nwsapi@^2.2.2: resolved "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.10.tgz" integrity sha512-QK0sRs7MKv0tKe1+5uZIQk/C8XGza4DAnztJG8iD+TpJIORARrCxczA738awHrZoHeTjSSoHqao2teO0dC/gFQ== +object-assign@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== + object-inspect@^1.13.1: version "1.13.1" resolved "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz" @@ -4031,6 +4475,11 @@ p-try@^2.0.0: resolved "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz" integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== +package-json-from-dist@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz#4f1471a010827a86f94cfd9b0727e36d267de505" + integrity sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw== + parent-module@^1.0.0: version "1.0.1" resolved "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz" @@ -4089,6 +4538,14 @@ path-parse@^1.0.7: resolved "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== +path-scurry@^1.11.1: + version "1.11.1" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.1.tgz#7960a668888594a0720b12a911d1a742ab9f11d2" + integrity sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA== + dependencies: + lru-cache "^10.2.0" + minipass "^5.0.0 || ^6.0.2 || ^7.0.0" + path-to-regexp@0.1.7: version "0.1.7" resolved "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz" @@ -4123,12 +4580,22 @@ picocolors@^1.1.0: resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.0.tgz#5358b76a78cde483ba5cef6a9dc9671440b27d59" integrity sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw== +picocolors@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" + integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== + picomatch@^2.0.4, picomatch@^2.2.3, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== -pirates@^4.0.4: +picomatch@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.2.tgz#77c742931e8f3b8820946c76cd0c1f13730d1dab" + integrity sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg== + +pirates@^4.0.1, pirates@^4.0.4: version "4.0.6" resolved "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz" integrity sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg== @@ -4140,6 +4607,13 @@ pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" +postcss-load-config@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-6.0.1.tgz#6fd7dcd8ae89badcf1b2d644489cbabf83aa8096" + integrity sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g== + dependencies: + lilconfig "^3.1.1" + postcss@8.4.31: version "8.4.31" resolved "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz" @@ -4272,6 +4746,11 @@ readable-stream@3, readable-stream@^3.0.0: string_decoder "^1.1.1" util-deprecate "^1.0.1" +readdirp@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-4.0.2.tgz#388fccb8b75665da3abffe2d8f8ed59fe74c230a" + integrity sha512-yDMz9g+VaZkqBYS/ozoBJwaBhTbZo3UNYQHNRw1D3UFQB8oHB4uS/tAODO+ZLjGWmUbKnIlOWO+aaIiAxrUWHA== + require-directory@^2.1.1: version "2.1.1" resolved "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz" @@ -4348,6 +4827,33 @@ rollup@^4.13.0: "@rollup/rollup-win32-x64-msvc" "4.18.0" fsevents "~2.3.2" +rollup@^4.24.0: + version "4.24.4" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.24.4.tgz#fdc76918de02213c95447c9ffff5e35dddb1d058" + integrity sha512-vGorVWIsWfX3xbcyAS+I047kFKapHYivmkaT63Smj77XwvLSJos6M1xGqZnBPFQFBRZDOcG1QnYEIxAvTr/HjA== + dependencies: + "@types/estree" "1.0.6" + optionalDependencies: + "@rollup/rollup-android-arm-eabi" "4.24.4" + "@rollup/rollup-android-arm64" "4.24.4" + "@rollup/rollup-darwin-arm64" "4.24.4" + "@rollup/rollup-darwin-x64" "4.24.4" + "@rollup/rollup-freebsd-arm64" "4.24.4" + "@rollup/rollup-freebsd-x64" "4.24.4" + "@rollup/rollup-linux-arm-gnueabihf" "4.24.4" + "@rollup/rollup-linux-arm-musleabihf" "4.24.4" + "@rollup/rollup-linux-arm64-gnu" "4.24.4" + "@rollup/rollup-linux-arm64-musl" "4.24.4" + "@rollup/rollup-linux-powerpc64le-gnu" "4.24.4" + "@rollup/rollup-linux-riscv64-gnu" "4.24.4" + "@rollup/rollup-linux-s390x-gnu" "4.24.4" + "@rollup/rollup-linux-x64-gnu" "4.24.4" + "@rollup/rollup-linux-x64-musl" "4.24.4" + "@rollup/rollup-win32-arm64-msvc" "4.24.4" + "@rollup/rollup-win32-ia32-msvc" "4.24.4" + "@rollup/rollup-win32-x64-msvc" "4.24.4" + fsevents "~2.3.2" + run-parallel@^1.1.9: version "1.2.0" resolved "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz" @@ -4379,6 +4885,11 @@ saxes@^6.0.0: dependencies: xmlchars "^2.2.0" +secure-json-parse@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/secure-json-parse/-/secure-json-parse-2.7.0.tgz#5a5f9cd6ae47df23dba3151edd06855d47e09862" + integrity sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw== + semver@^6.3.0, semver@^6.3.1: version "6.3.1" resolved "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz" @@ -4472,6 +4983,11 @@ signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7: resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== +signal-exit@^4.0.1: + version "4.1.0" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" + integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== + sirv@^2.0.4: version "2.0.4" resolved "https://registry.npmjs.org/sirv/-/sirv-2.0.4.tgz" @@ -4516,6 +5032,13 @@ source-map-support@0.5.13: buffer-from "^1.0.0" source-map "^0.6.0" +source-map@0.8.0-beta.0: + version "0.8.0-beta.0" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.8.0-beta.0.tgz#d4c1bb42c3f7ee925f005927ba10709e0d1d1f11" + integrity sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA== + dependencies: + whatwg-url "^7.0.0" + source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz" @@ -4589,6 +5112,15 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz" @@ -4598,6 +5130,15 @@ string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.1" +string-width@^5.0.1, string-width@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== + dependencies: + eastasianwidth "^0.2.0" + emoji-regex "^9.2.2" + strip-ansi "^7.0.1" + string_decoder@^1.1.1: version "1.3.0" resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz" @@ -4605,6 +5146,13 @@ string_decoder@^1.1.1: dependencies: safe-buffer "~5.2.0" +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz" @@ -4612,6 +5160,13 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: dependencies: ansi-regex "^5.0.1" +strip-ansi@^7.0.1: + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== + dependencies: + ansi-regex "^6.0.1" + strip-bom@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz" @@ -4634,6 +5189,19 @@ styled-jsx@5.1.1: dependencies: client-only "0.0.1" +sucrase@^3.35.0: + version "3.35.0" + resolved "https://registry.yarnpkg.com/sucrase/-/sucrase-3.35.0.tgz#57f17a3d7e19b36d8995f06679d121be914ae263" + integrity sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA== + dependencies: + "@jridgewell/gen-mapping" "^0.3.2" + commander "^4.0.0" + glob "^10.3.10" + lines-and-columns "^1.1.6" + mz "^2.7.0" + pirates "^4.0.1" + ts-interface-checker "^0.1.9" + superjson@1.13.3: version "1.13.3" resolved "https://registry.npmjs.org/superjson/-/superjson-1.13.3.tgz" @@ -4706,6 +5274,20 @@ text-table@^0.2.0: resolved "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz" integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== +thenify-all@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726" + integrity sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA== + dependencies: + thenify ">= 3.1.0 < 4" + +"thenify@>= 3.1.0 < 4": + version "3.3.1" + resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.1.tgz#8932e686a4066038a016dd9e2ca46add9838a95f" + integrity sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw== + dependencies: + any-promise "^1.0.0" + through2@^4.0.2: version "4.0.2" resolved "https://registry.npmjs.org/through2/-/through2-4.0.2.tgz" @@ -4721,6 +5303,19 @@ tiny-glob@^0.2.9: globalyzer "0.1.0" globrex "^0.1.2" +tinyexec@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/tinyexec/-/tinyexec-0.3.1.tgz#0ab0daf93b43e2c211212396bdb836b468c97c98" + integrity sha512-WiCJLEECkO18gwqIp6+hJg0//p23HXp4S+gGtAKu3mI2F2/sXC4FvHvXvB0zJVVaTPhx1/tOwdbRsa1sOBIKqQ== + +tinyglobby@^0.2.9: + version "0.2.10" + resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.10.tgz#e712cf2dc9b95a1f5c5bbd159720e15833977a0f" + integrity sha512-Zc+8eJlFMvgatPZTl6A9L/yht8QqdmUNtURHaKZLmKBE12hNPSrqNkUp2cs3M/UKmNVVAMFQYSjYIVHDjW5zew== + dependencies: + fdir "^6.4.2" + picomatch "^4.0.2" + tmpl@1.0.5: version "1.0.5" resolved "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz" @@ -4758,6 +5353,13 @@ tough-cookie@^4.1.2: universalify "^0.2.0" url-parse "^1.5.3" +tr46@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09" + integrity sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA== + dependencies: + punycode "^2.1.0" + tr46@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz" @@ -4765,6 +5367,11 @@ tr46@^3.0.0: dependencies: punycode "^2.1.1" +tree-kill@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" + integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A== + treeify@^1.1.0: version "1.1.0" resolved "https://registry.npmjs.org/treeify/-/treeify-1.1.0.tgz" @@ -4775,6 +5382,11 @@ ts-api-utils@^1.3.0: resolved "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz" integrity sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ== +ts-interface-checker@^0.1.9: + version "0.1.13" + resolved "https://registry.yarnpkg.com/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz#784fd3d679722bc103b1b4b8030bcddb5db2a699" + integrity sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA== + ts-jest@29.1.4, ts-jest@^29.1.4: version "29.1.4" resolved "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.4.tgz" @@ -4794,6 +5406,28 @@ tslib@^2.3.1, tslib@^2.4.0: resolved "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== +tsup@^8: + version "8.3.5" + resolved "https://registry.yarnpkg.com/tsup/-/tsup-8.3.5.tgz#d55344e4756e924bf6f442e54e7d324b4471eee0" + integrity sha512-Tunf6r6m6tnZsG9GYWndg0z8dEV7fD733VBFzFJ5Vcm1FtlXB8xBD/rtrBi2a3YKEV7hHtxiZtW5EAVADoe1pA== + dependencies: + bundle-require "^5.0.0" + cac "^6.7.14" + chokidar "^4.0.1" + consola "^3.2.3" + debug "^4.3.7" + esbuild "^0.24.0" + joycon "^3.1.1" + picocolors "^1.1.1" + postcss-load-config "^6.0.1" + resolve-from "^5.0.0" + rollup "^4.24.0" + source-map "0.8.0-beta.0" + sucrase "^3.35.0" + tinyexec "^0.3.1" + tinyglobby "^0.2.9" + tree-kill "^1.2.2" + tsx@^4.11.0: version "4.11.0" resolved "https://registry.npmjs.org/tsx/-/tsx-4.11.0.tgz" @@ -4897,6 +5531,11 @@ typescript-eslint@^8.0.0-alpha.22: "@typescript-eslint/parser" "8.0.0-alpha.22" "@typescript-eslint/utils" "8.0.0-alpha.22" +typescript@5.5.4: + version "5.5.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba" + integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== + typescript@^5.5.2: version "5.5.3" resolved "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz" @@ -4907,6 +5546,11 @@ undici-types@~5.26.4: resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== +undici-types@~6.19.8: + version "6.19.8" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" + integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== + unicorn-magic@^0.1.0: version "0.1.0" resolved "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz" @@ -5010,6 +5654,11 @@ walker@^1.0.8: dependencies: makeerror "1.0.12" +webidl-conversions@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" + integrity sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg== + webidl-conversions@^7.0.0: version "7.0.0" resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz" @@ -5035,6 +5684,15 @@ whatwg-url@^11.0.0: tr46 "^3.0.0" webidl-conversions "^7.0.0" +whatwg-url@^7.0.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-7.1.0.tgz#c2c492f1eca612988efd3d2266be1b9fc6170d06" + integrity sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg== + dependencies: + lodash.sortby "^4.7.0" + tr46 "^1.0.1" + webidl-conversions "^4.0.2" + which@^2.0.1: version "2.0.2" resolved "https://registry.npmjs.org/which/-/which-2.0.2.tgz" @@ -5054,6 +5712,15 @@ word-wrap@^1.2.5: resolved "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz" @@ -5063,6 +5730,15 @@ wrap-ansi@^7.0.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" + integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== + dependencies: + ansi-styles "^6.1.0" + string-width "^5.0.1" + strip-ansi "^7.0.1" + wrappy@1: version "1.0.2" resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" @@ -5172,3 +5848,8 @@ yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== + +zod@3.23.8: + version "3.23.8" + resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d" + integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g== From 9dcf152efa48c32c27c46f5b4a8104a92bcfcee2 Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Fri, 8 Nov 2024 09:52:10 +0000 Subject: [PATCH 04/19] Lock ai-sdk versions --- deno.lock | 2 +- packages/vercel-ai-provider/package.json | 10 +----- .../vercel-ai-provider/src/edgedb-error.ts | 4 ++- yarn.lock | 34 +++++++++---------- 4 files changed, 21 insertions(+), 29 deletions(-) diff --git a/deno.lock b/deno.lock index c40dcfef3..ef0145ab6 100644 --- a/deno.lock +++ b/deno.lock @@ -515,7 +515,7 @@ "packages/vercel-ai-provider": { "packageJson": { "dependencies": [ - "npm:@ai-sdk/provider-utils@^1.0.20", + "npm:@ai-sdk/provider-utils@1.0.20", "npm:@ai-sdk/provider@0.0.24", "npm:@repo/tsconfig@*", "npm:@types/node@18", diff --git a/packages/vercel-ai-provider/package.json b/packages/vercel-ai-provider/package.json index 671b9cdb3..064be7934 100644 --- a/packages/vercel-ai-provider/package.json +++ b/packages/vercel-ai-provider/package.json @@ -27,7 +27,7 @@ }, "dependencies": { "@ai-sdk/provider": "0.0.24", - "@ai-sdk/provider-utils": "^1.0.20" + "@ai-sdk/provider-utils": "1.0.20" }, "devDependencies": { "@repo/tsconfig": "*", @@ -47,14 +47,6 @@ "publishConfig": { "access": "public" }, - "homepage": "https://sdk.vercel.ai/docs", - "repository": { - "type": "git", - "url": "git+https://github.com/vercel/ai.git" - }, - "bugs": { - "url": "https://github.com/vercel/ai/issues" - }, "keywords": [ "ai" ] diff --git a/packages/vercel-ai-provider/src/edgedb-error.ts b/packages/vercel-ai-provider/src/edgedb-error.ts index 481833530..b8a253cc1 100644 --- a/packages/vercel-ai-provider/src/edgedb-error.ts +++ b/packages/vercel-ai-provider/src/edgedb-error.ts @@ -11,7 +11,9 @@ const edgedbErrorDataSchema = z.object({ export type EdgedDBErrorData = z.infer; -export const edgedbFailedResponseHandler = createJsonErrorResponseHandler({ +export const edgedbFailedResponseHandler: ReturnType< + typeof createJsonErrorResponseHandler +> = createJsonErrorResponseHandler({ errorSchema: edgedbErrorDataSchema, errorToMessage: (data) => data.message, }); diff --git a/yarn.lock b/yarn.lock index 8f1b631c5..5906158d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,15 +2,15 @@ # yarn lockfile v1 -"@ai-sdk/provider-utils@^1.0.20": - version "1.0.22" - resolved "https://registry.yarnpkg.com/@ai-sdk/provider-utils/-/provider-utils-1.0.22.tgz#5397a193587709796d012fc04e2df9903b70852f" - integrity sha512-YHK2rpj++wnLVc9vPGzGFP3Pjeld2MwhKinetA0zKXOoHAT/Jit5O8kZsxcSlJPu9wvcGT1UGZEjZrtO7PfFOQ== +"@ai-sdk/provider-utils@1.0.20": + version "1.0.20" + resolved "https://registry.yarnpkg.com/@ai-sdk/provider-utils/-/provider-utils-1.0.20.tgz#46175945dc32ad2d76cb5447738bcac3ad59dbcb" + integrity sha512-ngg/RGpnA00eNOWEtXHenpX1MsM2QshQh4QJFjUfwcqHpM5kTfG7je7Rc3HcEDP+OkRVv2GF+X4fC1Vfcnl8Ow== dependencies: - "@ai-sdk/provider" "0.0.26" - eventsource-parser "^1.1.2" - nanoid "^3.3.7" - secure-json-parse "^2.7.0" + "@ai-sdk/provider" "0.0.24" + eventsource-parser "1.1.2" + nanoid "3.3.6" + secure-json-parse "2.7.0" "@ai-sdk/provider@0.0.24": version "0.0.24" @@ -19,13 +19,6 @@ dependencies: json-schema "0.4.0" -"@ai-sdk/provider@0.0.26": - version "0.0.26" - resolved "https://registry.yarnpkg.com/@ai-sdk/provider/-/provider-0.0.26.tgz#52c3d5eb65cf7592c77c78decadf77cbec978934" - integrity sha512-dQkfBDs2lTYpKM8389oopPdQgIU007GQyCbuPPrV+K6MtSII3HBfE0stUIMXUb44L+LK1t6GXPP7wjSzjO6uKg== - dependencies: - json-schema "^0.4.0" - "@ampproject/remapping@^2.2.0", "@ampproject/remapping@^2.2.1": version "2.3.0" resolved "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz" @@ -2918,7 +2911,7 @@ etag@~1.8.1: resolved "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz" integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg== -eventsource-parser@^1.1.2: +eventsource-parser@1.1.2, eventsource-parser@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-1.1.2.tgz" integrity sha512-v0eOBUbiaFojBu2s2NPBfYUoRR9GjcDNvCXVaqEf5vVfpIAh9f8RCo4vXTP8c63QRKCFwoLpMpTdPwwhEKVgzA== @@ -4044,7 +4037,7 @@ json-schema-traverse@^0.4.1: resolved "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== -json-schema@0.4.0, json-schema@^0.4.0: +json-schema@0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5" integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA== @@ -4319,6 +4312,11 @@ mz@^2.7.0: object-assign "^4.0.1" thenify-all "^1.0.0" +nanoid@3.3.6: + version "3.3.6" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c" + integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA== + nanoid@^3.3.6, nanoid@^3.3.7: version "3.3.7" resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz" @@ -4885,7 +4883,7 @@ saxes@^6.0.0: dependencies: xmlchars "^2.2.0" -secure-json-parse@^2.7.0: +secure-json-parse@2.7.0: version "2.7.0" resolved "https://registry.yarnpkg.com/secure-json-parse/-/secure-json-parse-2.7.0.tgz#5a5f9cd6ae47df23dba3151edd06855d47e09862" integrity sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw== From 45b7293fcb721bf39dcd1d81f745b952308b2e13 Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Fri, 8 Nov 2024 17:42:03 +0000 Subject: [PATCH 05/19] Use default prompt in provider doStream & doGenerate Use default prompt if prompt.custom is not provided, but messages are. --- .../src/edgedb-rag-language-model.ts | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/vercel-ai-provider/src/edgedb-rag-language-model.ts b/packages/vercel-ai-provider/src/edgedb-rag-language-model.ts index 6e650c3ca..0bf9c25f9 100644 --- a/packages/vercel-ai-provider/src/edgedb-rag-language-model.ts +++ b/packages/vercel-ai-provider/src/edgedb-rag-language-model.ts @@ -28,7 +28,6 @@ import { mapOpenAICompletionLogProbs, } from "./utils"; import { convertToEdgeDBRagMessages } from "./convert-to-edgedb-rag-messages"; -// import type { JSONSchema7 } from "json-schema"; export interface EdgeDBLanguageModel extends LanguageModelV1 { withSettings(settings: Partial): EdgeDBRagLanguageModel; @@ -192,6 +191,10 @@ export class EdgeDBRagLanguageModel implements EdgeDBLanguageModel { const { args, warnings } = this.getArgs(options); const { messages } = args; + const providedPromptId = + this.settings.prompt && + ("name" in this.settings.prompt || "id" in this.settings.prompt); + const { responseHeaders, value: response } = await postJsonToApi({ url: `rag`, headers: options.headers, @@ -202,6 +205,14 @@ export class EdgeDBRagLanguageModel implements EdgeDBLanguageModel { prompt: { ...this.settings.prompt, ...(messages.length > 1 && { + // if user provides prompt.custom without id/name it is his choice + // to not include default prompt msgs, but if user provides messages + // and doesn't provide prompt.custom, since we add messages to the + // prompt.custom we also have to include default prompt messages + ...(!this.settings.prompt?.custom && + !providedPromptId && { + name: "builtin::rag-default", + }), custom: [...(this.settings.prompt?.custom || []), ...messages], }), }, @@ -249,6 +260,10 @@ export class EdgeDBRagLanguageModel implements EdgeDBLanguageModel { const { args, warnings } = this.getArgs(options); const { messages } = args; + const providedPromptId = + this.settings.prompt && + ("name" in this.settings.prompt || "id" in this.settings.prompt); + const { responseHeaders, value: response } = await postJsonToApi({ url: `rag`, headers: options.headers, @@ -259,6 +274,14 @@ export class EdgeDBRagLanguageModel implements EdgeDBLanguageModel { prompt: { ...this.settings.prompt, ...(messages.length > 1 && { + // if user provides prompt.custom without id/name it is his choice + // to not include default prompt msgs, but if user provides messages + // and doesn't provide prompt.custom, since we add messages to the + // prompt.custom we also have to include default prompt messages + ...(!this.settings.prompt?.custom && + !providedPromptId && { + name: "builtin::rag-default", + }), custom: [...(this.settings.prompt?.custom || []), ...messages], }), }, From a230f1e3638c75c380fd16fd178e397da94f0dc6 Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Mon, 18 Nov 2024 09:29:33 +0100 Subject: [PATCH 06/19] Rename rag stuff into vercel-ai-provider stuff --- packages/ai/src/core.ts | 43 +++++++++++++------ packages/ai/src/types.ts | 8 ++-- ...sages.ts => convert-to-edgedb-messages.ts} | 8 ++-- ...model.ts => edgedb-chat-language-model.ts} | 40 ++++++++--------- ...ag-settings.ts => edgedb-chat-settings.ts} | 18 ++++---- ...edb-rag-provider.ts => edgedb-provider.ts} | 34 +++++++-------- packages/vercel-ai-provider/src/index.ts | 4 +- packages/vercel-ai-provider/src/utils.ts | 2 +- 8 files changed, 86 insertions(+), 71 deletions(-) rename packages/vercel-ai-provider/src/{convert-to-edgedb-rag-messages.ts => convert-to-edgedb-messages.ts} (92%) rename packages/vercel-ai-provider/src/{edgedb-rag-language-model.ts => edgedb-chat-language-model.ts} (95%) rename packages/vercel-ai-provider/src/{edgedb-rag-settings.ts => edgedb-chat-settings.ts} (90%) rename packages/vercel-ai-provider/src/{edgedb-rag-provider.ts => edgedb-provider.ts} (71%) diff --git a/packages/ai/src/core.ts b/packages/ai/src/core.ts index 07ef5ab47..25254f3a3 100644 --- a/packages/ai/src/core.ts +++ b/packages/ai/src/core.ts @@ -9,12 +9,7 @@ import { getAuthenticatedFetch, type AuthenticatedFetch, } from "edgedb/dist/utils.js"; -import type { - AIOptions, - QueryContext, - RAGRequest, - StreamingMessage, -} from "./types.js"; +import type { AIOptions, QueryContext, StreamingMessage } from "./types.js"; import { getHTTPSCRAMAuth } from "edgedb/dist/httpScram.js"; import { cryptoUtils } from "edgedb/dist/browserCrypto.js"; @@ -68,11 +63,17 @@ export class EdgeDBAI { }); } - private async fetchRag(request: Omit) { + private async fetchRag(request: any) { const headers = request.stream ? { Accept: "text/event-stream", "Content-Type": "application/json" } : { Accept: "application/json", "Content-Type": "application/json" }; + const { messages } = request; + + const providedPrompt = + this.options.prompt && + ("name" in this.options.prompt || "id" in this.options.prompt); + const response = await ( await this.authenticatedFetch )("rag", { @@ -81,7 +82,24 @@ export class EdgeDBAI { body: JSON.stringify({ ...request, model: this.options.model, - prompt: this.options.prompt, + ...((this.options.prompt || messages.length > 1) && { + prompt: { + ...this.options.prompt, + ...(messages.length > 1 && { + // if user provides prompt.custom without id/name it is his choice + // to not include default prompt msgs, but if user provides messages + // and doesn't provide prompt.custom, since we add messages to the + // prompt.custom we also have to include default prompt messages + ...(!this.options.prompt?.custom && + !providedPrompt && { + name: "builtin::rag-default", + }), + custom: [...(this.options.prompt?.custom || []), ...messages], + }), + }, + }), + query: [...messages].reverse().find((msg) => msg.role === "user")! + .content[0].text, }), }); @@ -93,10 +111,10 @@ export class EdgeDBAI { return response; } - async queryRag(query: string, context = this.context): Promise { + async queryRag(request: any, context = this.context): Promise { const res = await this.fetchRag({ context, - query, + ...request, stream: false, }); @@ -117,19 +135,18 @@ export class EdgeDBAI { "Expected response to be object with response key of type string", ); } - return data.response; } streamRag( - query: string, + request: any, context = this.context, ): AsyncIterable & PromiseLike { const fetchRag = this.fetchRag.bind(this); const ragOptions = { context, - query, + ...request, stream: true, }; diff --git a/packages/ai/src/types.ts b/packages/ai/src/types.ts index b071ed037..277b541d8 100644 --- a/packages/ai/src/types.ts +++ b/packages/ai/src/types.ts @@ -3,9 +3,9 @@ import { z } from "zod"; export type ChatParticipantRole = "system" | "user" | "assistant" | "tool"; export type Prompt = - | { name: string; custom?: EdgeDBRagMessage } - | { id: string; custom?: EdgeDBRagMessage[] } - | { custom: EdgeDBRagMessage[] }; + | { name: string; custom?: EdgeDBMessage[] } + | { id: string; custom?: EdgeDBMessage[] } + | { custom: EdgeDBMessage[] }; export interface AIOptions { model: string; @@ -27,7 +27,7 @@ export interface RAGRequest { stream?: boolean; } -export type EdgeDBRagMessage = +export type EdgeDBMessage = | EdgeDBSystemMessage | EdgeDBUserMessage | EdgeDBAssistantMessage diff --git a/packages/vercel-ai-provider/src/convert-to-edgedb-rag-messages.ts b/packages/vercel-ai-provider/src/convert-to-edgedb-messages.ts similarity index 92% rename from packages/vercel-ai-provider/src/convert-to-edgedb-rag-messages.ts rename to packages/vercel-ai-provider/src/convert-to-edgedb-messages.ts index 148c52272..3d7b9a897 100644 --- a/packages/vercel-ai-provider/src/convert-to-edgedb-rag-messages.ts +++ b/packages/vercel-ai-provider/src/convert-to-edgedb-messages.ts @@ -1,10 +1,10 @@ import { type LanguageModelV1Prompt } from "@ai-sdk/provider"; -import type { EdgeDBRagMessage } from "./edgedb-rag-settings"; +import type { EdgeDBMessage } from "./edgedb-chat-settings"; -export function convertToEdgeDBRagMessages( +export function convertToEdgeDBMessages( prompt: LanguageModelV1Prompt, -): EdgeDBRagMessage[] { - const messages: EdgeDBRagMessage[] = []; +): EdgeDBMessage[] { + const messages: EdgeDBMessage[] = []; for (const { role, content } of prompt) { switch (role) { diff --git a/packages/vercel-ai-provider/src/edgedb-rag-language-model.ts b/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts similarity index 95% rename from packages/vercel-ai-provider/src/edgedb-rag-language-model.ts rename to packages/vercel-ai-provider/src/edgedb-chat-language-model.ts index 0bf9c25f9..47ee1429a 100644 --- a/packages/vercel-ai-provider/src/edgedb-rag-language-model.ts +++ b/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts @@ -15,38 +15,38 @@ import { generateId, } from "@ai-sdk/provider-utils"; import { - type EdgeDBRagConfig, - type EdgeDBRagModelId, - type EdgeDBRagSettings, + type EdgeDBChatConfig, + type EdgeDBChatModelId, + type EdgeDBChatSettings, isAnthropicModel, isOpenAIModel, -} from "./edgedb-rag-settings"; +} from "./edgedb-chat-settings"; import { edgedbFailedResponseHandler } from "./edgedb-error"; import { - mapEdgedbRagStopReason, + mapEdgedbStopReason, getResponseMetadata, mapOpenAICompletionLogProbs, } from "./utils"; -import { convertToEdgeDBRagMessages } from "./convert-to-edgedb-rag-messages"; +import { convertToEdgeDBMessages } from "./convert-to-edgedb-messages"; export interface EdgeDBLanguageModel extends LanguageModelV1 { - withSettings(settings: Partial): EdgeDBRagLanguageModel; + withSettings(settings: Partial): EdgeDBChatLanguageModel; } -export class EdgeDBRagLanguageModel implements EdgeDBLanguageModel { +export class EdgeDBChatLanguageModel implements EdgeDBLanguageModel { readonly specificationVersion = "v1"; readonly defaultObjectGenerationMode = "json"; readonly supportsImageUrls = false; - readonly modelId: EdgeDBRagModelId; - readonly settings: EdgeDBRagSettings; + readonly modelId: EdgeDBChatModelId; + readonly settings: EdgeDBChatSettings; - private readonly config: EdgeDBRagConfig; + private readonly config: EdgeDBChatConfig; constructor( - modelId: EdgeDBRagModelId, - settings: EdgeDBRagSettings, - config: EdgeDBRagConfig, + modelId: EdgeDBChatModelId, + settings: EdgeDBChatSettings, + config: EdgeDBChatConfig, ) { this.modelId = modelId; this.settings = settings; @@ -57,8 +57,8 @@ export class EdgeDBRagLanguageModel implements EdgeDBLanguageModel { return this.config.provider; } - withSettings(settings: Partial) { - return new EdgeDBRagLanguageModel( + withSettings(settings: Partial) { + return new EdgeDBChatLanguageModel( this.modelId, { ...this.settings, ...settings }, this.config, @@ -142,7 +142,7 @@ export class EdgeDBRagLanguageModel implements EdgeDBLanguageModel { const baseArgs = { model: this.modelId, - messages: convertToEdgeDBRagMessages(prompt), + messages: convertToEdgeDBMessages(prompt), temperature, max_tokens: maxTokens, top_p: topP, @@ -241,7 +241,7 @@ export class EdgeDBRagLanguageModel implements EdgeDBLanguageModel { toolName: toolCall.name, args: JSON.stringify(toolCall.args), })), - finishReason: mapEdgedbRagStopReason(finish_reason), + finishReason: mapEdgedbStopReason(finish_reason), logprobs: mapOpenAICompletionLogProbs(logprobs), usage: { promptTokens: usage.prompt_tokens, @@ -439,7 +439,7 @@ export class EdgeDBRagLanguageModel implements EdgeDBLanguageModel { } case "message_delta": { - finishReason = mapEdgedbRagStopReason(value.delta.stop_reason); + finishReason = mapEdgedbStopReason(value.delta.stop_reason); if (value.usage) { usage.completionTokens = value.usage.completion_tokens; } @@ -586,7 +586,7 @@ function prepareToolsAndToolChoice( mode: Parameters[0]["mode"] & { type: "regular"; }, - model: EdgeDBRagModelId, + model: EdgeDBChatModelId, ) { const isOpenAI = isOpenAIModel(model); const isAnthropic = isAnthropicModel(model); diff --git a/packages/vercel-ai-provider/src/edgedb-rag-settings.ts b/packages/vercel-ai-provider/src/edgedb-chat-settings.ts similarity index 90% rename from packages/vercel-ai-provider/src/edgedb-rag-settings.ts rename to packages/vercel-ai-provider/src/edgedb-chat-settings.ts index 9a0090673..2f1bf4968 100644 --- a/packages/vercel-ai-provider/src/edgedb-rag-settings.ts +++ b/packages/vercel-ai-provider/src/edgedb-chat-settings.ts @@ -25,13 +25,13 @@ export type AnthropicModelId = | "claude-3-sonnet-20240229" | "claude-3-opus-20240229"; -export type EdgeDBRagModelId = +export type EdgeDBChatModelId = | OpenAIModelId | MistralModelId | AnthropicModelId | (string & {}); -export function isAnthropicModel(model: EdgeDBRagModelId): boolean { +export function isAnthropicModel(model: EdgeDBChatModelId): boolean { return ( model === "claude-3-5-sonnet-20240620" || model === "claude-3-haiku-20240307" || @@ -40,7 +40,7 @@ export function isAnthropicModel(model: EdgeDBRagModelId): boolean { ); } -export function isOpenAIModel(model: EdgeDBRagModelId): boolean { +export function isOpenAIModel(model: EdgeDBChatModelId): boolean { return ( model === "gpt-4o" || model === "gpt-4o-mini" || @@ -52,9 +52,9 @@ export function isOpenAIModel(model: EdgeDBRagModelId): boolean { } export type Prompt = - | { name: string; custom?: EdgeDBRagMessage[] } - | { id: string; custom?: EdgeDBRagMessage[] } - | { custom: EdgeDBRagMessage[] }; + | { name: string; custom?: EdgeDBMessage[] } + | { id: string; custom?: EdgeDBMessage[] } + | { custom: EdgeDBMessage[] }; export interface QueryContext { query: string; @@ -63,12 +63,12 @@ export interface QueryContext { max_object_count?: number; } -export interface EdgeDBRagConfig { +export interface EdgeDBChatConfig { provider: string; fetch: FetchFunction; } -export interface EdgeDBRagSettings { +export interface EdgeDBChatSettings { context?: QueryContext; prompt?: Prompt; @@ -129,7 +129,7 @@ monitor and detect abuse. Learn more. // cacheControl?: boolean; } -export type EdgeDBRagMessage = +export type EdgeDBMessage = | EdgeDBSystemMessage | EdgeDBUserMessage | EdgeDBAssistantMessage diff --git a/packages/vercel-ai-provider/src/edgedb-rag-provider.ts b/packages/vercel-ai-provider/src/edgedb-provider.ts similarity index 71% rename from packages/vercel-ai-provider/src/edgedb-rag-provider.ts rename to packages/vercel-ai-provider/src/edgedb-provider.ts index ce7922fbc..9970aa6f7 100644 --- a/packages/vercel-ai-provider/src/edgedb-rag-provider.ts +++ b/packages/vercel-ai-provider/src/edgedb-provider.ts @@ -9,13 +9,13 @@ import type { ProviderV1, } from "@ai-sdk/provider"; import { - EdgeDBRagLanguageModel, + EdgeDBChatLanguageModel, type EdgeDBLanguageModel, -} from "./edgedb-rag-language-model"; +} from "./edgedb-chat-language-model"; import type { - EdgeDBRagModelId, - EdgeDBRagSettings, -} from "./edgedb-rag-settings"; + EdgeDBChatModelId, + EdgeDBChatSettings, +} from "./edgedb-chat-settings"; import { EdgeDBEmbeddingModel } from "./edgedb-embedding-model"; import type { EdgeDBEmbeddingModelId, @@ -24,12 +24,12 @@ import type { const httpSCRAMAuth = getHTTPSCRAMAuth(cryptoUtils); -export interface EdgeDBRagProvider extends ProviderV1 { - (modelId: EdgeDBRagModelId | EdgeDBEmbeddingModelId): LanguageModelV1; +export interface EdgeDBProvider extends ProviderV1 { + (modelId: EdgeDBChatModelId | EdgeDBEmbeddingModelId): LanguageModelV1; languageModel( - modelId: EdgeDBRagModelId, - settings?: EdgeDBRagSettings, + modelId: EdgeDBChatModelId, + settings?: EdgeDBChatSettings, ): EdgeDBLanguageModel; textEmbeddingModel: ( @@ -38,9 +38,7 @@ export interface EdgeDBRagProvider extends ProviderV1 { ) => EmbeddingModelV1; } -export async function createEdgeDBRag( - client: Client, -): Promise { +export async function createEdgeDB(client: Client): Promise { const connectConfig: ResolvedConnectConfig = ( await (client as any).pool._getNormalizedConnectConfig() ).connectionParams; @@ -52,11 +50,11 @@ export async function createEdgeDBRag( ); const createChatModel = ( - modelId: EdgeDBRagModelId, - settings: EdgeDBRagSettings = {}, + modelId: EdgeDBChatModelId, + settings: EdgeDBChatSettings = {}, ) => - new EdgeDBRagLanguageModel(modelId, settings, { - provider: "edgedb.rag", + new EdgeDBChatLanguageModel(modelId, settings, { + provider: "edgedb.chat", fetch, }); @@ -70,7 +68,7 @@ export async function createEdgeDBRag( }); }; - const provider = function (modelId: EdgeDBRagModelId) { + const provider = function (modelId: EdgeDBChatModelId) { if (new.target) { throw new Error( "The EdgeDB model function cannot be called with the new keyword.", @@ -89,4 +87,4 @@ export async function createEdgeDBRag( /** Default provider instance. */ -export const edgedbRag = createEdgeDBRag(createClient()); +export const edgedb = createEdgeDB(createClient()); diff --git a/packages/vercel-ai-provider/src/index.ts b/packages/vercel-ai-provider/src/index.ts index 470dc540e..ee8cdb6e5 100644 --- a/packages/vercel-ai-provider/src/index.ts +++ b/packages/vercel-ai-provider/src/index.ts @@ -1,2 +1,2 @@ -export { createEdgeDBRag, edgedbRag } from "./edgedb-rag-provider"; -export type { EdgeDBRagProvider } from "./edgedb-rag-provider"; +export { createEdgeDB, edgedb } from "./edgedb-provider"; +export type { EdgeDBProvider } from "./edgedb-provider"; diff --git a/packages/vercel-ai-provider/src/utils.ts b/packages/vercel-ai-provider/src/utils.ts index 0cc07170e..ae9b2f8b3 100644 --- a/packages/vercel-ai-provider/src/utils.ts +++ b/packages/vercel-ai-provider/src/utils.ts @@ -1,7 +1,7 @@ import type { LanguageModelV1FinishReason } from "@ai-sdk/provider"; import type { LanguageModelV1LogProbs } from "@ai-sdk/provider"; -export function mapEdgedbRagStopReason( +export function mapEdgedbStopReason( finishReason: string | null | undefined, ): LanguageModelV1FinishReason { switch (finishReason) { From b51476bf7803c84b80b305f23264155d162cc2ec Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Mon, 18 Nov 2024 14:19:39 +0100 Subject: [PATCH 07/19] revert Deno lockfile version to 3 --- deno.lock | 129 +++++++++++------------ packages/vercel-ai-provider/package.json | 9 +- turbo.json | 4 +- 3 files changed, 67 insertions(+), 75 deletions(-) diff --git a/deno.lock b/deno.lock index ef0145ab6..2a72433f9 100644 --- a/deno.lock +++ b/deno.lock @@ -1,25 +1,30 @@ { - "version": "4", - "specifiers": { - "npm:@types/node@*": "18.16.19", - "npm:fast-check@*": "3.20.0", - "npm:typescript@*": "5.5.4" - }, - "npm": { - "@types/node@18.16.19": { - "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==" - }, - "fast-check@3.20.0": { - "integrity": "sha512-pZIjqLpOZgdSLecec4GKC3Zq5702MZ34upMKxojnNVSWA0K64V3pXOBT1Wdsrc3AphLtzRBbsi8bRWF4TUGmUg==", - "dependencies": [ - "pure-rand" - ] + "version": "3", + "packages": { + "specifiers": { + "npm:@types/node": "npm:@types/node@18.16.19", + "npm:fast-check": "npm:fast-check@3.20.0", + "npm:typescript": "npm:typescript@5.5.4" }, - "pure-rand@6.1.0": { - "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==" - }, - "typescript@5.5.4": { - "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==" + "npm": { + "@types/node@18.16.19": { + "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==", + "dependencies": {} + }, + "fast-check@3.20.0": { + "integrity": "sha512-pZIjqLpOZgdSLecec4GKC3Zq5702MZ34upMKxojnNVSWA0K64V3pXOBT1Wdsrc3AphLtzRBbsi8bRWF4TUGmUg==", + "dependencies": { + "pure-rand": "pure-rand@6.1.0" + } + }, + "pure-rand@6.1.0": { + "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==", + "dependencies": {} + }, + "typescript@5.5.4": { + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "dependencies": {} + } } }, "redirects": { @@ -310,12 +315,12 @@ "integration-tests/legacy": { "packageJson": { "dependencies": [ - "npm:@edgedb/generate@*", + "npm:@edgedb/generate", "npm:@tsconfig/node-lts@^20.1.3", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", "npm:conditional-type-checks@^1.0.6", - "npm:edgedb@*", + "npm:edgedb", "npm:jest@^29.7.0", "npm:ts-jest@^29.1.4", "npm:typescript@^5.5.2" @@ -325,13 +330,13 @@ "integration-tests/lts": { "packageJson": { "dependencies": [ - "npm:@arktype/attest@~0.7.8", - "npm:@edgedb/generate@*", + "npm:@arktype/attest@^0.7.8", + "npm:@edgedb/generate", "npm:@tsconfig/node-lts@^20.1.3", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", "npm:conditional-type-checks@^1.0.6", - "npm:edgedb@*", + "npm:edgedb", "npm:fast-check@^3.19.0", "npm:jest@^29.7.0", "npm:superjson@1.13.3", @@ -343,12 +348,12 @@ "integration-tests/nightly": { "packageJson": { "dependencies": [ - "npm:@edgedb/generate@*", + "npm:@edgedb/generate", "npm:@tsconfig/node-lts@^20.1.3", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", "npm:conditional-type-checks@^1.0.6", - "npm:edgedb@*", + "npm:edgedb", "npm:jest@^29.7.0", "npm:ts-jest@^29.1.4", "npm:typescript@^5.5.2" @@ -358,12 +363,12 @@ "integration-tests/stable": { "packageJson": { "dependencies": [ - "npm:@edgedb/generate@*", + "npm:@edgedb/generate", "npm:@tsconfig/node-lts@^20.1.3", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", "npm:conditional-type-checks@^1.0.6", - "npm:edgedb@*", + "npm:edgedb", "npm:jest@^29.7.0", "npm:ts-jest@^29.1.4", "npm:typescript@^5.5.2" @@ -373,10 +378,10 @@ "packages/ai": { "packageJson": { "dependencies": [ - "npm:@repo/tsconfig@*", + "npm:@repo/tsconfig", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", - "npm:edgedb@*", + "npm:edgedb", "npm:eventsource-parser@^1.1.2", "npm:jest@29.7.0", "npm:ts-jest@29.1.4", @@ -387,12 +392,12 @@ "packages/auth-core": { "packageJson": { "dependencies": [ - "npm:@repo/tsconfig@*", + "npm:@repo/tsconfig", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", - "npm:edgedb@*", + "npm:edgedb", "npm:jest@29.7.0", - "npm:jwt-decode@4", + "npm:jwt-decode@^4.0.0", "npm:ts-jest@29.1.4", "npm:typescript@^5.5.2" ] @@ -401,11 +406,11 @@ "packages/auth-express": { "packageJson": { "dependencies": [ - "npm:@edgedb/auth-core@~0.2.1", - "npm:@repo/tsconfig@*", + "npm:@edgedb/auth-core@^0.2.1", + "npm:@repo/tsconfig", "npm:@types/express@^4.17.21", "npm:@types/node@^20.12.13", - "npm:edgedb@*", + "npm:edgedb", "npm:express@^4.19.2", "npm:typescript@^5.5.2" ] @@ -415,10 +420,10 @@ "packageJson": { "dependencies": [ "npm:@edgedb/auth-core@0.2.1", - "npm:@repo/tsconfig@*", + "npm:@repo/tsconfig", "npm:@types/node@^20.12.13", "npm:@types/react@^18.3.3", - "npm:edgedb@*", + "npm:edgedb", "npm:next@14.2.3", "npm:react@^18.3.1", "npm:typescript@^5.5.2" @@ -428,12 +433,12 @@ "packages/auth-remix": { "packageJson": { "dependencies": [ - "npm:@edgedb/auth-core@~0.2.1", + "npm:@edgedb/auth-core@^0.2.1", "npm:@remix-run/server-runtime@^2.9.2", - "npm:@repo/tsconfig@*", + "npm:@repo/tsconfig", "npm:@types/node@^20.12.13", - "npm:cookie@0.6", - "npm:edgedb@*", + "npm:cookie@^0.6.0", + "npm:edgedb", "npm:typescript@^5.5.2" ] } @@ -441,11 +446,11 @@ "packages/auth-sveltekit": { "packageJson": { "dependencies": [ - "npm:@edgedb/auth-core@~0.2.1", - "npm:@repo/tsconfig@*", + "npm:@edgedb/auth-core@^0.2.1", + "npm:@repo/tsconfig", "npm:@sveltejs/kit@^2.5.10", "npm:@types/node@^20.12.13", - "npm:edgedb@*", + "npm:edgedb", "npm:svelte@^4.2.17", "npm:typescript@^5.5.2", "npm:vite@^5.2.12" @@ -455,7 +460,7 @@ "packages/create": { "packageJson": { "dependencies": [ - "npm:@clack/prompts@0.7", + "npm:@clack/prompts@^0.7.0", "npm:@types/debug@^4.1.12", "npm:@types/node@^20.12.13", "npm:debug@^4.3.4", @@ -471,17 +476,15 @@ "packageJson": { "dependencies": [ "npm:@js-temporal/polyfill@0.4.3", - "npm:@petamoriken/float16@^3.8.7", - "npm:@repo/tsconfig@*", + "npm:@repo/tsconfig", "npm:@types/jest@^29.5.12", - "npm:@types/node@^22.7.5", "npm:@types/semver@^7.5.8", "npm:@types/shell-quote@^1.7.5", "npm:@types/which@^3.0.3", "npm:debug@^4.3.4", - "npm:env-paths@3", + "npm:env-paths@^3.0.0", "npm:fast-check@^3.19.0", - "npm:get-stdin@9", + "npm:get-stdin@^9.0.0", "npm:globby@^14.0.1", "npm:jest-environment-jsdom@^29.7.0", "npm:jest@29.7.0", @@ -490,7 +493,7 @@ "npm:ts-jest@29.1.4", "npm:tsx@^4.11.0", "npm:typescript@^5.5.2", - "npm:which@4" + "npm:which@^4.0.0" ] } }, @@ -498,33 +501,19 @@ "packageJson": { "dependencies": [ "npm:@iarna/toml@^2.2.5", - "npm:@repo/tsconfig@*", + "npm:@repo/tsconfig", "npm:@types/jest@^29.5.12", "npm:@types/node@^20.12.13", "npm:conditional-type-checks@^1.0.6", "npm:debug@^4.3.4", - "npm:edgedb@*", - "npm:esbuild@~0.21.4", + "npm:edgedb", + "npm:esbuild@^0.21.4", "npm:globby@^14.0.1", "npm:jest@^29.7.0", "npm:ts-jest@^29.1.4", "npm:typescript@^5.5.2" ] } - }, - "packages/vercel-ai-provider": { - "packageJson": { - "dependencies": [ - "npm:@ai-sdk/provider-utils@1.0.20", - "npm:@ai-sdk/provider@0.0.24", - "npm:@repo/tsconfig@*", - "npm:@types/node@18", - "npm:edgedb@*", - "npm:tsup@8", - "npm:typescript@5.5.4", - "npm:zod@3.23.8" - ] - } } } } diff --git a/packages/vercel-ai-provider/package.json b/packages/vercel-ai-provider/package.json index 064be7934..6ad631a5d 100644 --- a/packages/vercel-ai-provider/package.json +++ b/packages/vercel-ai-provider/package.json @@ -11,11 +11,12 @@ "/dist" ], "scripts": { - "build": "tsc --project tsconfig.json", "clean": "rm -rf dist", - "lint": "eslint \"./**/*.ts*\"", - "type-check": "tsc --noEmit", - "prettier-check": "prettier --check \"./**/*.ts*\"" + "typecheck": "tsc --project tsconfig.json --noEmit", + "test": "jest --detectOpenHandles --passWithNoTests", + "build": "tsc --project tsconfig.json", + "lint": "eslint --quiet", + "lint:fix": "eslint --fix" }, "exports": { "./package.json": "./package.json", diff --git a/turbo.json b/turbo.json index c341435c0..a44e03e81 100644 --- a/turbo.json +++ b/turbo.json @@ -19,7 +19,9 @@ "@edgedb/auth-nextjs#typecheck", "@edgedb/auth-express#typecheck", "@edgedb/auth-remix#typecheck", - "@edgedb/auth-sveltekit#typecheck" + "@edgedb/auth-sveltekit#typecheck", + "@edgedb/ai#typecheck", + "@edgedb/vercel-ai-provider#typecheck" ] }, "ci:test": { From 08df0b96bb79f1e82c3088793132f2cd24d8216d Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Mon, 18 Nov 2024 15:47:57 +0100 Subject: [PATCH 08/19] Update readmes for the ai and the vercel provider libs --- packages/ai/README.md | 8 ++++++-- packages/vercel-ai-provider/README.md | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/ai/README.md b/packages/ai/README.md index c35173f76..05b1ff423 100644 --- a/packages/ai/README.md +++ b/packages/ai/README.md @@ -22,8 +22,8 @@ Creates an instance of `EdgeDBAI` with the specified client and options. - `client`: An EdgeDB client instance. - `options`: Configuration options for the AI model. - - `model`: Required. Specifies the AI model to use. This could be a version of GPT or any other model supported by EdgeDB AI. - - `prompt`: Optional. Defines the input prompt for the AI model. The prompt can be a simple string, an ID referencing a stored prompt, or a custom prompt structure that includes roles and content for more complex interactions. The default is the built-in system prompt. + - `model`: Required. Specifies the AI model to use. This could be some of the OpenAI, Mistral or Anthropic models supported by EdgeDB AI. + - `prompt`: Optional. Defines the input messages for the AI model. The prompt can have an `ID` or a `name` referencing a stored prompt. The referenced prompt will supply predefined messages. Optionally, include a custom list of messages using the `custom` field. These custom messages will be concatenated with messages from the stored prompt referenced by `id` or `name`. If no `id` or `name` is specified, only the `custom` messages will be used. If no `id`, `name`, or `custom` messages are provided, the built-in system prompt will be used by default. ### `EdgeDBAI` @@ -52,6 +52,10 @@ Creates an instance of `EdgeDBAI` with the specified client and options. Generates embeddings for the array of strings. +## Tool Calls + +Tool calls are supported by the AI extension but the tool calls should be executed on the client side and results should be provided back to the EdgeDB AI. + ## Example The following example demonstrates how to use the `@edgedb/ai` package to query an AI model about astronomy and chemistry. diff --git a/packages/vercel-ai-provider/README.md b/packages/vercel-ai-provider/README.md index 88b233178..4e7e4fe27 100644 --- a/packages/vercel-ai-provider/README.md +++ b/packages/vercel-ai-provider/README.md @@ -13,10 +13,10 @@ npm i @edgedb/vercel-ai-provider ## Provider Instance -You can import the default provider instance `edgedbRag` from `@edgedb/vercel-ai-provider`: +You can import the default provider instance `edgedb` from `@edgedb/vercel-ai-provider`: ```ts -import { edgedbRag } from "@edgedb/vercel-ai-provider"; +import { edgedb } from "@edgedb/vercel-ai-provider"; ``` ## Example @@ -24,9 +24,9 @@ import { edgedbRag } from "@edgedb/vercel-ai-provider"; ```ts import { generateText } from "ai"; import { createClient } from "edgedb"; -import { edgedbRag } from "@edgedb/vercel-ai-provider"; +import { edgedb } from "@edgedb/vercel-ai-provider"; -const textModel = (await edgedbRag).languageModel("gpt-4-turbo-preview"); +const textModel = (await edgedb).languageModel("gpt-4-turbo-preview"); const { text } = await generateText({ model: textModel.withSettings({ @@ -40,4 +40,4 @@ console.log(text); ## Documentation -Please check out the **[EdgeDB provider documentation](https://docs.edgedb.com)** for more information. +Please check out the **[EdgeDB provider documentation](https://docs.edgedb.com/ai/vercel-ai-provider)** for more information. From 4941fe5f00ada3e2bbab4a3f35ea9a6726c868eb Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Mon, 18 Nov 2024 16:12:38 +0100 Subject: [PATCH 09/19] Update Request type in the ai binding --- packages/ai/src/core.ts | 48 ++++++++++++++++++++++++++-------------- packages/ai/src/types.ts | 7 ++---- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/packages/ai/src/core.ts b/packages/ai/src/core.ts index 25254f3a3..82cb2cf85 100644 --- a/packages/ai/src/core.ts +++ b/packages/ai/src/core.ts @@ -9,7 +9,12 @@ import { getAuthenticatedFetch, type AuthenticatedFetch, } from "edgedb/dist/utils.js"; -import type { AIOptions, QueryContext, StreamingMessage } from "./types.js"; +import type { + AIOptions, + QueryContext, + StreamingMessage, + RagRequest, +} from "./types.js"; import { getHTTPSCRAMAuth } from "edgedb/dist/httpScram.js"; import { cryptoUtils } from "edgedb/dist/browserCrypto.js"; @@ -63,7 +68,7 @@ export class EdgeDBAI { }); } - private async fetchRag(request: any) { + private async fetchRag(request: RagRequest, context: QueryContext) { const headers = request.stream ? { Accept: "text/event-stream", "Content-Type": "application/json" } : { Accept: "application/json", "Content-Type": "application/json" }; @@ -81,6 +86,7 @@ export class EdgeDBAI { headers, body: JSON.stringify({ ...request, + context, model: this.options.model, ...((this.options.prompt || messages.length > 1) && { prompt: { @@ -111,12 +117,14 @@ export class EdgeDBAI { return response; } - async queryRag(request: any, context = this.context): Promise { - const res = await this.fetchRag({ + async queryRag(request: RagRequest, context = this.context): Promise { + const res = await this.fetchRag( + { + ...request, + stream: false, + }, context, - ...request, - stream: false, - }); + ); if (!res.headers.get("content-type")?.includes("application/json")) { throw new Error( @@ -132,27 +140,27 @@ export class EdgeDBAI { typeof data.response !== "string" ) { throw new Error( - "Expected response to be object with response key of type string", + "Expected response to be an object with response key of type string", ); } return data.response; } streamRag( - request: any, + request: RagRequest, context = this.context, ): AsyncIterable & PromiseLike { const fetchRag = this.fetchRag.bind(this); - const ragOptions = { - context, - ...request, - stream: true, - }; - return { async *[Symbol.asyncIterator]() { - const res = await fetchRag(ragOptions); + const res = await fetchRag( + { + ...request, + stream: true, + }, + context, + ); if (!res.body) { throw new Error("Expected response to include a body"); @@ -184,7 +192,13 @@ export class EdgeDBAI { | undefined | null, ): Promise { - return fetchRag(ragOptions).then(onfulfilled, onrejected); + return fetchRag( + { + ...request, + stream: true, + }, + context, + ).then(onfulfilled, onrejected); }, }; } diff --git a/packages/ai/src/types.ts b/packages/ai/src/types.ts index 277b541d8..b928a2de4 100644 --- a/packages/ai/src/types.ts +++ b/packages/ai/src/types.ts @@ -19,11 +19,8 @@ export interface QueryContext { max_object_count?: number; } -export interface RAGRequest { - model: string; - prompt?: Prompt; - context: QueryContext; - query: string; +export interface RagRequest { + messages: EdgeDBMessage[]; stream?: boolean; } From f65bf4e3a840aa153e269ec1bcdabaef0bfbf2ca Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Mon, 18 Nov 2024 16:16:49 +0100 Subject: [PATCH 10/19] Update Request type in the ai binding --- packages/ai/src/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/ai/src/types.ts b/packages/ai/src/types.ts index b928a2de4..980ec34f5 100644 --- a/packages/ai/src/types.ts +++ b/packages/ai/src/types.ts @@ -22,6 +22,7 @@ export interface QueryContext { export interface RagRequest { messages: EdgeDBMessage[]; stream?: boolean; + [key: string]: unknown; } export type EdgeDBMessage = From 37d53739e1488acfc4d10ce47f721b81df95b716 Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Mon, 18 Nov 2024 16:58:28 +0100 Subject: [PATCH 11/19] Always include messages in the AI prompt's custom field --- packages/ai/src/core.ts | 22 +++++----- .../src/edgedb-chat-language-model.ts | 44 +++++++++---------- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/packages/ai/src/core.ts b/packages/ai/src/core.ts index 82cb2cf85..74dd2c29c 100644 --- a/packages/ai/src/core.ts +++ b/packages/ai/src/core.ts @@ -88,20 +88,18 @@ export class EdgeDBAI { ...request, context, model: this.options.model, - ...((this.options.prompt || messages.length > 1) && { + ...(this.options.prompt && { prompt: { ...this.options.prompt, - ...(messages.length > 1 && { - // if user provides prompt.custom without id/name it is his choice - // to not include default prompt msgs, but if user provides messages - // and doesn't provide prompt.custom, since we add messages to the - // prompt.custom we also have to include default prompt messages - ...(!this.options.prompt?.custom && - !providedPrompt && { - name: "builtin::rag-default", - }), - custom: [...(this.options.prompt?.custom || []), ...messages], - }), + // if user provides prompt.custom without id/name it is his choice + // to not include default prompt msgs, but if user provides messages + // and doesn't provide prompt.custom, since we add messages to the + // prompt.custom we also have to include default prompt messages + ...(!this.options.prompt?.custom && + !providedPrompt && { + name: "builtin::rag-default", + }), + custom: [...(this.options.prompt?.custom || []), ...messages], }, }), query: [...messages].reverse().find((msg) => msg.role === "user")! diff --git a/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts b/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts index 47ee1429a..5c03156a2 100644 --- a/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts +++ b/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts @@ -201,20 +201,18 @@ export class EdgeDBChatLanguageModel implements EdgeDBLanguageModel { body: { ...args, context: this.settings.context, - ...((this.settings.prompt || messages.length > 1) && { + ...(this.settings.prompt && { prompt: { ...this.settings.prompt, - ...(messages.length > 1 && { - // if user provides prompt.custom without id/name it is his choice - // to not include default prompt msgs, but if user provides messages - // and doesn't provide prompt.custom, since we add messages to the - // prompt.custom we also have to include default prompt messages - ...(!this.settings.prompt?.custom && - !providedPromptId && { - name: "builtin::rag-default", - }), - custom: [...(this.settings.prompt?.custom || []), ...messages], - }), + // if user provides prompt.custom without id/name it is his choice + // to not include default prompt msgs, but if user provides messages + // and doesn't provide prompt.custom, since we add messages to the + // prompt.custom we also have to include default prompt messages + ...(!this.settings.prompt?.custom && + !providedPromptId && { + name: "builtin::rag-default", + }), + custom: [...(this.settings.prompt?.custom || []), ...messages], }, }), query: [...messages].reverse().find((msg) => msg.role === "user")! @@ -270,20 +268,18 @@ export class EdgeDBChatLanguageModel implements EdgeDBLanguageModel { body: { ...args, context: this.settings.context, - ...((this.settings.prompt || messages.length > 1) && { + ...(this.settings.prompt && { prompt: { ...this.settings.prompt, - ...(messages.length > 1 && { - // if user provides prompt.custom without id/name it is his choice - // to not include default prompt msgs, but if user provides messages - // and doesn't provide prompt.custom, since we add messages to the - // prompt.custom we also have to include default prompt messages - ...(!this.settings.prompt?.custom && - !providedPromptId && { - name: "builtin::rag-default", - }), - custom: [...(this.settings.prompt?.custom || []), ...messages], - }), + // if user provides prompt.custom without id/name it is his choice + // to not include default prompt msgs, but if user provides messages + // and doesn't provide prompt.custom, since we add messages to the + // prompt.custom we also have to include default prompt messages + ...(!this.settings.prompt?.custom && + !providedPromptId && { + name: "builtin::rag-default", + }), + custom: [...(this.settings.prompt?.custom || []), ...messages], }, }), query: [...messages].reverse().find((msg) => msg.role === "user")! From 43b26d4105f7a1318167d9f30108dfd862539093 Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Tue, 19 Nov 2024 16:19:30 +0100 Subject: [PATCH 12/19] Update the err we send from the ai binding to the client --- packages/ai/src/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ai/src/core.ts b/packages/ai/src/core.ts index 74dd2c29c..852922ce6 100644 --- a/packages/ai/src/core.ts +++ b/packages/ai/src/core.ts @@ -109,7 +109,7 @@ export class EdgeDBAI { if (!response.ok) { const bodyText = await response.text(); - throw new Error(bodyText); + throw new Error(JSON.parse(bodyText).message); } return response; From c34c0cd2c715b86bc387e1a700b3cfcc3c27d8e2 Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Wed, 20 Nov 2024 09:34:47 +0100 Subject: [PATCH 13/19] Use client.resolveConnectionParams to get config --- packages/vercel-ai-provider/src/edgedb-provider.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/vercel-ai-provider/src/edgedb-provider.ts b/packages/vercel-ai-provider/src/edgedb-provider.ts index 9970aa6f7..d1b8ec427 100644 --- a/packages/vercel-ai-provider/src/edgedb-provider.ts +++ b/packages/vercel-ai-provider/src/edgedb-provider.ts @@ -1,5 +1,4 @@ import { type Client, createClient } from "edgedb"; -import type { ResolvedConnectConfig } from "edgedb/dist/conUtils.js"; import { getHTTPSCRAMAuth } from "edgedb/dist/httpScram.js"; import { cryptoUtils } from "edgedb/dist/browserCrypto.js"; import { getAuthenticatedFetch } from "edgedb/dist/utils.js"; @@ -39,9 +38,7 @@ export interface EdgeDBProvider extends ProviderV1 { } export async function createEdgeDB(client: Client): Promise { - const connectConfig: ResolvedConnectConfig = ( - await (client as any).pool._getNormalizedConnectConfig() - ).connectionParams; + const connectConfig = await client.resolveConnectionParams(); const fetch = await getAuthenticatedFetch( connectConfig, From 1c228f39d576944cedb69910b881900146c165af Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Wed, 20 Nov 2024 09:52:10 +0100 Subject: [PATCH 14/19] Update ai binding readme --- packages/ai/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ai/README.md b/packages/ai/README.md index 05b1ff423..3eb72df05 100644 --- a/packages/ai/README.md +++ b/packages/ai/README.md @@ -54,7 +54,7 @@ Creates an instance of `EdgeDBAI` with the specified client and options. ## Tool Calls -Tool calls are supported by the AI extension but the tool calls should be executed on the client side and results should be provided back to the EdgeDB AI. +Tool calls are supported by the AI extension. They should be executed on the client side and tool call results should be provided back to the EdgeDB AI. ## Example From a52447a01389fbce024001110c5ba7bb7c58c550 Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Wed, 20 Nov 2024 16:43:07 +0100 Subject: [PATCH 15/19] ai lib & provider: fix prompt we send to ai ext --- packages/ai/src/core.ts | 40 ++++++++------ packages/ai/src/types.ts | 7 ++- .../src/edgedb-chat-language-model.ts | 52 +++++++++---------- 3 files changed, 53 insertions(+), 46 deletions(-) diff --git a/packages/ai/src/core.ts b/packages/ai/src/core.ts index 852922ce6..aa4bacea1 100644 --- a/packages/ai/src/core.ts +++ b/packages/ai/src/core.ts @@ -14,6 +14,7 @@ import type { QueryContext, StreamingMessage, RagRequest, + EdgeDBMessage, } from "./types.js"; import { getHTTPSCRAMAuth } from "edgedb/dist/httpScram.js"; import { cryptoUtils } from "edgedb/dist/browserCrypto.js"; @@ -73,7 +74,16 @@ export class EdgeDBAI { ? { Accept: "text/event-stream", "Content-Type": "application/json" } : { Accept: "application/json", "Content-Type": "application/json" }; - const { messages } = request; + const { messages: initialMessages, prompt } = request; + + if (prompt && initialMessages) + throw new Error( + "You can provide either a prompt or a messages array, not both.", + ); + + const messages: EdgeDBMessage[] | undefined = prompt + ? [{ role: "user" as const, content: [{ type: "text", text: prompt }] }] + : initialMessages; const providedPrompt = this.options.prompt && @@ -88,21 +98,19 @@ export class EdgeDBAI { ...request, context, model: this.options.model, - ...(this.options.prompt && { - prompt: { - ...this.options.prompt, - // if user provides prompt.custom without id/name it is his choice - // to not include default prompt msgs, but if user provides messages - // and doesn't provide prompt.custom, since we add messages to the - // prompt.custom we also have to include default prompt messages - ...(!this.options.prompt?.custom && - !providedPrompt && { - name: "builtin::rag-default", - }), - custom: [...(this.options.prompt?.custom || []), ...messages], - }, - }), - query: [...messages].reverse().find((msg) => msg.role === "user")! + prompt: { + ...this.options.prompt, + // if user provides prompt.custom without id/name it is his choice + // to not include default prompt msgs, but if user provides messages + // and doesn't provide prompt.custom, since we add messages to the + // prompt.custom we also have to include default prompt messages + ...(!this.options.prompt?.custom && + !providedPrompt && { + name: "builtin::rag-default", + }), + custom: [...(this.options.prompt?.custom || []), ...messages!], + }, + query: [...messages!].reverse().find((msg) => msg.role === "user")! .content[0].text, }), }); diff --git a/packages/ai/src/types.ts b/packages/ai/src/types.ts index 980ec34f5..1e58b69e8 100644 --- a/packages/ai/src/types.ts +++ b/packages/ai/src/types.ts @@ -19,12 +19,15 @@ export interface QueryContext { max_object_count?: number; } -export interface RagRequest { - messages: EdgeDBMessage[]; +interface RagRequestBase { stream?: boolean; [key: string]: unknown; } +export type RagRequest = + | (RagRequestBase & { messages: EdgeDBMessage[]; prompt?: undefined }) + | (RagRequestBase & { prompt: string; messages?: undefined }); + export type EdgeDBMessage = | EdgeDBSystemMessage | EdgeDBUserMessage diff --git a/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts b/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts index 5c03156a2..7e77fb8af 100644 --- a/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts +++ b/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts @@ -201,20 +201,18 @@ export class EdgeDBChatLanguageModel implements EdgeDBLanguageModel { body: { ...args, context: this.settings.context, - ...(this.settings.prompt && { - prompt: { - ...this.settings.prompt, - // if user provides prompt.custom without id/name it is his choice - // to not include default prompt msgs, but if user provides messages - // and doesn't provide prompt.custom, since we add messages to the - // prompt.custom we also have to include default prompt messages - ...(!this.settings.prompt?.custom && - !providedPromptId && { - name: "builtin::rag-default", - }), - custom: [...(this.settings.prompt?.custom || []), ...messages], - }, - }), + prompt: { + ...this.settings.prompt, + // if user provides prompt.custom without id/name it is his choice + // to not include default prompt msgs, but if user provides messages + // and doesn't provide prompt.custom, since we add messages to the + // prompt.custom we also have to include default prompt messages + ...(!this.settings.prompt?.custom && + !providedPromptId && { + name: "builtin::rag-default", + }), + custom: [...(this.settings.prompt?.custom || []), ...messages], + }, query: [...messages].reverse().find((msg) => msg.role === "user")! .content[0].text, stream: false, @@ -268,20 +266,18 @@ export class EdgeDBChatLanguageModel implements EdgeDBLanguageModel { body: { ...args, context: this.settings.context, - ...(this.settings.prompt && { - prompt: { - ...this.settings.prompt, - // if user provides prompt.custom without id/name it is his choice - // to not include default prompt msgs, but if user provides messages - // and doesn't provide prompt.custom, since we add messages to the - // prompt.custom we also have to include default prompt messages - ...(!this.settings.prompt?.custom && - !providedPromptId && { - name: "builtin::rag-default", - }), - custom: [...(this.settings.prompt?.custom || []), ...messages], - }, - }), + prompt: { + ...this.settings.prompt, + // if user provides prompt.custom without id/name it is his choice + // to not include default prompt msgs, but if user provides messages + // and doesn't provide prompt.custom, since we add messages to the + // prompt.custom we also have to include default prompt messages + ...(!this.settings.prompt?.custom && + !providedPromptId && { + name: "builtin::rag-default", + }), + custom: [...(this.settings.prompt?.custom || []), ...messages], + }, query: [...messages].reverse().find((msg) => msg.role === "user")! .content[0].text, stream: true, From bb190df525987a3ad82262fa46e1850528b1b2f5 Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Thu, 21 Nov 2024 19:18:17 +0100 Subject: [PATCH 16/19] Support for vercel ai sdk v4 --- packages/vercel-ai-provider/package.json | 4 +- .../src/edgedb-chat-language-model.ts | 98 +---------- .../src/edgedb-prepare-tools.ts | 152 ++++++++++++++++++ 3 files changed, 156 insertions(+), 98 deletions(-) create mode 100644 packages/vercel-ai-provider/src/edgedb-prepare-tools.ts diff --git a/packages/vercel-ai-provider/package.json b/packages/vercel-ai-provider/package.json index 6ad631a5d..fc8e07af5 100644 --- a/packages/vercel-ai-provider/package.json +++ b/packages/vercel-ai-provider/package.json @@ -27,8 +27,8 @@ } }, "dependencies": { - "@ai-sdk/provider": "0.0.24", - "@ai-sdk/provider-utils": "1.0.20" + "@ai-sdk/provider": "^1.0.0", + "@ai-sdk/provider-utils": "^2.0.0" }, "devDependencies": { "@repo/tsconfig": "*", diff --git a/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts b/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts index 7e77fb8af..aaae3dc51 100644 --- a/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts +++ b/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts @@ -19,7 +19,6 @@ import { type EdgeDBChatModelId, type EdgeDBChatSettings, isAnthropicModel, - isOpenAIModel, } from "./edgedb-chat-settings"; import { edgedbFailedResponseHandler } from "./edgedb-error"; import { @@ -28,6 +27,7 @@ import { mapOpenAICompletionLogProbs, } from "./utils"; import { convertToEdgeDBMessages } from "./convert-to-edgedb-messages"; +import { prepareTools } from "./edgedb-prepare-tools"; export interface EdgeDBLanguageModel extends LanguageModelV1 { withSettings(settings: Partial): EdgeDBChatLanguageModel; @@ -167,7 +167,7 @@ export class EdgeDBChatLanguageModel implements EdgeDBLanguageModel { return { args: { ...baseArgs, - ...prepareToolsAndToolChoice(mode, this.modelId), + ...prepareTools(mode, this.modelId), }, warnings, }; @@ -572,97 +572,3 @@ const edgedbRagChunkSchema = z.discriminatedUnion("type", [ }), }), ]); - -// doesn't support atm structured outputs with OpenAI type regular -function prepareToolsAndToolChoice( - mode: Parameters[0]["mode"] & { - type: "regular"; - }, - model: EdgeDBChatModelId, -) { - const isOpenAI = isOpenAIModel(model); - const isAnthropic = isAnthropicModel(model); - - // when the tools array is empty, change it to undefined to prevent errors: - const tools = mode.tools?.length ? mode.tools : undefined; - - if (tools == null) { - return { tools: undefined, tool_choice: undefined }; - } - - const toolChoice = mode.toolChoice; - - const mappedTools = tools.map((tool) => - isAnthropic - ? { - name: tool.name, - description: tool.description, - input_schema: tool.parameters, - } - : { - type: "function", - function: { - name: tool.name, - description: tool.description, - parameters: tool.parameters, - }, - }, - ); - - if (toolChoice == null) { - return { tools: mappedTools, tool_choice: undefined }; - } - - const type = toolChoice.type; - - switch (type) { - case "auto": - return { - tools: mappedTools, - tool_choice: isAnthropic ? { type: "auto" } : "auto", - }; - case "none": - return isAnthropic - ? { tools: undefined, tool_choice: undefined } - : { tools: mappedTools, tool_choice: type }; - case "required": - return { - tools: mappedTools, - tool_choice: isAnthropic - ? { type: "any" } - : isOpenAI - ? "required" - : "any", - }; - - // mistral does not support tool mode directly, - // so we filter the tools and force the tool choice through 'any' - case "tool": - return isAnthropic - ? { - tools: mappedTools, - tool_choice: { type: "tool", name: toolChoice.toolName }, - } - : isOpenAI - ? { - tools: mappedTools, - tool_choice: { - type: "function", - function: { - name: toolChoice.toolName, - }, - }, - } - : { - tools: mappedTools.filter( - (tool) => tool.function!.name === toolChoice.toolName, - ), - tool_choice: "any", - }; - - default: { - const _exhaustiveCheck: never = type; - throw new Error(`Unsupported tool choice type: ${_exhaustiveCheck}`); - } - } -} diff --git a/packages/vercel-ai-provider/src/edgedb-prepare-tools.ts b/packages/vercel-ai-provider/src/edgedb-prepare-tools.ts new file mode 100644 index 000000000..332ac5d15 --- /dev/null +++ b/packages/vercel-ai-provider/src/edgedb-prepare-tools.ts @@ -0,0 +1,152 @@ +import type { + JSONSchema7, + LanguageModelV1, + LanguageModelV1CallWarning, +} from "@ai-sdk/provider"; +import { + type EdgeDBChatModelId, + isAnthropicModel, + isOpenAIModel, +} from "./edgedb-chat-settings"; + +interface OpenAILikeTool { + type: "function"; + function: { + name: string; + description: string | undefined; + parameters: unknown; + }; +} + +interface AnthropicTool { + name: string; + description: string | undefined; + input_schema: JSONSchema7; +} + +export function prepareTools( + mode: Parameters[0]["mode"] & { + type: "regular"; + }, + model: EdgeDBChatModelId, +) { + const isOpenAI = isOpenAIModel(model); + const isAnthropic = isAnthropicModel(model); + + // when the tools array is empty, change it to undefined to prevent errors: + const tools = mode.tools?.length ? mode.tools : undefined; + const toolWarnings: LanguageModelV1CallWarning[] = []; + + if (tools == null) { + return { tools: undefined, tool_choice: undefined, toolWarnings }; + } + + const edgedbOpenAILikeTools: OpenAILikeTool[] = []; + const edgedbAnthropicTools: AnthropicTool[] = []; + + for (const tool of tools) { + switch (tool.type) { + case "function": + if (isAnthropic) { + edgedbAnthropicTools.push({ + name: tool.name, + description: tool.description, + input_schema: tool.parameters, + }); + } else { + edgedbOpenAILikeTools.push({ + type: "function", + function: { + name: tool.name, + description: tool.description, + parameters: tool.parameters, + // openai + // strict: structuredOutputs === true ? true : undefined, + }, + }); + } + break; + // add support for anthropic provider tools + case "provider-defined": + toolWarnings.push({ type: "unsupported-tool", tool }); + break; + default: + toolWarnings.push({ type: "unsupported-tool", tool }); + break; + } + } + + const toolChoice = mode.toolChoice; + const edgedbTools = isAnthropic + ? edgedbAnthropicTools + : edgedbOpenAILikeTools; + + if (toolChoice == null) { + return { + tools: edgedbTools, + tool_choice: undefined, + toolWarnings, + }; + } + + const type = toolChoice.type; + + switch (type) { + case "auto": + return { + tools: edgedbTools, + tool_choice: isAnthropic ? { type: "auto" } : "auto", + toolWarnings, + // add betas to Anthropic in all cases + }; + case "none": + return isAnthropic + ? { tools: undefined, tool_choice: undefined, toolWarnings } + : { tools: edgedbTools, tool_choice: type, toolWarnings }; + case "required": + return { + tools: edgedbTools, + tool_choice: isAnthropic + ? { type: "any" } + : isOpenAI + ? "required" + : "any", + }; + + // mistral does not support tool mode directly, + // so we filter the tools and force the tool choice through 'any' + case "tool": + return isAnthropic + ? { + tools: edgedbTools, + tool_choice: { + type: "tool", + name: toolChoice.toolName, + toolWarnings, + }, + } + : isOpenAI + ? { + tools: edgedbTools, + tool_choice: { + type: "function", + function: { + name: toolChoice.toolName, + }, + }, + toolWarnings, + } + : { + tools: (edgedbTools as OpenAILikeTool[]).filter( + (tool) => tool.function!.name === toolChoice.toolName, + ), + tool_choice: "any", + toolWarnings, + }; + + default: { + const _exhaustiveCheck: never = type; + throw new Error(`Unsupported tool choice type: ${_exhaustiveCheck}`); + } + } +} From ed08833a9d4a38aca51a346f53d37597471a8b1a Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Mon, 25 Nov 2024 16:06:15 +0100 Subject: [PATCH 17/19] Extract an err properly and throw in ai lib --- packages/ai/src/core.ts | 21 +++++++++++++++------ yarn.lock | 42 ++++++++++++++++++++--------------------- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/packages/ai/src/core.ts b/packages/ai/src/core.ts index aa4bacea1..172782460 100644 --- a/packages/ai/src/core.ts +++ b/packages/ai/src/core.ts @@ -81,9 +81,9 @@ export class EdgeDBAI { "You can provide either a prompt or a messages array, not both.", ); - const messages: EdgeDBMessage[] | undefined = prompt + const messages: EdgeDBMessage[] = prompt ? [{ role: "user" as const, content: [{ type: "text", text: prompt }] }] - : initialMessages; + : initialMessages ?? []; const providedPrompt = this.options.prompt && @@ -108,16 +108,25 @@ export class EdgeDBAI { !providedPrompt && { name: "builtin::rag-default", }), - custom: [...(this.options.prompt?.custom || []), ...messages!], + custom: [...(this.options.prompt?.custom || []), ...messages], }, - query: [...messages!].reverse().find((msg) => msg.role === "user")! + query: [...messages].reverse().find((msg) => msg.role === "user")! .content[0].text, }), }); if (!response.ok) { - const bodyText = await response.text(); - throw new Error(JSON.parse(bodyText).message); + const contentType = response.headers.get("content-type"); + let errorMessage: string; + + if (contentType && contentType.includes("application/json")) { + const json = await response.json(); + errorMessage = json.message || "An error occurred"; + } else { + const bodyText = await response.text(); + errorMessage = bodyText || "An unknown error occurred"; + } + throw new Error(errorMessage); } return response; diff --git a/yarn.lock b/yarn.lock index 5906158d0..7b3dd40bd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,22 +2,22 @@ # yarn lockfile v1 -"@ai-sdk/provider-utils@1.0.20": - version "1.0.20" - resolved "https://registry.yarnpkg.com/@ai-sdk/provider-utils/-/provider-utils-1.0.20.tgz#46175945dc32ad2d76cb5447738bcac3ad59dbcb" - integrity sha512-ngg/RGpnA00eNOWEtXHenpX1MsM2QshQh4QJFjUfwcqHpM5kTfG7je7Rc3HcEDP+OkRVv2GF+X4fC1Vfcnl8Ow== +"@ai-sdk/provider-utils@^2.0.0": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@ai-sdk/provider-utils/-/provider-utils-2.0.1.tgz#953735eb8b000e96dbb1521518f9db2a9df88a76" + integrity sha512-TNg7rPhRtETB2Z9F0JpOvpGii9Fs8EWM8nYy1jEkvSXkrPJ6b/9zVnDdaJsmLFDyrMbOsPJlkblYtmYEQou36w== dependencies: - "@ai-sdk/provider" "0.0.24" - eventsource-parser "1.1.2" - nanoid "3.3.6" - secure-json-parse "2.7.0" + "@ai-sdk/provider" "1.0.0" + eventsource-parser "^3.0.0" + nanoid "^3.3.7" + secure-json-parse "^2.7.0" -"@ai-sdk/provider@0.0.24": - version "0.0.24" - resolved "https://registry.yarnpkg.com/@ai-sdk/provider/-/provider-0.0.24.tgz#e794f4255a833c47aeffcd8f6808a79b2a6b1f06" - integrity sha512-XMsNGJdGO+L0cxhhegtqZ8+T6nn4EoShS819OvCgI2kLbYTIvk0GWFGD0AXJmxkxs3DrpsJxKAFukFR7bvTkgQ== +"@ai-sdk/provider@1.0.0", "@ai-sdk/provider@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@ai-sdk/provider/-/provider-1.0.0.tgz#f4e2eeca4e1feeebc02f6335c5b699071fca2b04" + integrity sha512-Sj29AzooJ7SYvhPd+AAWt/E7j63E9+AzRnoMHUaJPRYzOd/WDrVNxxv85prF9gDcQ7XPVlSk9j6oAZV9/DXYpA== dependencies: - json-schema "0.4.0" + json-schema "^0.4.0" "@ampproject/remapping@^2.2.0", "@ampproject/remapping@^2.2.1": version "2.3.0" @@ -2911,11 +2911,16 @@ etag@~1.8.1: resolved "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz" integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg== -eventsource-parser@1.1.2, eventsource-parser@^1.1.2: +eventsource-parser@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-1.1.2.tgz" integrity sha512-v0eOBUbiaFojBu2s2NPBfYUoRR9GjcDNvCXVaqEf5vVfpIAh9f8RCo4vXTP8c63QRKCFwoLpMpTdPwwhEKVgzA== +eventsource-parser@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eventsource-parser/-/eventsource-parser-3.0.0.tgz#9303e303ef807d279ee210a17ce80f16300d9f57" + integrity sha512-T1C0XCUimhxVQzW4zFipdx0SficT651NnkR0ZSH3yQwh+mFMdLfgjABVi4YtMTtaL4s168593DaoaRLMqryavA== + execa@^5.0.0: version "5.1.1" resolved "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz" @@ -4037,7 +4042,7 @@ json-schema-traverse@^0.4.1: resolved "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== -json-schema@0.4.0: +json-schema@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5" integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA== @@ -4312,11 +4317,6 @@ mz@^2.7.0: object-assign "^4.0.1" thenify-all "^1.0.0" -nanoid@3.3.6: - version "3.3.6" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c" - integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA== - nanoid@^3.3.6, nanoid@^3.3.7: version "3.3.7" resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz" @@ -4883,7 +4883,7 @@ saxes@^6.0.0: dependencies: xmlchars "^2.2.0" -secure-json-parse@2.7.0: +secure-json-parse@^2.7.0: version "2.7.0" resolved "https://registry.yarnpkg.com/secure-json-parse/-/secure-json-parse-2.7.0.tgz#5a5f9cd6ae47df23dba3151edd06855d47e09862" integrity sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw== From cc88937d82abc2fb22bd30f2ac1635fc95e2902c Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Wed, 27 Nov 2024 15:38:10 +0100 Subject: [PATCH 18/19] Refactor ai lib and ai provider Remove undefined props from return object in edgedb-prepare-tools Use type guard for RagRequest Add buildPrompt & buildQuery func to provider & simplify postJsonToApi obj creation Add handleResponseError func and use it in fetchRag --- packages/ai/src/core.ts | 55 +++++----------- packages/ai/src/types.ts | 18 ++++- packages/ai/src/utils.ts | 30 +++++++++ .../src/edgedb-chat-language-model.ts | 65 +++++++++---------- .../src/edgedb-prepare-tools.ts | 5 +- 5 files changed, 94 insertions(+), 79 deletions(-) create mode 100644 packages/ai/src/utils.ts diff --git a/packages/ai/src/core.ts b/packages/ai/src/core.ts index 172782460..0909ca22c 100644 --- a/packages/ai/src/core.ts +++ b/packages/ai/src/core.ts @@ -1,23 +1,21 @@ import type { Client } from "edgedb"; -import { - EventSourceParserStream, - type ParsedEvent, -} from "eventsource-parser/stream"; +import { EventSourceParserStream } from "eventsource-parser/stream"; import type { ResolvedConnectConfig } from "edgedb/dist/conUtils.js"; import { getAuthenticatedFetch, type AuthenticatedFetch, } from "edgedb/dist/utils.js"; -import type { - AIOptions, - QueryContext, - StreamingMessage, - RagRequest, - EdgeDBMessage, +import { + type AIOptions, + type QueryContext, + type StreamingMessage, + type RagRequest, + isPromptRequest, } from "./types.js"; import { getHTTPSCRAMAuth } from "edgedb/dist/httpScram.js"; import { cryptoUtils } from "edgedb/dist/browserCrypto.js"; +import { extractMessageFromParsedEvent, handleResponseError } from "./utils.js"; export function createAI(client: Client, options: AIOptions) { return new EdgeDBAI(client, options); @@ -74,16 +72,19 @@ export class EdgeDBAI { ? { Accept: "text/event-stream", "Content-Type": "application/json" } : { Accept: "application/json", "Content-Type": "application/json" }; - const { messages: initialMessages, prompt } = request; - - if (prompt && initialMessages) + if (request.prompt && request.initialMessages) throw new Error( "You can provide either a prompt or a messages array, not both.", ); - const messages: EdgeDBMessage[] = prompt - ? [{ role: "user" as const, content: [{ type: "text", text: prompt }] }] - : initialMessages ?? []; + const messages = isPromptRequest(request) + ? [ + { + role: "user" as const, + content: [{ type: "text", text: request.prompt }], + }, + ] + : request.messages ?? []; const providedPrompt = this.options.prompt && @@ -116,17 +117,7 @@ export class EdgeDBAI { }); if (!response.ok) { - const contentType = response.headers.get("content-type"); - let errorMessage: string; - - if (contentType && contentType.includes("application/json")) { - const json = await response.json(); - errorMessage = json.message || "An error occurred"; - } else { - const bodyText = await response.text(); - errorMessage = bodyText || "An unknown error occurred"; - } - throw new Error(errorMessage); + handleResponseError(response); } return response; @@ -241,13 +232,3 @@ export class EdgeDBAI { return data.data[0].embedding; } } - -function extractMessageFromParsedEvent( - parsedEvent: ParsedEvent, -): StreamingMessage { - const { data } = parsedEvent; - if (!data) { - throw new Error("Expected SSE message to include a data payload"); - } - return JSON.parse(data) as StreamingMessage; -} diff --git a/packages/ai/src/types.ts b/packages/ai/src/types.ts index 1e58b69e8..9b5e4c9ea 100644 --- a/packages/ai/src/types.ts +++ b/packages/ai/src/types.ts @@ -24,9 +24,21 @@ interface RagRequestBase { [key: string]: unknown; } -export type RagRequest = - | (RagRequestBase & { messages: EdgeDBMessage[]; prompt?: undefined }) - | (RagRequestBase & { prompt: string; messages?: undefined }); +export type RagRequestPrompt = RagRequestBase & { + prompt: string; +}; + +export type RagRequestMessages = RagRequestBase & { + messages: EdgeDBMessage[]; +}; + +export type RagRequest = RagRequestPrompt | RagRequestMessages; + +export function isPromptRequest( + request: RagRequest, +): request is RagRequestPrompt { + return "prompt" in request; +} export type EdgeDBMessage = | EdgeDBSystemMessage diff --git a/packages/ai/src/utils.ts b/packages/ai/src/utils.ts new file mode 100644 index 000000000..0bbc1a4b1 --- /dev/null +++ b/packages/ai/src/utils.ts @@ -0,0 +1,30 @@ +import type { ParsedEvent } from "eventsource-parser"; +import type { StreamingMessage } from "./types.js"; + +export function extractMessageFromParsedEvent( + parsedEvent: ParsedEvent, +): StreamingMessage { + const { data } = parsedEvent; + if (!data) { + throw new Error("Expected SSE message to include a data payload"); + } + return JSON.parse(data) as StreamingMessage; +} + +export async function handleResponseError(response: Response) { + const contentType = response.headers.get("content-type"); + let errorMessage: string; + + if (contentType && contentType.includes("application/json")) { + const json = await response.json(); + + errorMessage = + typeof json === "object" && json != null && "message" in json + ? json.message + : `An error occurred: ${json}`; + } else { + const bodyText = await response.text(); + errorMessage = bodyText || "An unknown error occurred"; + } + throw new Error(errorMessage); +} diff --git a/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts b/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts index aaae3dc51..6a8a50f2a 100644 --- a/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts +++ b/packages/vercel-ai-provider/src/edgedb-chat-language-model.ts @@ -18,6 +18,7 @@ import { type EdgeDBChatConfig, type EdgeDBChatModelId, type EdgeDBChatSettings, + type EdgeDBMessage, isAnthropicModel, } from "./edgedb-chat-settings"; import { edgedbFailedResponseHandler } from "./edgedb-error"; @@ -185,36 +186,44 @@ export class EdgeDBChatLanguageModel implements EdgeDBLanguageModel { } } + private buildPrompt(messages: EdgeDBMessage[]) { + const providedPromptId = + this.settings.prompt && + ("name" in this.settings.prompt || "id" in this.settings.prompt); + + return { + ...this.settings.prompt, + // if user provides prompt.custom without id/name it is his choice + // to not include default prompt msgs, but if user provides messages + // and doesn't provide prompt.custom, since we add messages to the + // prompt.custom we also have to include default prompt messages + ...(!this.settings.prompt?.custom && + !providedPromptId && { + name: "builtin::rag-default", + }), + custom: [...(this.settings.prompt?.custom || []), ...messages], + }; + } + + private buildQuery(messages: EdgeDBMessage[]) { + return [...messages].reverse().find((msg) => msg.role === "user")! + .content[0].text; + } + async doGenerate( options: Parameters[0], ): Promise>> { const { args, warnings } = this.getArgs(options); const { messages } = args; - const providedPromptId = - this.settings.prompt && - ("name" in this.settings.prompt || "id" in this.settings.prompt); - const { responseHeaders, value: response } = await postJsonToApi({ url: `rag`, headers: options.headers, body: { ...args, context: this.settings.context, - prompt: { - ...this.settings.prompt, - // if user provides prompt.custom without id/name it is his choice - // to not include default prompt msgs, but if user provides messages - // and doesn't provide prompt.custom, since we add messages to the - // prompt.custom we also have to include default prompt messages - ...(!this.settings.prompt?.custom && - !providedPromptId && { - name: "builtin::rag-default", - }), - custom: [...(this.settings.prompt?.custom || []), ...messages], - }, - query: [...messages].reverse().find((msg) => msg.role === "user")! - .content[0].text, + prompt: this.buildPrompt(messages), + query: this.buildQuery(messages), stream: false, }, failedResponseHandler: edgedbFailedResponseHandler, @@ -256,30 +265,14 @@ export class EdgeDBChatLanguageModel implements EdgeDBLanguageModel { const { args, warnings } = this.getArgs(options); const { messages } = args; - const providedPromptId = - this.settings.prompt && - ("name" in this.settings.prompt || "id" in this.settings.prompt); - const { responseHeaders, value: response } = await postJsonToApi({ url: `rag`, headers: options.headers, body: { ...args, context: this.settings.context, - prompt: { - ...this.settings.prompt, - // if user provides prompt.custom without id/name it is his choice - // to not include default prompt msgs, but if user provides messages - // and doesn't provide prompt.custom, since we add messages to the - // prompt.custom we also have to include default prompt messages - ...(!this.settings.prompt?.custom && - !providedPromptId && { - name: "builtin::rag-default", - }), - custom: [...(this.settings.prompt?.custom || []), ...messages], - }, - query: [...messages].reverse().find((msg) => msg.role === "user")! - .content[0].text, + prompt: this.buildPrompt(messages), + query: this.buildQuery(messages), stream: true, }, failedResponseHandler: edgedbFailedResponseHandler, diff --git a/packages/vercel-ai-provider/src/edgedb-prepare-tools.ts b/packages/vercel-ai-provider/src/edgedb-prepare-tools.ts index 332ac5d15..1902c02b6 100644 --- a/packages/vercel-ai-provider/src/edgedb-prepare-tools.ts +++ b/packages/vercel-ai-provider/src/edgedb-prepare-tools.ts @@ -38,7 +38,7 @@ export function prepareTools( const toolWarnings: LanguageModelV1CallWarning[] = []; if (tools == null) { - return { tools: undefined, tool_choice: undefined, toolWarnings }; + return { toolWarnings }; } const edgedbOpenAILikeTools: OpenAILikeTool[] = []; @@ -84,7 +84,6 @@ export function prepareTools( if (toolChoice == null) { return { tools: edgedbTools, - tool_choice: undefined, toolWarnings, }; } @@ -101,7 +100,7 @@ export function prepareTools( }; case "none": return isAnthropic - ? { tools: undefined, tool_choice: undefined, toolWarnings } + ? { toolWarnings } : { tools: edgedbTools, tool_choice: type, toolWarnings }; case "required": return { From 342156784b9be3e8897bc2b38ca6f3fc67f240dd Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Wed, 27 Nov 2024 19:22:34 +0100 Subject: [PATCH 19/19] Use ts types in ai lib for chunk types instead of zod schema --- packages/ai/src/types.ts | 205 ++++++++++++++++++++------------------- 1 file changed, 106 insertions(+), 99 deletions(-) diff --git a/packages/ai/src/types.ts b/packages/ai/src/types.ts index 9b5e4c9ea..c12bd53bf 100644 --- a/packages/ai/src/types.ts +++ b/packages/ai/src/types.ts @@ -1,7 +1,37 @@ -import { z } from "zod"; - export type ChatParticipantRole = "system" | "user" | "assistant" | "tool"; +export interface EdgeDBSystemMessage { + role: "system"; + content: string; +} + +export interface EdgeDBUserMessage { + role: "user"; + content: { type: "text"; text: string }[]; +} + +export interface EdgeDBAssistantMessage { + role: "assistant"; + content: string; + tool_calls?: { + id: string; + type: "function"; + function: { name: string; arguments: string }; + }[]; +} + +export interface EdgeDBToolMessage { + role: "tool"; + content: string; + tool_call_id: string; +} + +export type EdgeDBMessage = + | EdgeDBSystemMessage + | EdgeDBUserMessage + | EdgeDBAssistantMessage + | EdgeDBToolMessage; + export type Prompt = | { name: string; custom?: EdgeDBMessage[] } | { id: string; custom?: EdgeDBMessage[] } @@ -40,109 +70,86 @@ export function isPromptRequest( return "prompt" in request; } -export type EdgeDBMessage = - | EdgeDBSystemMessage - | EdgeDBUserMessage - | EdgeDBAssistantMessage - | EdgeDBToolMessage; +export interface MessageStart { + type: "message_start"; + message: { + id: string; + model: string; + role: "assistant" | "system" | "user"; //todo check this; + usage?: { + prompt_tokens: number; + completion_tokens: number; + } | null; + }; +} -export interface EdgeDBSystemMessage { - role: "system"; - content: string; +export interface ContentBlockStart { + type: "content_block_start"; + index: number; + content_block: + | { + type: "text"; + text: string; + } + | { + type: "tool_use"; + id?: string | null; + name: string; + args?: string | null; + }; } -export interface EdgeDBUserMessage { - role: "user"; - content: { type: "text"; text: string }[]; +export interface ContentBlockDelta { + type: "content_block_delta"; + index: number; + delta: + | { + type: "text_delta"; + text: string; + } + | { + type: "tool_call_delta"; + args: string; + }; + logprobs?: { + tokens: string[]; + token_logprobs: number[]; + top_logprobs: Record[] | null; + } | null; } -export interface EdgeDBAssistantMessage { - role: "assistant"; - content: string; - tool_calls?: { - id: string; - type: "function"; - function: { name: string; arguments: string }; - }[]; +export interface ContentBlockStop { + type: "content_block_stop"; + index: number; } -export interface EdgeDBToolMessage { - role: "tool"; - content: string; - tool_call_id: string; +export interface MessageDelta { + type: "message_delta"; + delta: { + stop_reason: string; + }; + usage?: { + completion_tokens: number; + }; +} + +export interface MessageStop { + type: "message_stop"; +} + +export interface MessageError { + type: "error"; + error: { + type: string; + message: string; + }; } -export type StreamingMessage = z.infer; - -const _edgedbRagChunkSchema = z.discriminatedUnion("type", [ - z.object({ - type: z.literal("message_start"), - message: z.object({ - id: z.string(), - model: z.string(), - role: z.enum(["assistant", "system", "user"]), - usage: z - .object({ - prompt_tokens: z.number(), - completion_tokens: z.number(), - }) - .nullish(), - }), - }), - z.object({ - type: z.literal("content_block_start"), - index: z.number(), - content_block: z.discriminatedUnion("type", [ - z.object({ - type: z.literal("text"), - text: z.string(), - }), - z.object({ - type: z.literal("tool_use"), - id: z.string().nullish(), - name: z.string(), - args: z.string().nullish(), - }), - ]), - }), - z.object({ - type: z.literal("content_block_delta"), - index: z.number(), - delta: z.discriminatedUnion("type", [ - z.object({ - type: z.literal("text_delta"), - text: z.string(), - }), - z.object({ - type: z.literal("tool_call_delta"), - args: z.string(), // partial json - }), - ]), - logprobs: z - .object({ - tokens: z.array(z.string()), - token_logprobs: z.array(z.number()), - top_logprobs: z.array(z.record(z.string(), z.number())).nullable(), - }) - .nullish(), - }), - z.object({ - type: z.literal("content_block_stop"), - index: z.number(), - }), - z.object({ - type: z.literal("message_delta"), - delta: z.object({ stop_reason: z.string() }), - usage: z.object({ completion_tokens: z.number() }).nullish(), - }), - z.object({ - type: z.literal("message_stop"), - }), - z.object({ - type: z.literal("error"), - error: z.object({ - type: z.string(), - message: z.string(), - }), - }), -]); +export type StreamingMessage = + | MessageStart + | ContentBlockStart + | ContentBlockDelta + | ContentBlockStop + | MessageDelta + | MessageStop + | MessageError;