Skip to content

Commit

Permalink
fix: header id
Browse files Browse the repository at this point in the history
  • Loading branch information
Angular2Guy committed Nov 15, 2023
1 parent 9c370ef commit 94c44f6
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ record TikaDocumentAndContent(org.springframework.ai.document.Document document,
.map(myStr -> new TikaDocumentAndContent(myDocument1, myStr)))
.map(myTikaRecord -> new org.springframework.ai.document.Document(myTikaRecord.content(),
myTikaRecord.document().getMetadata()))
.peek(myDocument1 -> myDocument1.getMetadata().put(ID, myDocument.getId())).toList();
.peek(myDocument1 -> myDocument1.getMetadata().put(ID, myDocument.getId().toString())).toList();

LOGGER.info("Name: {}, size: {}, chunks: {}", document.getDocumentName(), document.getDocumentContent().length,
aiDocuments.size());
Expand Down Expand Up @@ -102,7 +102,8 @@ public AiResult queryDocuments(String query) {
ZonedDateTime.of(LocalDateTime.now(), ZoneId.systemDefault()).toInstant().toEpochMilli()
- ZonedDateTime.of(start, ZoneId.systemDefault()).toInstant().toEpochMilli());
var documents = mostSimilar.stream().map(myGen -> myGen.getMetadata().get(ID))
.map(myId -> (myId instanceof Integer ? Integer.valueOf((Integer) myId).longValue() : (Long) myId))
.filter(myId -> Optional.ofNullable(myId).stream().allMatch(myId1 -> (myId1 instanceof String)))
.map(myId -> Long.parseLong(((String) myId)))
.map(myId -> this.documentRepository.findById(myId)).filter(Optional::isPresent).map(Optional::get)
.toList();
return new AiResult(query, response.getGenerations(), documents);
Expand Down

0 comments on commit 94c44f6

Please sign in to comment.