Skip to content

Commit

Permalink
Beta160 (#160)
Browse files Browse the repository at this point in the history
* beta1

* beta2

* beta3

* beta4

* beta5

* beta6

* beta7

* beta8

* beta9

* beta10

* beta11

* beta12

* beta13

* beta14

* beta15

* beta16

* beta16

* beta19

* beta20

* beta21

* beta22

* beta23

* beta24

* beta25

* beta27

* beta28

* beta29

* beta30

* beta31

* beta33

* beta34

* beta35

* beta36

* beta37

* beta38

* beta39

* beta40

* beta41

* beta42

* beta43

* beta44

* beta45

* beta45

* beta46

* beat48

* beta49

* beta50

* beta51

* beta52

* beta53

* beta54

* beta55

* beta57

* beta58

* beta59

* beta61

* beta62

* beta63

* beta63

* beta64

* beta65

* beta66

* beta67

* beta70

* beta71

* beta72

* beta72

* beta74

* beta75

* beta76

* beta77

* beta78

* beta79

* beta80

* beta81

* beta82

* beta83

* beta85

* beta86

* beta87

* beta88

* beta89

* beta90

* beta91

* beta92

* beta93

* beta94

* beta94

* beta96

* beta97

* beta98

* beta99

* beta100

* beta101

* beta102

* beta104

* beta105

* beta106

* beta107

* beta108

* beta109

* beta110

* beta111

* beta112

* beta113

* beta115

* beta116

* beta117

* beta118

* beta119

* beta120

* beta121

* beta122

* beta123

* beta124

* beta125

* beta126

* beta127

* beta128

* beta129

* beta130

* beta131

* beta132

* beta1333

* beta134

* beta135

* beta136

* beta137

* beta138

* beta139

* beta140

* beta141

* beta142

* beta143

* beta144

* beta145

* beta146

* beta148

* beta149

* beta150

* beta151

* beta151

* beta152

* beta154

* beta155

* beta156

* beta160
  • Loading branch information
Hoshinonyaruko authored Jul 11, 2024
1 parent 39d60a5 commit b194b6d
Show file tree
Hide file tree
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
Expand Up @@ -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.")
}
}

Expand Down Expand Up @@ -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)
Expand Down
14 changes: 12 additions & 2 deletions applogic/chatgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
}

Expand Down Expand Up @@ -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)
Expand Down
19 changes: 13 additions & 6 deletions applogic/ernie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
}

Expand Down Expand Up @@ -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)
Expand Down
27 changes: 12 additions & 15 deletions applogic/hunyuan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
}

Expand Down Expand Up @@ -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)
Expand Down
27 changes: 12 additions & 15 deletions applogic/rwkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
}

Expand Down Expand Up @@ -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)
Expand Down
28 changes: 13 additions & 15 deletions applogic/tongyiqianwen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions applogic/yuanqi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,24 @@ _✨ 适用于Gensokyo以及Onebotv11的大模型一键端 ✨_

腾讯混元

腾讯元器

百度文心

阿里通义

清华智谱

字节火山(豆包)

OpenAI

groQ

Rwkv runner

One-API

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

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

0 comments on commit b194b6d

Please sign in to comment.