diff --git a/src/parser/content-evaluator-module.ts b/src/parser/content-evaluator-module.ts index 37d80758..46f2caf9 100644 --- a/src/parser/content-evaluator-module.ts +++ b/src/parser/content-evaluator-module.ts @@ -108,7 +108,11 @@ export class ContentEvaluatorModule extends BaseModule { ); if (Object.keys(relevancesByAi).length !== commentsToEvaluate.length + prCommentsToEvaluate.length) { - throw this.context.logger.fatal("Relevance / Comment length mismatch!", { relevancesByAi, commentsToEvaluate }); + throw this.context.logger.fatal("Relevance / Comment length mismatch!", { + relevancesByAi, + commentsToEvaluate, + prCommentsToEvaluate, + }); } for (const currentComment of commentsWithScore) { diff --git a/src/web/api/index.ts b/src/web/api/index.ts index 1dd5be91..515c7f0e 100644 --- a/src/web/api/index.ts +++ b/src/web/api/index.ts @@ -71,21 +71,22 @@ app.use( // Fakes OpenAi routes app.post("/openai/*", async (c) => { const text = await c.req.json(); - const regex = /START EVALUATING:\s*\[([\s\S]*?)]/g; + const regex = /JSON response should equal exactly (\d+)/g; const comments: { id: string; comment: string; author: string }[] = []; if ("messages" in text) { let match; while ((match = regex.exec(text.messages[0].content)) !== null) { - const jsonArray = JSON.parse(`[${match[1]}]`); - jsonArray.forEach((item: { id: string; comment: string; author: string }) => { - comments.push({ - id: item.id, - comment: item.comment, - author: item.author, - }); - }); + const length = JSON.parse(`[${match[1]}]`); + + comments.push( + ...Array.from({ length }, (item, i) => ({ + id: i.toString(), + comment: "Generic comment", + author: "Generic author", + })) + ); } }