feat: enhance OpenAI request and response DTOs
- Add `Prefix` and `ReasoningContent` fields to Message struct - Add getter and setter methods for `Prefix` - Make `ToolCall.ID` field optional (fix #749)
This commit is contained in:
@@ -86,11 +86,13 @@ func (r GeneralOpenAIRequest) ParseInput() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
Role string `json:"role"`
|
Role string `json:"role"`
|
||||||
Content json.RawMessage `json:"content"`
|
Content json.RawMessage `json:"content"`
|
||||||
Name *string `json:"name,omitempty"`
|
Name *string `json:"name,omitempty"`
|
||||||
ToolCalls json.RawMessage `json:"tool_calls,omitempty"`
|
Prefix *bool `json:"prefix,omitempty"`
|
||||||
ToolCallId string `json:"tool_call_id,omitempty"`
|
ReasoningContent string `json:"reasoning_content,omitempty"`
|
||||||
|
ToolCalls json.RawMessage `json:"tool_calls,omitempty"`
|
||||||
|
ToolCallId string `json:"tool_call_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MediaContent struct {
|
type MediaContent struct {
|
||||||
@@ -116,6 +118,17 @@ const (
|
|||||||
ContentTypeInputAudio = "input_audio"
|
ContentTypeInputAudio = "input_audio"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (m *Message) GetPrefix() bool {
|
||||||
|
if m.Prefix == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return *m.Prefix
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Message) SetPrefix(prefix bool) {
|
||||||
|
m.Prefix = &prefix
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Message) ParseToolCalls() []ToolCall {
|
func (m *Message) ParseToolCalls() []ToolCall {
|
||||||
if m.ToolCalls == nil {
|
if m.ToolCalls == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ func (c *ChatCompletionsStreamResponseChoiceDelta) GetContentString() string {
|
|||||||
type ToolCall struct {
|
type ToolCall struct {
|
||||||
// Index is not nil only in chat completion chunk object
|
// Index is not nil only in chat completion chunk object
|
||||||
Index *int `json:"index,omitempty"`
|
Index *int `json:"index,omitempty"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id,omitempty"`
|
||||||
Type any `json:"type"`
|
Type any `json:"type"`
|
||||||
Function FunctionCall `json:"function"`
|
Function FunctionCall `json:"function"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user