Skip to content

Commit

Permalink
Iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
serefyarar committed Jun 25, 2024
1 parent abffd09 commit b953903
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion indexer/src/app/modules/agent.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class Agent {
return question.replace(/^\d+\.\s/g, '');
})
.filter((question: string) => {
return question.length > 5;
return question && question.length > 5;
});
},
},
Expand Down
8 changes: 6 additions & 2 deletions indexer/src/chat/service/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,14 @@ export class ChatService {
if (response.ids.length === 0)
throw new HttpException('No documents have found', HttpStatus.NOT_FOUND);

const questions = await chain.invoke({
const resp = await chain.invoke({
documents: response.documents,
});

return questions;
if (resp.questions && resp.questions.length > 4) {
resp.questions = resp.questions.slice(0, 4);
}

return resp;
}
}

0 comments on commit b953903

Please sign in to comment.