Skip to content

Commit

Permalink
Merge d3e225e into 39d60a5
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoshinonyaruko authored Jul 11, 2024
2 parents 39d60a5 + d3e225e commit 3d75c78
Showing 8 changed files with 87 additions and 68 deletions.
27 changes: 12 additions & 15 deletions applogic/chatglm.go
Original file line number Diff line number Diff line change
@@ -125,22 +125,14 @@ func (app *App) ChatHandlerGlm(w http.ResponseWriter, r *http.Request) {
}
}
} else {
// 默认执行 正常提示词顺序
if !config.GetEnhancedQA(promptstr) {
history, err = prompt.GetMessagesFromFilename(promptstr)
if err != nil {
fmtf.Printf("prompt.GetMessagesFromFilename error: %v\n", err)
}
// 只获取系统提示词
systemMessage, err := prompt.GetFirstSystemMessageStruct(promptstr)
if err != nil {
fmt.Println("Error:", err)
} else {
// 只获取系统提示词
systemMessage, err := prompt.GetFirstSystemMessageStruct(promptstr)
if err != nil {
fmt.Println("Error:", err)
} else {
// 如果找到system消息,将其添加到历史数组中
history = append(history, systemMessage)
fmt.Println("Added system message back to history.")
}
// 如果找到system消息,将其添加到历史数组中
history = append(history, systemMessage)
fmt.Println("Added system message back to history.")
}
}

@@ -203,6 +195,11 @@ func (app *App) ChatHandlerGlm(w http.ResponseWriter, r *http.Request) {

// 添加用户历史到总历史中
history = append(history, userHistory...)
} else {
history, err = prompt.GetMessagesExcludingSystem(promptstr)
if err != nil {
fmtf.Printf("prompt.GetMessagesExcludingSystem error: %v\n", err)
}
}

fmtf.Printf("Glm上下文history:%v\n", history)
14 changes: 12 additions & 2 deletions applogic/chatgpt.go
Original file line number Diff line number Diff line change
@@ -122,9 +122,14 @@ func (app *App) ChatHandlerChatgpt(w http.ResponseWriter, r *http.Request) {
}
}
} else {
history, err = prompt.GetMessagesFromFilename(promptstr)
// 只获取系统提示词
systemMessage, err := prompt.GetFirstSystemMessageStruct(promptstr)
if err != nil {
fmtf.Printf("prompt.GetMessagesFromFilename error: %v\n", err)
fmt.Println("Error:", err)
} else {
// 如果找到system消息,将其添加到历史数组中
history = append(history, systemMessage)
fmt.Println("Added system message back to history.")
}
}

@@ -182,6 +187,11 @@ func (app *App) ChatHandlerChatgpt(w http.ResponseWriter, r *http.Request) {

// 添加用户历史到总历史中
history = append(history, userHistory...)
} else {
history, err = prompt.GetMessagesExcludingSystem(promptstr)
if err != nil {
fmtf.Printf("prompt.GetMessagesExcludingSystem error: %v\n", err)
}
}

fmtf.Printf("CLOSE-AI上下文history:%v\n", history)
19 changes: 13 additions & 6 deletions applogic/ernie.go
Original file line number Diff line number Diff line change
@@ -102,12 +102,14 @@ func (app *App) ChatHandlerErnie(w http.ResponseWriter, r *http.Request) {
}
}
} else {
// 默认执行 正常提示词顺序
if !config.GetEnhancedQA(promptstr) {
history, err = prompt.GetMessagesExcludingSystem(promptstr)
if err != nil {
fmtf.Printf("prompt.GetMessagesExcludingSystem error: %v\n", err)
}
// 只获取系统提示词
systemMessage, err := prompt.GetFirstSystemMessageStruct(promptstr)
if err != nil {
fmt.Println("Error:", err)
} else {
// 如果找到system消息,将其添加到历史数组中
history = append(history, systemMessage)
fmt.Println("Added system message back to history.")
}
}

@@ -167,6 +169,11 @@ func (app *App) ChatHandlerErnie(w http.ResponseWriter, r *http.Request) {
}
// 添加用户历史到总历史中
history = append(history, userHistory...)
} else {
history, err = prompt.GetMessagesExcludingSystem(promptstr)
if err != nil {
fmtf.Printf("prompt.GetMessagesExcludingSystem error: %v\n", err)
}
}

