Skip to content

Commit

Permalink
Fix bug for setting window for robot. v1.0.36
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Dec 17, 2023
1 parent 459fda8 commit 7643596
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,6 @@ The changelog:
* Refine bot log for the first time. [v1.0.33](https://github.com/ossrs/ai-talk/releases/tag/v1.0.33)
* Allow user retry when error. v1.0.34
* Refine badcase for user input. v1.0.35
* Fix bug for setting window for robot. [v1.0.36](https://github.com/ossrs/ai-talk/releases/tag/v1.0.36)

Winlin, 2023.12
13 changes: 4 additions & 9 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,13 +707,8 @@ func handleUploadQuestionAudio(ctx context.Context, w http.ResponseWriter, r *ht
Content: stage.previousAssitant,
})

if v, err := strconv.ParseInt(os.Getenv("AIT_CHAT_WINDOW"), 10, 64); err != nil {
return errors.Wrapf(err, "parse AIT_CHAT_WINDOW %v", os.Getenv("AIT_CHAT_WINDOW"))
} else {
window := int(v)
for len(stage.histories) > window*2 {
stage.histories = stage.histories[1:]
}
for len(stage.histories) > robot.chatWindow*2 {
stage.histories = stage.histories[1:]
}
}

Expand Down Expand Up @@ -747,8 +742,8 @@ func handleUploadQuestionAudio(ctx context.Context, w http.ResponseWriter, r *ht
} else {
temperature = float32(v)
}
logger.Tf(ctx, "robot=%v(%v), AIT_CHAT_MODEL: %v, AIT_MAX_TOKENS: %v, AIT_TEMPERATURE: %v, histories=%v",
robot.uuid, robot.label, model, maxTokens, temperature, len(stage.histories))
logger.Tf(ctx, "robot=%v(%v), AIT_CHAT_MODEL: %v, AIT_MAX_TOKENS: %v, AIT_TEMPERATURE: %v, window=%v, histories=%v",
robot.uuid, robot.label, model, maxTokens, temperature, robot.chatWindow, len(stage.histories))

gptChatStream, err := client.CreateChatCompletionStream(
ctx, openai.ChatCompletionRequest{
Expand Down

0 comments on commit 7643596

Please sign in to comment.