Pinecone.io vector database module for nestjs
$ npm i --save @nhogs/nestjs-pinecone
See Pincone quickstart guide for config details
@Module({
imports: [
PineconeModule.register({
environment: 'YOUR_ENVIRONMENT', // Default is 'us-west1-gcp',
project: 'YOUR_PROJECT', // Project id
apiKey: 'YOUR_API_KEY', // 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
index: 'YOUR_INDEX', // Optional index name
}),
],
})
export class AppModule {}
@Module({
imports: [
PineconeModule.registerAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService): PineconeConfig => {
return {
index: configService.get('PINECONE_INDEX'),
project: configService.get('PINECONE_PROJECT'),
environment: configService.get('PINECONE_ENV'),
apiKey: configService.get('PINECONE_API_KEY'),
};
},
}),
ConfigModule.forRoot({
envFilePath: './your/env/file/path/.env',
}),
],
})
export class AsyncAppModule {}
@Injectable()
export class PineconeIndexService {
/**
* Check environment and make sure your Pinecone API key works.
*/
whoAmI(): Observable<WhoAmIResult> {}
/**
* This operation returns a list of your Pinecone indexes.
*/
listIndexes(): Observable<string[]> {}
/**
* Get a description of an index.
* @param indexName or default index set in config
*/
describeIndex(indexName?: string): Observable<IndexDescriptionResult> {}
}
@Injectable()
export class PineconeVectorService {
/**
* The DescribeIndexStats operation returns statistics about the index's contents.
* @param index index name
*/
describeIndexStats(index?: string): Observable<IndexStatsResult> {}
/**
* The Query operation searches a namespace, using one or more query vectors. It retrieves the ids of the most similar items in a namespace, along with their similarity scores.
* @param query
* @param index
*/
query(query: Query, index?: string): Observable<QueryResults> {}
/**
* The Delete operation deletes vectors, by id, from a single namespace. You can delete items by their id, from a single namespace.
* @param del
* @param index
*/
delete(del: Delete, index?: string): Observable<DeleteResult> {}
/**
* The Fetch operation looks up and returns vectors, by id, from a single namespace. The returned vectors include the vector data and/or metadata.
* @param fetch
* @param index
*/
fetch(fetch: Fetch, index?: string): Observable<FetchResult> {}
/**
* The Update operation updates vector in a namespace. If a value is included, it will overwrite the previous value. If a set_metadata is included, the values of the fields specified in it will be added or overwrite the previous value.
* @param update
* @param index
*/
update(update: Update, index?: string): Observable<UpdateResult> {}
/**
* The Upsert operation writes vectors into a namespace. If a new value is upserted for an existing vector id, it will overwrite the previous value.
* @param upsert
* @param index
*/
upsert(upsert: Upsert, index?: string): Observable<UpsertResult> {}
}