Skip to content

Commit

Permalink
fix(app): set new as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgfr committed Jul 25, 2023
1 parent bbd557a commit 10c3849
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
31 changes: 20 additions & 11 deletions targets/export-elasticsearch/src/services/embedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ export class EmbeddingService {
SOURCES.CONTRIBUTIONS,
CollectionSlug.CONTRIBUTION + "-generic",
(r) => {
return r.document.answers?.generic?.markdown ?? "";
return (
r.document.answers?.generic?.text ??
r.document.answers?.generic?.markdown ??
""
);
}
);
await this.ingestDocuments(
Expand Down Expand Up @@ -125,23 +129,27 @@ export class EmbeddingService {

async getContributionDocuments(query: string) {
// etape 1 : retrouver les 5 meilleurs elements
const collection = await this.client.getOrCreateCollection({
name: CollectionSlug.CONTRIBUTION + "-generic",
embeddingFunction: this.embedder,
});
const result = await collection.query({
queryTexts: [query],
});
const result = await this.getDocuments(
CollectionSlug.CONTRIBUTION + "-generic",
query
);
// etape 2 : recuperer les parties découpées
// etape 3 : filer les infos liées à la cc
return result;
}

async getServicePublicDocuments(query: string): Promise<ChromaGetResults> {
return await this.getDocuments(CollectionSlug.SERVICE_PUBLIC, query);
}

private async getDocuments(
collectionName: string,
query: string
): Promise<ChromaGetResults> {
try {
const result: ChromaGetResults = [];
const collection = await this.client.getOrCreateCollection({
name: CollectionSlug.SERVICE_PUBLIC,
name: collectionName,
embeddingFunction: this.embedder,
});
const queryTextsResult = await collection.query({
Expand All @@ -167,7 +175,6 @@ export class EmbeddingService {
},
},
});
console.log(queryResult);
const ids = queryResult.ids[0]!;
const documents = queryResult.documents[0]!;
const text: string = documents
Expand Down Expand Up @@ -196,7 +203,9 @@ export class EmbeddingService {
}

async countAndPeekContributionDocuments() {
return await this.countAndPeekDocuments(CollectionSlug.CONTRIBUTION);
return await this.countAndPeekDocuments(
CollectionSlug.CONTRIBUTION + "-generic"
);
}

async countAndPeekServicePublicDocuments() {
Expand Down
1 change: 1 addition & 0 deletions targets/export-elasticsearch/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface DocumentRepo {
answers?: {
generic?: {
markdown: string;
text: string;
};
conventionAnswer?: {
markdown: string;
Expand Down

0 comments on commit 10c3849

Please sign in to comment.