mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-12-26 17:55:58 +08:00
feat: Refactor vision message handling and increase commit short SHA length
- Increase the length of the commit short SHA from 8 to 7 characters - Update relay-aiproxy.go to handle multiple content types in the last message - Refactor and modify countVisonTokenMessages function in relay-utils.go to handle different content types and update token counts accordingly - Update VisionMessage struct in relay.go to have Content as a slice of OpenaiVisionMessageContent
This commit is contained in:
@@ -54,7 +54,15 @@ func requestOpenAI2AIProxyLibrary(request GeneralOpenAIRequest) *AIProxyLibraryR
|
||||
if msgs, err := request.TextMessages(); err == nil {
|
||||
query = msgs[len(msgs)-1].Content
|
||||
} else if msgs, err := request.VisionMessages(); err == nil {
|
||||
query = msgs[len(msgs)-1].Content.Text
|
||||
lastMsg := msgs[len(msgs)-1]
|
||||
if len(lastMsg.Content) != 0 {
|
||||
for i := range lastMsg.Content {
|
||||
if lastMsg.Content[i].Type == OpenaiVisionMessageContentTypeText {
|
||||
query = lastMsg.Content[i].Text
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Panicf("unknown message type: %T", msgs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user