Skip to content

Commit

Permalink
Merge pull request #56 from alkem-io/handle-contribution-without-post…
Browse files Browse the repository at this point in the history
…-and-link

Handle callout contributions without neither post nor link
  • Loading branch information
valeksiev authored Oct 8, 2024
2 parents 35a294d + 6315235 commit 94c0bd7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alkemio/space-ingest",
"version": "0.9.1",
"version": "0.9.2",
"description": "",
"author": "Alkemio Foundation",
"private": true,
Expand Down
24 changes: 11 additions & 13 deletions src/callout.handlers/base.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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<CalloutContribution>) => {
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(
Expand All @@ -71,9 +70,8 @@ export const baseHandler = async (
},
})
);
})
.join('\n');

}
}
logger.info(
`Documents for Callout (${documentId}) generated. # of documents ${result.length}`
);
Expand Down
9 changes: 8 additions & 1 deletion src/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 94c0bd7

Please sign in to comment.