Skip to content

Commit

Permalink
add editing functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Yerish26 committed May 9, 2024
1 parent 7ec1b79 commit 2740809
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,22 @@ public ResponseEntity<Conversation> createConversation() {
public ResponseEntity<ConversationResponse> continueConversation(
@PathVariable UUID id, @RequestBody ConversationRequest conversationRequest)
throws ConversationNotFoundException {
// TODO check if the id exists, else throw exception,
// conversation can built with builder and passed
// as a parameter for the update method
Conversation conversation = conversationService.update(id, conversationRequest);

return ResponseEntity.status(HttpStatus.OK).body(conversationControllerMapper.map(conversation));
}

@PutMapping("/{id}/edit")
public ResponseEntity<ConversationResponse> editConversation(@PathVariable UUID id)
throws ConversationNotFoundException {
Conversation conversation = conversationService.edit(id);

return ResponseEntity.status(HttpStatus.OK).body(conversationControllerMapper.map(conversation));
}

@ExceptionHandler(ConversationNotFoundException.class)
public ResponseEntity<String> handleConversationNotFoundException(
ConversationNotFoundException conversationNotFoundException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public Conversation update(UUID id, ConversationRequest conversationRequest) thr
return Conversation.builder().id(id).build();
}

public Conversation edit(UUID id) {
return Conversation.builder().build();
}

private String getPrediction(UUID id, String text) {
return llmService.generate(text).toString();
}
Expand Down

0 comments on commit 2740809

Please sign in to comment.