tmc / langchaingo

LangChain for Go, the easiest way to write LLM-based programs in Go
https://tmc.github.io/langchaingo/
MIT License
3.76k stars 523 forks source link

[Bug] agents.WithMemory not work #835

Open plum330 opened 1 month ago

plum330 commented 1 month ago

toolKits := []tools.Tool{xxx, xxx} history := memory.NewChatMessageHistory() for idx, conversation := range conversations { if idx&0x1 == 0 { err = history.AddUserMessage(ctx, conversation) } else { err = history.AddAIMessage(ctx, conversation) } } mem := agents.WithMemory(memory.NewConversationBuffer(memory.WithChatHistory(history))) agent := agents.NewExecutor(agents.NewOneShotAgent(llm, toolKits), toolKits, mem) result, err = chains.Run(ctx, agent, input, options...) Above code snippet, add chat history to agents, however, the final request sent to the llm has no chat history.