File size: 7,914 Bytes
1766992 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | // Copyright (c) 2025-2026 libaxuan
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package models
import "encoding/json"
// ResponseRequest OpenAI Responses API request
type ResponseRequest struct {
Model string `json:"model" binding:"required"`
Input json.RawMessage `json:"input,omitempty"`
Instructions json.RawMessage `json:"instructions,omitempty"`
Stream bool `json:"stream,omitempty"`
Tools []map[string]interface{} `json:"tools,omitempty"`
ToolChoice json.RawMessage `json:"tool_choice,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
MaxOutputTokens *int `json:"max_output_tokens,omitempty"`
User *string `json:"user,omitempty"`
PreviousResponseID *string `json:"previous_response_id,omitempty"`
Store *bool `json:"store,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
ParallelToolCalls *bool `json:"parallel_tool_calls,omitempty"`
Text json.RawMessage `json:"text,omitempty"`
Reasoning json.RawMessage `json:"reasoning,omitempty"`
MaxToolCalls *int `json:"max_tool_calls,omitempty"`
Background *bool `json:"background,omitempty"`
Conversation json.RawMessage `json:"conversation,omitempty"`
Truncation string `json:"truncation,omitempty"`
}
// Response OpenAI Responses API response
type Response struct {
ID string `json:"id"`
Object string `json:"object"`
CreatedAt int64 `json:"created_at"`
Status string `json:"status"`
CompletedAt *int64 `json:"completed_at,omitempty"`
Background *bool `json:"background,omitempty"`
Error *ResponseError `json:"error,omitempty"`
IncompleteDetails *ResponseIncompleteInfo `json:"incomplete_details,omitempty"`
Instructions interface{} `json:"instructions,omitempty"`
MaxOutputTokens *int `json:"max_output_tokens,omitempty"`
MaxToolCalls *int `json:"max_tool_calls,omitempty"`
Model string `json:"model"`
Output []interface{} `json:"output"`
OutputText string `json:"output_text,omitempty"`
ParallelToolCalls bool `json:"parallel_tool_calls,omitempty"`
PreviousResponseID *string `json:"previous_response_id,omitempty"`
Reasoning *ResponseReasoning `json:"reasoning,omitempty"`
Store *bool `json:"store,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
Text interface{} `json:"text,omitempty"`
ToolChoice interface{} `json:"tool_choice,omitempty"`
Tools []map[string]interface{} `json:"tools,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
Truncation string `json:"truncation,omitempty"`
Usage *ResponseUsage `json:"usage,omitempty"`
User *string `json:"user,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
// ResponseError mirrors the Responses API error object
type ResponseError struct {
Message string `json:"message"`
Type string `json:"type,omitempty"`
Code string `json:"code,omitempty"`
}
// ResponseIncompleteInfo mirrors the incomplete_details object
type ResponseIncompleteInfo struct {
Reason string `json:"reason,omitempty"`
}
// ResponseReasoning mirrors the reasoning config on responses
type ResponseReasoning struct {
Effort *string `json:"effort,omitempty"`
Summary interface{} `json:"summary,omitempty"`
}
// ResponseUsage mirrors the usage object on responses
type ResponseUsage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
TotalTokens int `json:"total_tokens"`
OutputTokensDetails *ResponseOutputTokensDetails `json:"output_tokens_details,omitempty"`
}
// ResponseOutputTokensDetails mirrors output_tokens_details
type ResponseOutputTokensDetails struct {
ReasoningTokens int `json:"reasoning_tokens,omitempty"`
}
// ResponseOutputTextContent is an output_text content part
type ResponseOutputTextContent struct {
Type string `json:"type"`
Text string `json:"text"`
Annotations []interface{} `json:"annotations,omitempty"`
Logprobs []interface{} `json:"logprobs,omitempty"`
}
// ResponseOutputMessage is a message output item
type ResponseOutputMessage struct {
ID string `json:"id"`
Type string `json:"type"`
Status string `json:"status,omitempty"`
Role string `json:"role"`
Content []ResponseOutputTextContent `json:"content"`
}
// ResponseFunctionCall is a function_call output item
type ResponseFunctionCall struct {
ID string `json:"id"`
Type string `json:"type"`
Status string `json:"status,omitempty"`
CallID string `json:"call_id"`
Name string `json:"name"`
Arguments string `json:"arguments"`
}
// ResponseApplyPatchCall is an apply_patch_call output item
type ResponseApplyPatchCall struct {
ID string `json:"id"`
Type string `json:"type"`
Status string `json:"status,omitempty"`
CallID string `json:"call_id"`
Operation map[string]interface{} `json:"operation"`
}
// ResponseShellCall is a shell_call output item
type ResponseShellCall struct {
ID string `json:"id"`
Type string `json:"type"`
Status string `json:"status,omitempty"`
CallID string `json:"call_id"`
Action map[string]interface{} `json:"action"`
Environment interface{} `json:"environment,omitempty"`
}
// ResponseLocalShellCall is a local_shell_call output item
type ResponseLocalShellCall struct {
ID string `json:"id"`
Type string `json:"type"`
Status string `json:"status,omitempty"`
CallID string `json:"call_id"`
Action map[string]interface{} `json:"action"`
}
|