vector-store.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * Interface for vector database clients
  3. */
  4. export type PointStruct = {
  5. id: string
  6. vector: number[]
  7. payload: Record<string, any>
  8. }
  9. export interface IVectorStore {
  10. /**
  11. * Initializes the vector store
  12. * @returns Promise resolving to boolean indicating if a new collection was created
  13. */
  14. initialize(): Promise<boolean>
  15. /**
  16. * Upserts points into the vector store
  17. * @param points Array of points to upsert
  18. */
  19. upsertPoints(points: PointStruct[]): Promise<void>
  20. /**
  21. * Searches for similar vectors
  22. * @param queryVector Vector to search for
  23. * @param directoryPrefix Optional directory prefix to filter results
  24. * @param minScore Optional minimum score threshold
  25. * @param maxResults Optional maximum number of results to return
  26. * @returns Promise resolving to search results
  27. */
  28. search(
  29. queryVector: number[],
  30. directoryPrefix?: string,
  31. minScore?: number,
  32. maxResults?: number,
  33. ): Promise<VectorStoreSearchResult[]>
  34. /**
  35. * Deletes points by file path
  36. * @param filePath Path of the file to delete points for
  37. */
  38. deletePointsByFilePath(filePath: string): Promise<void>
  39. /**
  40. * Deletes points by multiple file paths
  41. * @param filePaths Array of file paths to delete points for
  42. */
  43. deletePointsByMultipleFilePaths(filePaths: string[]): Promise<void>
  44. /**
  45. * Clears all points from the collection
  46. */
  47. clearCollection(): Promise<void>
  48. /**
  49. * Deletes the entire collection.
  50. */
  51. deleteCollection(): Promise<void>
  52. /**
  53. * Checks if the collection exists
  54. * @returns Promise resolving to boolean indicating if the collection exists
  55. */
  56. collectionExists(): Promise<boolean>
  57. }
  58. export interface VectorStoreSearchResult {
  59. id: string | number
  60. score: number
  61. payload?: Payload | null
  62. }
  63. export interface Payload {
  64. filePath: string
  65. codeChunk: string
  66. startLine: number
  67. endLine: number
  68. [key: string]: any
  69. }