-
Notifications
You must be signed in to change notification settings - Fork 439
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
Function calling #175
Function calling #175
Conversation
3418f19
to
729aca3
Compare
So, function calling is... weird. Without function calling, a chatbot pipeline is pretty straightforward:
With function calling, the flow is different:
Right now, that entire second branch is implemented in the |
llm, # LLM | ||
tts, # TTS | ||
transport.output(), # Transport bot output | ||
tma_out # Santa Cat spoken responses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the comments are removed? And we should use WakeCheckFilter
instead.
] | ||
|
||
}) | ||
self._context.add_message(tool_call) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this can be added internally when we push LLMFunctionCallFrame
. There's nothing the user should do in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant to do this on behalf of the user, because as a general rule we don't mess with the context in the framework. In the patient-intake example, I'm kind of misusing function calling and not actually inserting function call results into the context, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Well, in this case it's not the result, it's just the function call itself. Maybe for this one maybe we could add an argument to the LLM service, something like include_function_calling_in_context
or something like that (and it defaults to True). Asking the user to handle all this is too much probably?
@aconchillo I think I've addressed the concerns and the function calling code is ready to merge. But I'm still concerned I may have inadvertently undone some of your changes through various merges and rebases. |
src/pipecat/services/openai.py
Outdated
LLMFullResponseEndFrame, | ||
LLMFullResponseStartFrame, | ||
LLMFunctionStartFrame, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove LLMFunctionStartFrame
and CallFrame
OK, I think I've gotten the new function calling approach where it needs to be. Let's get this one merged, and I can remove the function call frame types in a follow-up PR. @aconchillo |
self._context.add_message( | ||
{"role": "system", "content": "Finally, ask the user the reason for their doctor visit today. Once they answer, call the list_visit_reasons function."}) | ||
await llm.process_frame(OpenAILLMContextFrame(self._context), FrameDirection.DOWNSTREAM) | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should all these functions return None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They do implicitly, but maybe better to be more explicit about it, if so.
f09a9ba
to
ed70c71
Compare
No description provided.