agents icon indicating copy to clipboard operation
agents copied to clipboard

Add Events Before LLM & TTS Invocation

Open Toubat opened this issue 1 year ago • 5 comments

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

Toubat avatar Oct 28 '24 09:10 Toubat

⚠️ 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

changeset-bot[bot] avatar Oct 28 '24 09:10 changeset-bot[bot]

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 28 '24 09:10 CLAassistant

Why not just use before_tts_cb and before_llm_cb directly?

martin-purplefish avatar Oct 28 '24 18:10 martin-purplefish

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.

Toubat avatar Oct 28 '24 19:10 Toubat

cc @davidzhao @theomonnom

Toubat avatar Oct 31 '24 18:10 Toubat