VectorStoreService
Upgather SDK / VectorStoreService
Class: VectorStoreService
Orchestrates file operations (add/update/remove) in your OpenAI vector store, scoped by eventId in Strapi.
Constructors
new VectorStoreService()
new VectorStoreService(
strapi,logger?):VectorStoreService
Creates an instance of VectorStoreService.
Parameters
strapi
The StrapiService instance for interacting with Strapi CMS
logger?
Optional logger instance. If not provided, uses a silent logger.
Returns
Methods
addFile()
addFile(
eventId,file,filename?,options?):Promise<UploadedFile>
Add a new file to the vector store for a given event.
Parameters
eventId
string
Strapi event identifier.
file
File to upload (Buffer, Readable, or FileObject).
FileObject | Buffer<ArrayBufferLike> | Readable
filename?
string
Optional filename for buffer uploads.
options?
Optional configuration including OpenAI key.
Returns
Promise<UploadedFile>
The uploaded file information.
Throws
Error if upload or association fails.
getVectorConfig()
getVectorConfig(
eventId,providedKey?):Promise<{openAiKey:string;orgKey:string;vectorStoreId:string; }>
Fetches the OpenAI API key and vector-store ID for a given event.
Parameters
eventId
string
The Strapi eventId (api::event.event → eventId)
providedKey?
string
Optional OpenAI key to use instead of the org key
Returns
Promise<{ openAiKey: string; orgKey: string; vectorStoreId: string; }>
An object containing:
- openAiKey: the OpenAI key (provided key takes precedence)
- vectorStoreId: the vector store identifier (
VectorStore.vector_store_id) - orgKey: the organization's key (for fallback purposes)
Throws
Error if the event, organization, or vector store is missing or mis-configured.
removeFile()
removeFile(
eventId,fileId,options?):Promise<FileDeleted&object>
Remove a file from the vector store and delete it from OpenAI's file storage.
Parameters
eventId
string
Strapi event identifier.
fileId
string
ID of the file to remove.
options?
Optional configuration including OpenAI key.
Returns
Promise<FileDeleted & object>
The OpenAI delete response (usually { deleted: true }).
Throws
Error if disassociation or deletion fails.
Remarks
This method performs two operations:
- Removes the file association from the vector store
- Deletes the actual file from OpenAI's file storage
updateFile()
updateFile(
eventId,oldFileId,newFile,filename?,options?):Promise<UploadedFile>
Replace an existing file in the vector store. Under the hood, disassociates & deletes the old file, then uploads & re-associates.
Parameters
eventId
string
Strapi event identifier.
oldFileId
string
ID of the file to replace.
newFile
New file (Buffer, Readable, or FileObject).
FileObject | Buffer<ArrayBufferLike> | Readable
filename?
string
Optional filename for buffer uploads.
options?
Optional configuration including OpenAI key.
Returns
Promise<UploadedFile>
The new uploaded file information.
Throws
Error if any step fails.