Open prykris opened 1 month ago
What do you think about using the same approach that has been implemented for Anthropic? https://github.com/theodo-group/LLPhant/blob/9ac8a5325605da1f6beca6fcb02929a756f8a3a9/src/Chat/AnthropicChat.php#L70 @MaximeThoonsen what is your opinion?
What do you think about using the same approach that has been implemented for Anthropic?
@MaximeThoonsen what is your opinion?
While it does work, it comes with great drawback of it being stateless. We are unable to continue the conversation with "correct" history.
Could you be open to creating a stateful chat history solution while still being stateless by default?
While I understand that responsibility falls more on the user side the current approach limits what kind of messages users can collect. I don't see why the user couldn't attach its own MessageBag
(or whatever object is meant for collection). The extendability is lacking here
@prykris @f-lombardo My two main goals are:
After that I'm quite open on a lot of stuff :).
I feel we are on an important topic as agents and "chat with function being called" will be mainstream really soon.
We can create a new chat method that is stateful and we should indeed be more flexible to handle all the use cases. @prykris , in your message bag, what did you had in mind to put in? The function called?
For the stateful chat what do we need ?
Do you see anything else?
Simplicity remains achievable as long as users can choose between the core implementations for chat generation. My suggestion is to apply composition over inheritance and build on that foundation.
Copy code
class PersistentChat {
protected ChatInterface $chat;
}
My key requirements are:
For storing messages, the LinkedList data structure is ideal, with each node pairing a message and its metadata. This structure simplifies implementing a sliding window or querying conversation history based on token usage. It also allows for applying rules to the MessageBag, adjusting for different AI providers, and handling invalid states efficiently.
Since the conversation history is built using Message instances it doesn't allow me to return the called function result back into the conversation.
The error I receive:
Invalid parameter: messages with role 'tool' must be a response to a preceding message with 'tool_calls'.
Here is how I handle the tool call, and attempt to feed it back
And if I attempt to use
functionCall
instead, I get the following error:Missing parameter 'name': messages with role 'function' must have a 'name'.
I can't seem to make it "work" without hacking the implementation of OpenAIChat, which I DO NOT want to do. But I might have to extend and overwrite the method in order to get it working.
functions
are deprecated and are replaced bytools
it seems, but there yet does not seem to be a way that properly returnstool
call data.