adk-typescript
Version:
TypeScript port of Google's Agent Development Kit (ADK)
102 lines (101 loc) • 3.43 kB
TypeScript
import { SessionInterface as Session } from '../sessions/types';
import { BaseMemoryService, SearchMemoryResponse } from './BaseMemoryService';
/**
* Configuration for the Vertex AI RAG memory service.
*/
export interface VertexAiRagConfig {
/** The Vertex AI project */
project: string;
/** The location of the Vertex AI service */
location: string;
/** The RAG corpus name */
ragCorpus: string;
/** The number of contexts to retrieve */
similarityTopK?: number;
/** Only returns contexts with vector distance smaller than the threshold */
vectorDistanceThreshold?: number;
}
/**
* A memory service that uses Vertex AI RAG capabilities for semantic search.
*
* This implementation uses the Vertex AI embedding models to compute
* embeddings for memory entries and perform semantic searches.
*/
export declare class VertexAiRagMemoryService implements BaseMemoryService {
private config;
private vertexRagStore;
private vertexAi;
private baseUrl;
private auth;
private memoryStore;
/**
* Creates a new VertexAiRagMemoryService
* @param config The configuration for the service
*/
constructor(config: VertexAiRagConfig);
/**
* Adds a session to the memory service.
* @param session The session to add
*/
addSessionToMemory(session: Session): Promise<void>;
/**
* Uploads a file to the Vertex AI RAG corpus.
*
* @param corpusName The name of the corpus
* @param filePath The path to the file
* @param displayName The display name to store session info
*/
private uploadFile;
/**
* Searches for sessions that match the query.
* @param appName The name of the application
* @param userId The id of the user
* @param query The query to search for
* @returns A SearchMemoryResponse containing the matching memories
*/
searchMemory(appName: string, userId: string, query: string): Promise<SearchMemoryResponse>;
/**
* Calls Vertex AI RAG retrieval query.
*
* @param text The text to search for
* @returns The retrieval query response
*/
private retrieveContexts;
/**
* Formats the RAG corpus name to include project and location if not already included.
*
* @param corpusName The corpus name to format
* @returns The formatted corpus name
*/
private formatRagCorpusName;
/**
* Merges event lists that have overlapping timestamps.
*
* @param eventLists Lists of events to merge
* @returns Merged event lists
*/
private mergeEventLists;
/**
* Stores a memory entry.
* @param appName The application name
* @param userId The user ID
* @param key The memory key
* @param value The memory value
*/
store(appName: string, userId: string, key: string, value: any): Promise<void>;
/**
* Retrieves a memory entry.
* @param appName The application name
* @param userId The user ID
* @param key The memory key
* @returns The memory value, or undefined if not found
*/
retrieve(appName: string, userId: string, key: string): Promise<any | undefined>;
/**
* Deletes a memory entry.
* @param appName The application name
* @param userId The user ID
* @param key The memory key
*/
delete(appName: string, userId: string, key: string): Promise<void>;
}