Spaces:
Paused
Paused
Update structs.go
Browse files- structs.go +16 -25
structs.go
CHANGED
|
@@ -14,7 +14,7 @@ type ClaudeRequest struct {
|
|
| 14 |
Stream bool `json:"stream,omitempty"`
|
| 15 |
Temperature *float64 `json:"temperature,omitempty"`
|
| 16 |
TopP *float64 `json:"top_p,omitempty"`
|
| 17 |
-
TopK *int `json:"top_k,omitempty"`
|
| 18 |
}
|
| 19 |
|
| 20 |
// ClaudeMessage represents a message in the Claude request
|
|
@@ -70,12 +70,9 @@ type OpenAIRequest struct {
|
|
| 70 |
MaxTokens *int `json:"max_tokens,omitempty"`
|
| 71 |
Temperature *float64 `json:"temperature,omitempty"`
|
| 72 |
TopP *float64 `json:"top_p,omitempty"`
|
| 73 |
-
TopK *int `json:"top_k,omitempty"`
|
| 74 |
Stop []string `json:"stop,omitempty"`
|
| 75 |
Stream bool `json:"stream,omitempty"`
|
| 76 |
-
// N *int `json:"n,omitempty"` // Not typically used with Claude proxy
|
| 77 |
-
// PresencePenalty *float64 `json:"presence_penalty,omitempty"` // Not mapped
|
| 78 |
-
// FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"` // Not mapped
|
| 79 |
}
|
| 80 |
|
| 81 |
// OpenAIMessage represents a message in the OpenAI request
|
|
@@ -91,16 +88,14 @@ type OpenAIResponse struct {
|
|
| 91 |
Created int64 `json:"created"`
|
| 92 |
Model string `json:"model"`
|
| 93 |
Choices []OpenAIChoice `json:"choices"`
|
| 94 |
-
Usage *OpenAIUsage `json:"usage,omitempty"`
|
| 95 |
-
// SystemFingerprint string `json:"system_fingerprint"` // Optional
|
| 96 |
}
|
| 97 |
|
| 98 |
// OpenAIChoice represents a choice in the OpenAI response
|
| 99 |
type OpenAIChoice struct {
|
| 100 |
Index int `json:"index"`
|
| 101 |
Message OpenAIMessage `json:"message"`
|
| 102 |
-
FinishReason *string `json:"finish_reason"`
|
| 103 |
-
// Logprobs interface{} `json:"logprobs"` // Not typically used here
|
| 104 |
}
|
| 105 |
|
| 106 |
// OpenAIUsage represents the token usage information from OpenAI
|
|
@@ -114,14 +109,13 @@ type OpenAIUsage struct {
|
|
| 114 |
type OpenAIStreamChoice struct {
|
| 115 |
Index int `json:"index"`
|
| 116 |
Delta OpenAIStreamDelta `json:"delta"`
|
| 117 |
-
FinishReason *string `json:"finish_reason"`
|
| 118 |
-
// Logprobs interface{} `json:"logprobs"` // Not typically used here
|
| 119 |
}
|
| 120 |
|
| 121 |
// OpenAIStreamDelta represents the delta content within an OpenAI SSE chunk
|
| 122 |
type OpenAIStreamDelta struct {
|
| 123 |
-
Role *string `json:"role,omitempty"`
|
| 124 |
-
Content *string `json:"content,omitempty"`
|
| 125 |
}
|
| 126 |
|
| 127 |
// OpenAIStreamChunk represents the structure of a data chunk in the OpenAI SSE stream
|
|
@@ -131,8 +125,7 @@ type OpenAIStreamChunk struct {
|
|
| 131 |
Created int64 `json:"created"`
|
| 132 |
Model string `json:"model"`
|
| 133 |
Choices []OpenAIStreamChoice `json:"choices"`
|
| 134 |
-
Usage *OpenAIUsage `json:"usage,omitempty"`
|
| 135 |
-
// SystemFingerprint string `json:"system_fingerprint"` // Optional
|
| 136 |
}
|
| 137 |
|
| 138 |
|
|
@@ -141,12 +134,12 @@ type OpenAIStreamChunk struct {
|
|
| 141 |
// ClaudeSSEEvent represents a generic Claude SSE event structure for easy marshaling
|
| 142 |
type ClaudeSSEEvent struct {
|
| 143 |
Type string `json:"type"`
|
| 144 |
-
Index *int `json:"index,omitempty"`
|
| 145 |
-
Message *ClaudeSSEMessage `json:"message,omitempty"`
|
| 146 |
-
ContentBlock *ClaudeSSEContentBlock `json:"content_block,omitempty"`
|
| 147 |
-
Delta *ClaudeSSEDelta `json:"delta,omitempty"`
|
| 148 |
-
Usage *ClaudeSSEUsage `json:"usage,omitempty"`
|
| 149 |
-
Error *ClaudeError `json:"error,omitempty"`
|
| 150 |
}
|
| 151 |
|
| 152 |
// ClaudeSSEMessage is nested within message_start
|
|
@@ -177,8 +170,6 @@ type ClaudeSSEDelta struct {
|
|
| 177 |
|
| 178 |
// ClaudeSSEUsage is nested within message_delta (HACK) and message_stop
|
| 179 |
type ClaudeSSEUsage struct {
|
| 180 |
-
// Note: message_delta only needs output_tokens for the hack
|
| 181 |
-
// message_stop should have both
|
| 182 |
InputTokens *int `json:"input_tokens,omitempty"` // Only in message_stop
|
| 183 |
-
OutputTokens int `json:"output_tokens"`
|
| 184 |
-
}
|
|
|
|
| 14 |
Stream bool `json:"stream,omitempty"`
|
| 15 |
Temperature *float64 `json:"temperature,omitempty"`
|
| 16 |
TopP *float64 `json:"top_p,omitempty"`
|
| 17 |
+
TopK *int `json:"top_k,omitempty"`
|
| 18 |
}
|
| 19 |
|
| 20 |
// ClaudeMessage represents a message in the Claude request
|
|
|
|
| 70 |
MaxTokens *int `json:"max_tokens,omitempty"`
|
| 71 |
Temperature *float64 `json:"temperature,omitempty"`
|
| 72 |
TopP *float64 `json:"top_p,omitempty"`
|
| 73 |
+
TopK *int `json:"top_k,omitempty"`
|
| 74 |
Stop []string `json:"stop,omitempty"`
|
| 75 |
Stream bool `json:"stream,omitempty"`
|
|
|
|
|
|
|
|
|
|
| 76 |
}
|
| 77 |
|
| 78 |
// OpenAIMessage represents a message in the OpenAI request
|
|
|
|
| 88 |
Created int64 `json:"created"`
|
| 89 |
Model string `json:"model"`
|
| 90 |
Choices []OpenAIChoice `json:"choices"`
|
| 91 |
+
Usage *OpenAIUsage `json:"usage,omitempty"`
|
|
|
|
| 92 |
}
|
| 93 |
|
| 94 |
// OpenAIChoice represents a choice in the OpenAI response
|
| 95 |
type OpenAIChoice struct {
|
| 96 |
Index int `json:"index"`
|
| 97 |
Message OpenAIMessage `json:"message"`
|
| 98 |
+
FinishReason *string `json:"finish_reason"`
|
|
|
|
| 99 |
}
|
| 100 |
|
| 101 |
// OpenAIUsage represents the token usage information from OpenAI
|
|
|
|
| 109 |
type OpenAIStreamChoice struct {
|
| 110 |
Index int `json:"index"`
|
| 111 |
Delta OpenAIStreamDelta `json:"delta"`
|
| 112 |
+
FinishReason *string `json:"finish_reason"`
|
|
|
|
| 113 |
}
|
| 114 |
|
| 115 |
// OpenAIStreamDelta represents the delta content within an OpenAI SSE chunk
|
| 116 |
type OpenAIStreamDelta struct {
|
| 117 |
+
Role *string `json:"role,omitempty"`
|
| 118 |
+
Content *string `json:"content,omitempty"`
|
| 119 |
}
|
| 120 |
|
| 121 |
// OpenAIStreamChunk represents the structure of a data chunk in the OpenAI SSE stream
|
|
|
|
| 125 |
Created int64 `json:"created"`
|
| 126 |
Model string `json:"model"`
|
| 127 |
Choices []OpenAIStreamChoice `json:"choices"`
|
| 128 |
+
Usage *OpenAIUsage `json:"usage,omitempty"`
|
|
|
|
| 129 |
}
|
| 130 |
|
| 131 |
|
|
|
|
| 134 |
// ClaudeSSEEvent represents a generic Claude SSE event structure for easy marshaling
|
| 135 |
type ClaudeSSEEvent struct {
|
| 136 |
Type string `json:"type"`
|
| 137 |
+
Index *int `json:"index,omitempty"`
|
| 138 |
+
Message *ClaudeSSEMessage `json:"message,omitempty"`
|
| 139 |
+
ContentBlock *ClaudeSSEContentBlock `json:"content_block,omitempty"`
|
| 140 |
+
Delta *ClaudeSSEDelta `json:"delta,omitempty"`
|
| 141 |
+
Usage *ClaudeSSEUsage `json:"usage,omitempty"`
|
| 142 |
+
Error *ClaudeError `json:"error,omitempty"`
|
| 143 |
}
|
| 144 |
|
| 145 |
// ClaudeSSEMessage is nested within message_start
|
|
|
|
| 170 |
|
| 171 |
// ClaudeSSEUsage is nested within message_delta (HACK) and message_stop
|
| 172 |
type ClaudeSSEUsage struct {
|
|
|
|
|
|
|
| 173 |
InputTokens *int `json:"input_tokens,omitempty"` // Only in message_stop
|
| 174 |
+
OutputTokens int `json:"output_tokens"`
|
| 175 |
+
}
|