Add Events Before LLM & TTS Invocation
Add two new events for assistant:
@assistant.on("llm_started_streaming")
def before_calling_llm(chat_ctx: ChatContext):
pass
@assistant.on("tts_started_streaming")
def before_calling_tts(source: AsyncIterator[str] | str):
pass
⚠️ No Changeset found
Latest commit: 52d6b5949dd32557bb9cd53cec38238448e2023e
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
Why not just use before_tts_cb and before_llm_cb directly?
Why not just use before_tts_cb and before_llm_cb directly?
@martin-purplefish Great question! Currently, both before_tts_cb and before_llm_cb are tightly coupled to the assistant object’s constructor, meaning they need to be created prior to instantiating the assistant object. However, in our application, the assistant object is passed across various layers/components, and some components are responsible for attaching event handlers to the assistant (which can only happen post-instantiation). By using an event emitter class, we ensure a unified approach to passing callbacks throughout.
cc @davidzhao @theomonnom