UNPKG

@squidcloud/client

Version:

A typescript implementation of the Squid client

95 lines (94 loc) 4.83 kB
import { AiEmbeddingsModelWithOptionalFields, AiKnowledgeBase, AiKnowledgeBaseChatOptions, AiKnowledgeBaseContext, AiKnowledgeBaseContextRequest, AiKnowledgeBaseContextWithReasoning, AiKnowledgeBaseDownloadContextResponse, AiKnowledgeBaseSearchContextsWithContextIdRequest, AiKnowledgeBaseSearchContextsWithPromptRequest, AiKnowledgeBaseSearchResultChunk, GenerateMetadataFieldDescriptionsRequest, GenerateMetadataFieldDescriptionsResponse, UpsertKnowledgeBaseContextResponse, UpsertKnowledgeBaseContextsResponse } from '../../../internal-common/src/public-types/ai-knowledge-base.public-types'; import { AiContextId } from '../../../internal-common/src/public-types/communication.public-types'; /** * Parameters for creating or updating an AI agent. * Excludes the `id` field, as it is derived from the agent instance. * @category AI */ export type UpsertKnowledgeBaseRequestParams = Omit<AiKnowledgeBase, 'id'>; /** * A reference to an AI knowledge base. */ export declare class AiKnowledgeBaseReference { private readonly knowledgeBaseId; private readonly rpcManager; private readonly jobClient; /** * Returns the AI knowledge base. * @returns A promise that resolves to the AI knowledge base or undefined if not found. */ getKnowledgeBase(): Promise<AiKnowledgeBase | undefined>; /** * Returns all AI knowledge bases. * @returns A promise that resolves to an array of AI Knowledge Bases */ listKnowledgeBases(): Promise<Array<AiKnowledgeBase>>; /** * Upserts the AI knowledge base. * @param knowledgeBase */ upsertKnowledgeBase(knowledgeBase: Omit<AiEmbeddingsModelWithOptionalFields, 'id' | 'appId' | 'updatedAt'>): Promise<void>; /** * AI-generates descriptions for this knowledge base's metadata fields and returns them WITHOUT * persisting — the caller saves them onto the KB (e.g. via `upsertKnowledgeBase`). By default only * fields with an empty description are generated; pass `overwriteExisting` to regenerate all. * @param options Optional `fieldNames` to limit generation to specific fields, and `overwriteExisting`. * @returns The (re)generated fields with their new descriptions (not yet persisted). */ generateMetadataFieldDescriptions(options?: Omit<GenerateMetadataFieldDescriptionsRequest, 'knowledgeBaseId'>): Promise<GenerateMetadataFieldDescriptionsResponse>; /** * Deletes the AI knowledge base. * @returns A promise that resolves when the deletion is complete. */ delete(): Promise<void>; /** * Lists all contexts associated with the knowledge base. */ listContexts(truncateTextAfter?: number): Promise<Array<AiKnowledgeBaseContext>>; /** * Lists the ids for all contexts associated with the knowledge base. */ listContextIds(): Promise<Array<AiContextId>>; /** * Retrieves a specific context by its ID. */ getContext(contextId: string): Promise<AiKnowledgeBaseContext | undefined>; /** * Deletes a specific context by its ID. */ deleteContext(contextId: string): Promise<void>; /** * Deletes multiple contexts. */ deleteContexts(contextIds: Array<string>): Promise<void>; /** * Adds or updates a single context. */ upsertContext(contextRequest: AiKnowledgeBaseContextRequest, file?: File): Promise<UpsertKnowledgeBaseContextResponse>; /** * Adds or updates multiple contexts. */ upsertContexts(contextRequests: Array<AiKnowledgeBaseContextRequest>, files?: Array<File>): Promise<UpsertKnowledgeBaseContextsResponse>; /** * Performs a semantic search in the knowledge base and returns chunks from the different contexts. */ search(options: AiKnowledgeBaseChatOptions & { prompt: string; }): Promise<Array<AiKnowledgeBaseSearchResultChunk>>; /** * Performs a semantic search in the knowledge base and returns contexts with reasoning. * Can be used for matchmaking or similarity search. */ searchContextsWithPrompt(request: Omit<AiKnowledgeBaseSearchContextsWithPromptRequest, 'knowledgeBaseId'>): Promise<Array<AiKnowledgeBaseContextWithReasoning>>; /** * Performs a semantic search in the knowledge base and returns contexts with reasoning. * Can be used for matchmaking or similarity search. */ searchContextsWithContextId(request: Omit<AiKnowledgeBaseSearchContextsWithContextIdRequest, 'knowledgeBaseId'>): Promise<Array<AiKnowledgeBaseContextWithReasoning>>; /** * Gets the download URL for the requested context. * * @return Object with temporary URL to download the requested context. Will be `undefined` if file is unavailable. */ downloadContext(contextId: string): Promise<AiKnowledgeBaseDownloadContextResponse>; }