diff --git a/LLama/ChatSession.cs b/LLama/ChatSession.cs index a3a50665..c6cd0a84 100644 --- a/LLama/ChatSession.cs +++ b/LLama/ChatSession.cs @@ -18,7 +18,14 @@ namespace LLama public IEnumerable Chat(string text, string? prompt = null) { - return _model.Chat(text, prompt); + History.Add(new ChatMessageRecord(new ChatCompletionMessage(ChatRole.Human, text), DateTime.Now)); + string totalResponse = ""; + foreach(var response in _model.Chat(text, prompt)) + { + totalResponse += response; + yield return response; + } + History.Add(new ChatMessageRecord(new ChatCompletionMessage(ChatRole.Assistant, totalResponse), DateTime.Now)); } public ChatSession WithPrompt(string prompt)