Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.github.sashirestela.openai.domain.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.github.sashirestela.slimvalidator.constraints.ObjectType;
import io.github.sashirestela.slimvalidator.constraints.ObjectType.Schema;
import io.github.sashirestela.slimvalidator.constraints.Required;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

@AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor
@Getter
@ToString
@JsonInclude(Include.NON_EMPTY)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class Prompt {

@Required
private String id;

@ObjectType(schema = Schema.MAP, keyClass = String.class, baseClass = { String.class, Input.Content.class })
private Object variable;

private String version;

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,25 @@ public class Response {
private ResponseError error;
private String id;
private IncompleteDetails incompleteDetails;
private String instructions;
private Object instructions;
private Long maxOutputTokens;
private Long maxToolCalls;
private Map<String, String> metadata;
private String model;
private String object;
@JsonDeserialize(contentUsing = ItemDeserializer.class)
private List<Input.Item> output;
private Boolean parallelToolCalls;
private String previousResponseId;
private Prompt prompt;
private Reasoning reasoning;
private ServiceTier serviceTier;
private ResponseStatus status;
private Double temperature;
private ResponseText text;
private Object toolChoice;
private List<ResponseTool> tools;
private Integer topLogprobs;
private Double topP;
private Truncation truncation;
private ResponseUsage usage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.github.sashirestela.slimvalidator.constraints.ObjectType;
import io.github.sashirestela.slimvalidator.constraints.ObjectType.Schema;
import io.github.sashirestela.slimvalidator.constraints.Range;
import io.github.sashirestela.slimvalidator.constraints.Required;
import io.github.sashirestela.slimvalidator.constraints.RequiredIfNull;
import io.github.sashirestela.slimvalidator.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -26,14 +26,13 @@
@AllArgsConstructor
@JsonInclude(Include.NON_EMPTY)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
@RequiredIfNull(fields = { "input", "model" }, dependsOn = "prompt")
public class ResponseRequest {

@Required
@ObjectType(baseClass = String.class)
@ObjectType(schema = Schema.COLL, baseClass = Input.class)
private Object input;

@Required
private String model;

private Boolean background;
Expand All @@ -51,6 +50,8 @@ public class ResponseRequest {

private String previousResponseId;

private Prompt prompt;

private Reasoning reasoning;

private ServiceTier serviceTier;
Expand All @@ -66,12 +67,15 @@ public class ResponseRequest {
private ResponseText text;

@ObjectType(baseClass = { ToolChoiceOption.class, ResponseToolChoice.HostedTool.class,
ResponseToolChoice.FunctionTool.class })
ResponseToolChoice.FunctionTool.class, ResponseToolChoice.MCPTool.class })
private Object toolChoice;

@Singular
private List<ResponseTool> tools;

@Range(min = 0, max = 20)
private Integer topLogprobs;

@Range(min = 0.0, max = 1.0)
private Double topP;

Expand All @@ -81,20 +85,23 @@ public class ResponseRequest {

public enum ResponseInclude {

@JsonProperty("code_interpreter_call.outputs")
CODE_INTERPRETER_CALL_OUTPUTS,

@JsonProperty("computer_call_output.output.image_url")
COMPUTER_CALL_OUTPUT_IMAGE_URL,

@JsonProperty("file_search_call.results")
FILE_SEARCH_CALL_RESULTS,

@JsonProperty("message.input_image.image_url")
MESSAGE_INPUT_IMAGE_URL,

@JsonProperty("computer_call_output.output.image_url")
COMPUTER_CALL_OUTPUT_IMAGE_URL,
@JsonProperty("message.output_text.logprobs")
MESSAGE_OUTPUT_TEXT_LOGPROBS,

@JsonProperty("reasoning.encrypted_content")
REASONING_ENCRYPTED_CONTENT,

@JsonProperty("code_interpreter_call.outputs")
CODE_INTERPRETER_CALL_OUTPUTS;
REASONING_ENCRYPTED_CONTENT;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,17 @@ public static class McpResponseTool extends ResponseTool {
@JsonDeserialize(using = RequireApprovalDeserializer.class)
private Object requireApproval;

private String serverDescription;

@Builder
public McpResponseTool(String serverLabel, String serverUrl, Object allowedTools, Map<String, String> headers,
Object requireApproval) {
Object requireApproval, String serverDescription) {
this.serverLabel = serverLabel;
this.serverUrl = serverUrl;
this.allowedTools = allowedTools;
this.headers = headers;
this.requireApproval = requireApproval;
this.serverDescription = serverDescription;
this.type = ResponseToolType.MCP;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,30 @@ public static FunctionTool of(String name) {

}

@AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor
@Getter
@ToString
@JsonInclude(Include.NON_EMPTY)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
class MCPTool {

@Required
private String serverLabel;

private String name;

@Required
private HostedToolType type;

public static MCPTool of(String serverLabel) {
return new MCPTool(serverLabel, null, HostedToolType.MCP);
}

public static MCPTool of(String serverLabel, String name) {
return new MCPTool(serverLabel, name, HostedToolType.MCP);
}

}

}