-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
removed duplications in function messages. #1262
base: main
Are you sure you want to change the base?
Conversation
…nside function calls from chat message to keep the chat context strictly to what the LLM sees in the instructions
|
I don't really agree with "what we include in a context as said by the assistant, should come from the assistant.". LLM is a complementation model even it's in the chat mode, it should have the ability to complement the content following the input user gives it. Meanwhile, users can set
I agree that adding messages to the chat ctx will change the behavior of the LLM, what I don't agree is this is a problem. It's highly depends on what messages added to the ctx, and users should have the flexibility to decide if this is the behavior they expected. |
It will be very helpful if you could share some cases this causes the problem. I have tested the prompt below and it worked as expected that function call always returns with a message. In my tests,
|
Sorry @longcw but I can tell you that the current setup, splitting one message with content + function into two messages, one with content and another with function ends up confusing the agent which will no longer do both things in the same message, and sends the content without calling the function.
I agree that users should keep the flexibility. And if they want to add a message in the middle, let it be that way. However, for those users that want to respect the original chat context, the moment 1 message goes into 2 messages, the user no longer have flexibility to keep them as one, and the behavior of the LLM changes. |
I understand your concerns. The duplicated messages was introduced in #1078. Here is my proposal if there is a message alongside the fnc:
This give both options to users. You can avoid using |
I just tried with this prompt and I can't replicate it... it might be because it's "too simple". But definitely happens when both the prompt and the conversation get longer |
This LGTM. Thanks for proposing it @longcw ! |
@longcw @davidzhao this is my proposal for the duplicated messages problem.
When the LLM is given a prompt, the LLM will follow those instructions of the prompt. It can generate messages and call functions. The LLM has no visibility on what happens inside the functions, except for the description, parameters, what is returned from those functions. If we generate assistant messages inside the functions and we append them to the overall context, this ends up confusing the LLM.
I have extensively tested it, and it ends up changing the behavior.
Is it as if i'm talking to you following some instructions and I see messages in the chat, coming from me, that I didn't write.
I understand the benefits of calling
agent.say
inside a function. However, IMHO, what we include in a context as said by the assistant, should come from the assistant. At least inside functions, where I've found this to be problematic. Outside of functions, usingagent.say
withadd_to_chat_ctx
is still not ideal, but up to the livekit user. Doing it inside the functions, forces every livekit user to have one original message split into 2 messages and the agent get confused.