mirror of
https://github.com/alibaba/higress.git
synced 2026-06-08 12:17:28 +08:00
fix(ai-proxy): resolve Claude streaming response conversion and SSE event chunking issues (#2882)
This commit is contained in:
@@ -159,10 +159,17 @@ type usage struct {
|
||||
CompletionTokens int `json:"completion_tokens,omitempty"`
|
||||
TotalTokens int `json:"total_tokens,omitempty"`
|
||||
CompletionTokensDetails *completionTokensDetails `json:"completion_tokens_details,omitempty"`
|
||||
PromptTokensDetails *promptTokensDetails `json:"prompt_tokens_details,omitempty"`
|
||||
}
|
||||
|
||||
type promptTokensDetails struct {
|
||||
AudioTokens int `json:"audio_tokens,omitempty"`
|
||||
CachedTokens int `json:"cached_tokens,omitempty"`
|
||||
}
|
||||
|
||||
type completionTokensDetails struct {
|
||||
ReasoningTokens int `json:"reasoning_tokens,omitempty"`
|
||||
AudioTokens int `json:"audio_tokens,omitempty"`
|
||||
AcceptedPredictionTokens int `json:"accepted_prediction_tokens,omitempty"`
|
||||
RejectedPredictionTokens int `json:"rejected_prediction_tokens,omitempty"`
|
||||
}
|
||||
@@ -240,11 +247,12 @@ func (m *chatMessage) handleStreamingReasoningContent(ctx wrapper.HttpContext, r
|
||||
}
|
||||
|
||||
type chatMessageContent struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Text string `json:"text"`
|
||||
ImageUrl *chatMessageContentImageUrl `json:"image_url,omitempty"`
|
||||
File *chatMessageContentFile `json:"file,omitempty"`
|
||||
InputAudio *chatMessageContentAudio `json:"input_audio,omitempty"`
|
||||
CacheControl map[string]interface{} `json:"cache_control,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Text string `json:"text"`
|
||||
ImageUrl *chatMessageContentImageUrl `json:"image_url,omitempty"`
|
||||
File *chatMessageContentFile `json:"file,omitempty"`
|
||||
InputAudio *chatMessageContentAudio `json:"input_audio,omitempty"`
|
||||
}
|
||||
|
||||
type chatMessageContentAudio struct {
|
||||
@@ -402,6 +410,7 @@ func (m *functionCall) IsEmpty() bool {
|
||||
}
|
||||
|
||||
type StreamEvent struct {
|
||||
RawEvent string `json:"-"`
|
||||
Id string `json:"id"`
|
||||
Event string `json:"event"`
|
||||
Data string `json:"data"`
|
||||
|
||||
Reference in New Issue
Block a user