Skip to content

Commit

Permalink
update reverse engine
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Sep 11, 2023
1 parent 45bf757 commit b0efa10
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ node_modules
.vscode
.idea
config.yaml


# for reverse engine
reverse
access.json
15 changes: 6 additions & 9 deletions api/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NativeStreamRequest(model string, endpoint string, apikeys string, messages

client := &http.Client{}
req, err := http.NewRequest("POST", endpoint+"/chat/completions", utils.ConvertBody(types.ChatGPTRequest{
Model: strings.Replace(model, "reverse", "free", -1),
Model: model,
Messages: messages,
MaxToken: token,
Stream: true,
Expand All @@ -71,7 +71,6 @@ func NativeStreamRequest(model string, endpoint string, apikeys string, messages

res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
Expand All @@ -94,14 +93,12 @@ func NativeStreamRequest(model string, endpoint string, apikeys string, messages
}

func StreamRequest(enableGPT4 bool, isProPlan bool, messages []types.ChatGPTMessage, token int, callback func(string)) {
var model string
if isProPlan {
model = "gpt-4-reverse" // using reverse engine
} else {
model = "gpt-4"
}
if enableGPT4 {
NativeStreamRequest(model, viper.GetString("openai.gpt4_endpoint"), viper.GetString("openai.gpt4"), messages, token, callback)
if isProPlan {
NativeStreamRequest(viper.GetString("openai.reverse"), viper.GetString("openai.pro_endpoint"), viper.GetString("openai.pro"), messages, token, callback)
} else {
NativeStreamRequest("gpt-4", viper.GetString("openai.gpt4_endpoint"), viper.GetString("openai.gpt4"), messages, token, callback)
}
} else {
NativeStreamRequest("gpt-3.5-turbo-16k-0613", viper.GetString("openai.user_endpoint"), viper.GetString("openai.user"), messages, token, callback)
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/conf.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from "axios";

export const version: string = "2.2.0";
export const version: string = "2.3.0";
export const deploy: boolean = true;
export let rest_api: string = "http://localhost:8094";
export let ws_api: string = "ws://localhost:8094";
Expand Down
6 changes: 6 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ openai:
user_endpoint: https://api.openai.com/v1
image: sk-xxxxxx|sk-xxxxxx|sk-xxxxxx
image_endpoint: https://api.openai.com/v1
gpt4: sk-xxxxxx|sk-xxxxxx|sk-xxxxxx
gpt4_endpoint: https://api.openai.com/v1

reverse: gpt-4 # cf reverse
pro: ey...|ey...|ey...
pro_endpoint: .../imitate/v1

mysql:
host: localhost
Expand Down

0 comments on commit b0efa10

Please sign in to comment.