Skip to content

Commit

Permalink
Complete the JavaDoc for API entities
Browse files Browse the repository at this point in the history
  • Loading branch information
penguineer committed Oct 31, 2024
1 parent b959cfd commit 32605d0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
16 changes: 16 additions & 0 deletions src/main/java/com/penguineering/hareairis/model/ChatError.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,33 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* Represents a chat error.
*
* <p>Represents a chat error that can be sent back to the chat client.</p>
*/
@AllArgsConstructor
@NoArgsConstructor
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
public class ChatError {
/**
* The error code, matching an HTTP status code.
*/
@JsonProperty("code")
private int code;

/**
* The error message.
*/
@JsonProperty("message")
private String message;

/**
* Creates a new chat error from a chat exception.
*
* @param ex The chat exception.
*/
public ChatError(ChatException ex) {
this.code = ex.getCode();
this.message = ex.getMessage();
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/com/penguineering/hareairis/model/ChatRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,25 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Optional;

/**
* Represents a chat request.
*
* <p>Represents a chat request that can be sent to the AI service.</p>
*/
@NoArgsConstructor
@AllArgsConstructor
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
public class ChatRequest {
/**
* The system message of the chat client.
*/
@JsonProperty("system-message")
private String systemMessage = "";

/**
* The actual prompt.
*/
@JsonProperty("prompt")
private String prompt = "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,32 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

/**
* Represents a chat response.
*
* <p>Represents a chat response that can be sent back to the chat client.</p>
*/
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Builder(toBuilder = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ChatResponse {
/**
* The response from the AI service.
*/
@JsonProperty("response")
private String response;

/**
* The number of input tokens.
*/
@JsonProperty("input-tokens")
private int inputTokens;

/**
* The number of output tokens.
*/
@JsonProperty("output-tokens")
private int outputTokens;
}
}

0 comments on commit 32605d0

Please sign in to comment.