diff --git a/package-lock.json b/package-lock.json index 30c1cd7..95a99cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@alkemio/space-ingest", - "version": "0.9.0", + "version": "0.9.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@alkemio/space-ingest", - "version": "0.9.0", + "version": "0.9.2", "license": "EUPL-1.2", "dependencies": { "@alkemio/client-lib": "^0.31.0", diff --git a/package.json b/package.json index f760f01..6fe7636 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@alkemio/space-ingest", - "version": "0.9.1", + "version": "0.9.2", "description": "", "author": "Alkemio Foundation", "private": true, diff --git a/src/callout.handlers/base.ts b/src/callout.handlers/base.ts index a7abc4f..64e4846 100644 --- a/src/callout.handlers/base.ts +++ b/src/callout.handlers/base.ts @@ -1,5 +1,5 @@ import { Logger } from 'winston'; -import { Callout, CalloutContribution } from '../generated/graphql'; +import { Callout } from '../generated/graphql'; import { Document } from 'langchain/document'; import generateDocument from '../generate.document'; @@ -49,15 +49,14 @@ export const baseHandler = async ( ]; logger.info(`Generating documents for Callout (${documentId}) contributions`); - // extra loop but will do for now - callout.contributions - ?.map((contribution: Partial) => { - let docLike; - if (!!contribution.link) { - docLike = contribution.link; - } else if (!!contribution.post) { - docLike = contribution.post; - } + for (const contribution of callout.contributions || []) { + let docLike; + if (contribution.link) { + docLike = contribution.link; + } else if (contribution.post) { + docLike = contribution.post; + } + if (docLike) { const { pageContent, documentId, source, type, title } = generateDocument(docLike); result.push( @@ -71,9 +70,8 @@ export const baseHandler = async ( }, }) ); - }) - .join('\n'); - + } + } logger.info( `Documents for Callout (${documentId}) generated. # of documents ${result.length}` ); diff --git a/src/embed.ts b/src/embed.ts index ae4079b..43bcd6f 100644 --- a/src/embed.ts +++ b/src/embed.ts @@ -99,7 +99,14 @@ export default async ( ); const response = await openAi.getEmbeddings(deployment, batch); data = [...data, ...response.data]; - logger.info('Embeddings generates'); + logger.debug( + `Generated embeddings ${ + response.data.length + }; Embeddings length are: ${Array.from( + new Set(response.data.map(({ embedding }) => embedding.length)) + )}` + ); + logger.info('Embeddings generated.'); } catch (error) { logger.error({ ...(error as Error),