Skip to content

Commit

Permalink
fix(client): continue conversation without creating a new one
Browse files Browse the repository at this point in the history
  • Loading branch information
astappiev committed Oct 3, 2023
1 parent 7cc4cfe commit 51900d0
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ public Conversation chatById(String uuid) throws InterwebException {

public void chatComplete(Conversation conversation) throws InterwebException {
CompletionResults results = sendPostRequest("/chat/completions", conversation, CompletionResults.class);
if (results.getLastMessage() != null) {
conversation.addMessage(results.getLastMessage());
if (conversation.getId() == null) {
conversation.setId(results.getChatId());
}
if (results.getChatTitle() != null) {
if (conversation.getTitle() == null && results.getChatTitle() != null) {
conversation.setTitle(results.getChatTitle());
}
if (results.getCost() != null) {
Expand All @@ -98,6 +98,9 @@ public void chatComplete(Conversation conversation) throws InterwebException {
if (results.getUsage() != null) {
conversation.setUsedTokens(results.getUsage().getTotalTokens());
}
if (results.getLastMessage() != null) {
conversation.addMessage(results.getLastMessage());
}
}

private URI createRequestUri(final String apiPath, final Map<String, String> params) {
Expand Down

0 comments on commit 51900d0

Please sign in to comment.