first commit: one-api base code + SAAS plan document
This commit is contained in:
16
relay/relaymode/define.go
Normal file
16
relay/relaymode/define.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package relaymode
|
||||
|
||||
const (
|
||||
Unknown = iota
|
||||
ChatCompletions
|
||||
Completions
|
||||
Embeddings
|
||||
Moderations
|
||||
ImagesGenerations
|
||||
Edits
|
||||
AudioSpeech
|
||||
AudioTranscription
|
||||
AudioTranslation
|
||||
// Proxy is a special relay mode for proxying requests to custom upstream
|
||||
Proxy
|
||||
)
|
||||
31
relay/relaymode/helper.go
Normal file
31
relay/relaymode/helper.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package relaymode
|
||||
|
||||
import "strings"
|
||||
|
||||
func GetByPath(path string) int {
|
||||
relayMode := Unknown
|
||||
if strings.HasPrefix(path, "/v1/chat/completions") {
|
||||
relayMode = ChatCompletions
|
||||
} else if strings.HasPrefix(path, "/v1/completions") {
|
||||
relayMode = Completions
|
||||
} else if strings.HasPrefix(path, "/v1/embeddings") {
|
||||
relayMode = Embeddings
|
||||
} else if strings.HasSuffix(path, "embeddings") {
|
||||
relayMode = Embeddings
|
||||
} else if strings.HasPrefix(path, "/v1/moderations") {
|
||||
relayMode = Moderations
|
||||
} else if strings.HasPrefix(path, "/v1/images/generations") {
|
||||
relayMode = ImagesGenerations
|
||||
} else if strings.HasPrefix(path, "/v1/edits") {
|
||||
relayMode = Edits
|
||||
} else if strings.HasPrefix(path, "/v1/audio/speech") {
|
||||
relayMode = AudioSpeech
|
||||
} else if strings.HasPrefix(path, "/v1/audio/transcriptions") {
|
||||
relayMode = AudioTranscription
|
||||
} else if strings.HasPrefix(path, "/v1/audio/translations") {
|
||||
relayMode = AudioTranslation
|
||||
} else if strings.HasPrefix(path, "/v1/oneapi/proxy") {
|
||||
relayMode = Proxy
|
||||
}
|
||||
return relayMode
|
||||
}
|
||||
Reference in New Issue
Block a user