Skip to content

Commit

Permalink
✨ Managed DB + embeddings
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Sep 16, 2024
1 parent 1842fcc commit 99a5877
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export function ConnectorDisplay({ item }: ItemDisplayProps) {
});

const mappingConnectionStrategies = connectionStrategies?.filter(
(cs) => extractVertical(cs.type).toLowerCase() === item?.vertical &&
extractProvider(cs.type).toLowerCase() === item?.name
(cs) => extractVertical(cs.type)?.toLowerCase() === item?.vertical?.toLowerCase() &&
extractProvider(cs.type)?.toLowerCase() === item?.name?.toLowerCase()
);

const oauthAttributes = CONNECTORS_METADATA[item?.vertical!]?.[item?.name!]?.options?.oauth_attributes || [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class EmbeddingCredentialsService {
return this.connectionsStrategiesService.getConnectionStrategyData(
projectId,
type,
['api_key'],
['embeddingApiKey'],
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/@core/rag/embedding/embedding.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class EmbeddingService implements OnModuleInit {
}

async embedQuery(query: string, projectId?: string) {
// await this.initializeEmbeddings(projectId);
await this.initializeEmbeddings(projectId);
return this.embeddings.embedQuery(query);
}
}
1 change: 1 addition & 0 deletions packages/api/src/@core/rag/rag.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class RagController {
body.query,
body.topK,
linkedUserId,
projectId,
);
}

Expand Down
13 changes: 11 additions & 2 deletions packages/api/src/@core/rag/rag.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@ export class RagService {
private s3Service: S3Service,
) {}

async queryEmbeddings(query: string, topK = 5, linkedUserId: string) {
const queryEmbedding = await this.embeddingService.embedQuery(query);
async queryEmbeddings(
query: string,
topK = 5,
linkedUserId: string,
projectId: string,
) {
const queryEmbedding = await this.embeddingService.embedQuery(
query,
projectId,
);
const results = await this.vectorDatabaseService.queryEmbeddings(
queryEmbedding,
topK,
linkedUserId,
projectId,
);
return results.map((match: any) => ({
chunk: match.metadata.text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class PineconeService {
fileId: string,
chunks: ProcessedChunk[],
embeddings: number[][],
projectId: string,
linkedUserId: string,
) {
const index = this.client.Index(this.indexName);
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/@core/rag/vecdb/vecdb.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ export class VectorDatabaseService implements OnModuleInit {
queryEmbedding: number[],
topK: number,
linkedUserId: string,
projectId: string,
) {
await this.init(projectId);
return this.vectorDb.queryEmbeddings(queryEmbedding, topK, linkedUserId);
}
}

0 comments on commit 99a5877

Please sign in to comment.