mirror of
https://github.com/githubhjs/CLIProxyAPIPlus.git
synced 2026-07-12 01:25:13 +00:00
style(kiro): convert Chinese comments to English in base64 image handling
This commit is contained in:
@@ -185,20 +185,20 @@ func ConvertOpenAIRequestToKiro(modelName string, inputRawJSON []byte, stream bo
|
|||||||
} else if partType == "image_url" {
|
} else if partType == "image_url" {
|
||||||
imageURL := part.Get("image_url.url").String()
|
imageURL := part.Get("image_url.url").String()
|
||||||
|
|
||||||
// 检查是否是base64格式 (data:image/png;base64,xxxxx)
|
// Check if it's base64 format (data:image/png;base64,xxxxx)
|
||||||
if strings.HasPrefix(imageURL, "data:") {
|
if strings.HasPrefix(imageURL, "data:") {
|
||||||
// 解析 data URL 格式
|
// Parse data URL format
|
||||||
// 格式: data:image/png;base64,xxxxx
|
// Format: data:image/png;base64,xxxxx
|
||||||
commaIdx := strings.Index(imageURL, ",")
|
commaIdx := strings.Index(imageURL, ",")
|
||||||
if commaIdx != -1 {
|
if commaIdx != -1 {
|
||||||
// 提取 media_type (例如 "image/png")
|
// Extract media_type (e.g., "image/png")
|
||||||
header := imageURL[5:commaIdx] // 去掉 "data:" 前缀
|
header := imageURL[5:commaIdx] // Remove "data:" prefix
|
||||||
mediaType := header
|
mediaType := header
|
||||||
if semiIdx := strings.Index(header, ";"); semiIdx != -1 {
|
if semiIdx := strings.Index(header, ";"); semiIdx != -1 {
|
||||||
mediaType = header[:semiIdx]
|
mediaType = header[:semiIdx]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提取 base64 数据
|
// Extract base64 data
|
||||||
base64Data := imageURL[commaIdx+1:]
|
base64Data := imageURL[commaIdx+1:]
|
||||||
|
|
||||||
contentParts = append(contentParts, map[string]interface{}{
|
contentParts = append(contentParts, map[string]interface{}{
|
||||||
@@ -211,7 +211,7 @@ func ConvertOpenAIRequestToKiro(modelName string, inputRawJSON []byte, stream bo
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 普通URL格式 - 保持原有逻辑
|
// Regular URL format - keep original logic
|
||||||
contentParts = append(contentParts, map[string]interface{}{
|
contentParts = append(contentParts, map[string]interface{}{
|
||||||
"type": "image",
|
"type": "image",
|
||||||
"source": map[string]interface{}{
|
"source": map[string]interface{}{
|
||||||
@@ -247,20 +247,20 @@ func ConvertOpenAIRequestToKiro(modelName string, inputRawJSON []byte, stream bo
|
|||||||
} else if partType == "image_url" {
|
} else if partType == "image_url" {
|
||||||
imageURL := part.Get("image_url.url").String()
|
imageURL := part.Get("image_url.url").String()
|
||||||
|
|
||||||
// 检查是否是base64格式 (data:image/png;base64,xxxxx)
|
// Check if it's base64 format (data:image/png;base64,xxxxx)
|
||||||
if strings.HasPrefix(imageURL, "data:") {
|
if strings.HasPrefix(imageURL, "data:") {
|
||||||
// 解析 data URL 格式
|
// Parse data URL format
|
||||||
// 格式: data:image/png;base64,xxxxx
|
// Format: data:image/png;base64,xxxxx
|
||||||
commaIdx := strings.Index(imageURL, ",")
|
commaIdx := strings.Index(imageURL, ",")
|
||||||
if commaIdx != -1 {
|
if commaIdx != -1 {
|
||||||
// 提取 media_type (例如 "image/png")
|
// Extract media_type (e.g., "image/png")
|
||||||
header := imageURL[5:commaIdx] // 去掉 "data:" 前缀
|
header := imageURL[5:commaIdx] // Remove "data:" prefix
|
||||||
mediaType := header
|
mediaType := header
|
||||||
if semiIdx := strings.Index(header, ";"); semiIdx != -1 {
|
if semiIdx := strings.Index(header, ";"); semiIdx != -1 {
|
||||||
mediaType = header[:semiIdx]
|
mediaType = header[:semiIdx]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提取 base64 数据
|
// Extract base64 data
|
||||||
base64Data := imageURL[commaIdx+1:]
|
base64Data := imageURL[commaIdx+1:]
|
||||||
|
|
||||||
contentParts = append(contentParts, map[string]interface{}{
|
contentParts = append(contentParts, map[string]interface{}{
|
||||||
@@ -273,7 +273,7 @@ func ConvertOpenAIRequestToKiro(modelName string, inputRawJSON []byte, stream bo
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 普通URL格式 - 保持原有逻辑
|
// Regular URL format - keep original logic
|
||||||
contentParts = append(contentParts, map[string]interface{}{
|
contentParts = append(contentParts, map[string]interface{}{
|
||||||
"type": "image",
|
"type": "image",
|
||||||
"source": map[string]interface{}{
|
"source": map[string]interface{}{
|
||||||
|
|||||||
Reference in New Issue
Block a user