feat: support channel ai.ls now (close #99)
This commit is contained in:
parent
7c6bf3e97b
commit
3711f4a741
@ -51,9 +51,10 @@ _✨ All in one 的 OpenAI 接口,整合各种 API 访问方式,开箱即用
|
||||
+ [x] **Azure OpenAI API**
|
||||
+ [x] [API2D](https://api2d.com/r/197971)
|
||||
+ [x] [OhMyGPT](https://aigptx.top?aff=uFpUl2Kf)
|
||||
+ [x] [CloseAI](https://console.openai-asia.com)
|
||||
+ [x] [OpenAI-SB](https://openai-sb.com)
|
||||
+ [x] [AI.LS](https://ai.ls)
|
||||
+ [x] [OpenAI Max](https://openaimax.com)
|
||||
+ [x] [OpenAI-SB](https://openai-sb.com)
|
||||
+ [x] [CloseAI](https://console.openai-asia.com)
|
||||
+ [x] 自定义渠道:例如使用自行搭建的 OpenAI 代理
|
||||
2. 支持通过**负载均衡**的方式访问多个渠道。
|
||||
3. 支持 **stream 模式**,可以通过流式传输实现打字机效果。
|
||||
|
@ -127,6 +127,7 @@ const (
|
||||
ChannelTypeOpenAIMax = 6
|
||||
ChannelTypeOhMyGPT = 7
|
||||
ChannelTypeCustom = 8
|
||||
ChannelTypeAILS = 9
|
||||
)
|
||||
|
||||
var ChannelBaseURLs = []string{
|
||||
@ -139,4 +140,5 @@ var ChannelBaseURLs = []string{
|
||||
"https://api.openaimax.com", // 6
|
||||
"https://api.ohmygpt.com", // 7
|
||||
"", // 8
|
||||
"https://api.caipacity.com", // 9
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ func countTokenMessages(messages []Message, model string) int {
|
||||
tokenNum += tokensPerMessage
|
||||
tokenNum += len(tokenEncoder.Encode(message.Content, nil, nil))
|
||||
tokenNum += len(tokenEncoder.Encode(message.Role, nil, nil))
|
||||
if message.Name != "" {
|
||||
if message.Name != nil {
|
||||
tokenNum += tokensPerName
|
||||
tokenNum += len(tokenEncoder.Encode(message.Name, nil, nil))
|
||||
tokenNum += len(tokenEncoder.Encode(*message.Name, nil, nil))
|
||||
}
|
||||
}
|
||||
tokenNum += 3 // Every reply is primed with <|start|>assistant<|message|>
|
||||
|
@ -14,9 +14,9 @@ import (
|
||||
)
|
||||
|
||||
type Message struct {
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
Name string `json:"name"`
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type ChatRequest struct {
|
||||
@ -232,6 +232,10 @@ func relayHelper(c *gin.Context) *OpenAIErrorWithStatusCode {
|
||||
go func() {
|
||||
for scanner.Scan() {
|
||||
data := scanner.Text()
|
||||
if len(data) < 6 { // must be something wrong!
|
||||
common.SysError("Invalid stream response: " + data)
|
||||
continue
|
||||
}
|
||||
dataChan <- data
|
||||
data = data[6:]
|
||||
if !strings.HasPrefix(data, "[DONE]") {
|
||||
|
@ -6,5 +6,6 @@ export const CHANNEL_OPTIONS = [
|
||||
{ key: 5, text: 'OpenAI-SB', value: 5, color: 'brown' },
|
||||
{ key: 6, text: 'OpenAI Max', value: 6, color: 'violet' },
|
||||
{ key: 7, text: 'OhMyGPT', value: 7, color: 'purple' },
|
||||
{ key: 9, text: 'AI.LS', value: 9, color: 'yellow' },
|
||||
{ key: 8, text: '自定义', value: 8, color: 'pink' }
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user