feat(api): implement stateful responses api (#122)

* feat(api): implement stateful responses api

Signed-off-by: mudler <mudler@localai.io>

* fix(tests): align client to API changes

Signed-off-by: mudler <mudler@localai.io>

---------

Signed-off-by: mudler <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto
2025-04-01 18:00:37 +02:00
committed by GitHub
parent 86cb9f1282
commit f3c06b1bfb
6 changed files with 68 additions and 16 deletions

View File

@@ -73,3 +73,12 @@ func (c *ConversationTracker[K]) AddMessage(key K, message openai.ChatCompletion
c.currentconversation[key] = append(c.currentconversation[key], message)
c.lastMessageTime[key] = time.Now()
}
func (c *ConversationTracker[K]) SetConversation(key K, messages []openai.ChatCompletionMessage) {
// Lock the conversation mutex to update the conversation history
c.convMutex.Lock()
defer c.convMutex.Unlock()
c.currentconversation[key] = messages
c.lastMessageTime[key] = time.Now()
}