Skip to content

Commit

Permalink
fix: chat history slice append
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu327 committed Mar 28, 2024
1 parent fc96896 commit d2c6c4c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/adapter/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func convertFinishReason(reason genai.FinishReason) openai.FinishReason {
func setGenaiChatHistory(cs *genai.ChatSession, messages []*genai.Content) {
cs.History = make([]*genai.Content, 0, len(messages))
if len(messages) > 1 {
cs.History = messages[:len(messages)-1]
cs.History = append(cs.History, messages[:len(messages)-1]...)
}

if len(cs.History) != 0 && cs.History[len(cs.History)-1].Role != genaiRoleModel {
Expand Down

0 comments on commit d2c6c4c

Please sign in to comment.