fmtf.Printf("文心上下文history:%v\n", history)
27 changes: 12 additions & 15 deletions applogic/hunyuan.go
Original file line number Diff line number Diff line change
@@ -118,22 +118,14 @@ func (app *App) ChatHandlerHunyuan(w http.ResponseWriter, r *http.Request) {
}
}
} else {
// 默认执行 正常提示词顺序
if !config.GetEnhancedQA(promptstr) {
history, err = prompt.GetMessagesFromFilename(promptstr)
if err != nil {
fmtf.Printf("prompt.GetMessagesFromFilename error: %v\n", err)
}
// 只获取系统提示词
systemMessage, err := prompt.GetFirstSystemMessageStruct(promptstr)
if err != nil {
fmt.Println("Error:", err)
} else {
// 只获取系统提示词
systemMessage, err := prompt.GetFirstSystemMessageStruct(promptstr)
if err != nil {
fmt.Println("Error:", err)
} else {
// 如果找到system消息,将其添加到历史数组中
history = append(history, systemMessage)
fmt.Println("Added system message back to history.")
}
// 如果找到system消息,将其添加到历史数组中
history = append(history, systemMessage)
fmt.Println("Added system message back to history.")
}
}

@@ -198,6 +190,11 @@ func (app *App) ChatHandlerHunyuan(w http.ResponseWriter, r *http.Request) {

// 添加用户历史到总历史中
history = append(history, userHistory...)
} else {
history, err = prompt.GetMessagesExcludingSystem(promptstr)
if err != nil {
fmtf.Printf("prompt.GetMessagesExcludingSystem error: %v\n", err)
}
}

fmtf.Printf("混元上下文history:%v\n", history)
27 changes: 12 additions & 15 deletions applogic/rwkv.go
Original file line number Diff line number Diff line change
@@ -120,22 +120,14 @@ func (app *App) ChatHandlerRwkv(w http.ResponseWriter, r *http.Request) {
}
}
} else {
// 默认执行 正常提示词顺序
if !config.GetEnhancedQA(promptstr) {
history, err = prompt.GetMessagesFromFilename(promptstr)
if err != nil {
fmtf.Printf("prompt.GetMessagesFromFilename error: %v\n", err)
}
// 只获取系统提示词
systemMessage, err := prompt.GetFirstSystemMessageStruct(promptstr)
if err != nil {
fmt.Println("Error:", err)
} else {
// 只获取系统提示词
systemMessage, err := prompt.GetFirstSystemMessageStruct(promptstr)
if err != nil {
fmt.Println("Error:", err)
} else {
// 如果找到system消息,将其添加到历史数组中
history = append(history, systemMessage)
fmt.Println("Added system message back to history.")
}
// 如果找到system消息,将其添加到历史数组中
history = append(history, systemMessage)
fmt.Println("Added system message back to history.")
}
}

@@ -200,6 +192,11 @@ func (app *App) ChatHandlerRwkv(w http.ResponseWriter, r *http.Request) {

// 添加用户历史到总历史中
history = append(history, userHistory...)
} else {
history, err = prompt.GetMessagesExcludingSystem(promptstr)
if err != nil {
fmtf.Printf("prompt.GetMessagesExcludingSystem error: %v\n", err)
}
}

fmtf.Printf("RWKV上下文history:%v\n", history)
28 changes: 13 additions & 15 deletions applogic/tongyiqianwen.go
Original file line number Diff line number Diff line change
@@ -120,24 +120,17 @@ func (app *App) ChatHandlerTyqw(w http.ResponseWriter, r *http.Request) {
}
}
} else {
// 默认执行 正常提示词顺序
if !config.GetEnhancedQA(promptstr) {
history, err = prompt.GetMessagesFromFilename(promptstr)
if err != nil {
fmtf.Printf("prompt.GetMessagesFromFilename error: %v\n", err)
}
// 只获取系统提示词
systemMessage, err := prompt.GetFirstSystemMessageStruct(promptstr)
if err != nil {
fmt.Println("Error:", err)
} else {
// 只获取系统提示词
systemMessage, err := prompt.GetFirstSystemMessageStruct(promptstr)
if err != nil {
fmt.Println("Error:", err)
} else {
// 如果找到system消息,将其添加到历史数组中
history = append(history, systemMessage)
fmt.Println("Added system message back to history.")
}
// 如果找到system消息,将其添加到历史数组中
history = append(history, systemMessage)
fmt.Println("Added system message back to history.")
}
}

// TODO: msgid是空的开始第一句也要处理 插入
// 获取历史信息
if msg.ParentMessageID != "" {
@@ -198,6 +191,11 @@ func (app *App) ChatHandlerTyqw(w http.ResponseWriter, r *http.Request) {

// 添加用户历史到总历史中
history = append(history, userHistory...)
} else {
history, err = prompt.GetMessagesExcludingSystem(promptstr)
if err != nil {
fmtf.Printf("prompt.GetMessagesExcludingSystem error: %v\n", err)
}
}

fmtf.Printf("Tyqw上下文history:%v\n", history)
5 changes: 5 additions & 0 deletions applogic/yuanqi.go
Original file line number Diff line number Diff line change
@@ -187,6 +187,11 @@ func (app *App) ChatHandlerYuanQi(w http.ResponseWriter, r *http.Request) {

// 添加用户历史到总历史中
history = append(history, userHistory...)
} else {
history, err = prompt.GetMessagesExcludingSystem(promptstr)
if err != nil {
fmtf.Printf("prompt.GetMessagesExcludingSystem error: %v\n", err)
}
}

apiURL := config.GetYuanqiApiPath(promptstr)
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -47,16 +47,24 @@ _✨ 适用于Gensokyo以及Onebotv11的大模型一键端 ✨_

腾讯混元

腾讯元器

百度文心

阿里通义

清华智谱

字节火山(豆包)

OpenAI

groQ

Rwkv runner

One-API

将这些平台的api转换为统一的api结构,并提供了上下文,支持sse方式返回

通过在yml设置相应平台的token,设置AllApi=true,可以同时进行切换调用.

0 comments on commit 3d75c78

Please sign in to comment.