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:
Laisky.Cai
2023-11-17 05:26:26 +00:00
parent 0cafbf0fc9
commit 14108ce24d
4 changed files with 27 additions and 17 deletions

View File

@@ -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)
}