Skip to content

Conversation

@AstraBert
Copy link
Member

Description

This package adds a LlamaIndex wrapper for ElevenLabs, that allows users to chat with their ElevenLabs Agents real-time, recording their interactions with the agent in LlamaIndex ChatMessages.

New Package?

Did I fill in the tool.llamahub section in the pyproject.toml and provide a detailed README.md for my new integration or package?

  • Yes
  • No

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • No

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Your pull-request will likely not be merged unless it is covered by some form of impactful unit testing.

  • I added new unit tests to cover this change
  • I believe this change is already covered by existing unit tests

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (next PR)
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran uv run make format; uv run make lint to appease the lint gods

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jun 4, 2025
client,
AGENT_ID,
requires_auth=bool(API_KEY),
audio_interface=DefaultAudioInterface(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thinking for the future, we might need to design (or use existing) our own audio interface across voice integrations

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the callback functions defined in utils, we already do use AudioBlock :)
I'm planning on scaling the support across the various integrations

conversation.start_session()

# RUN UNTIL CTRL+C IS HIT
signal.signal(signal.SIGINT, lambda sig, frame: conversation.end_session())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a more useful demo might be showing a while True loop with some kind of exit condition? If I was to use this in my own script, thats probably what I would do

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! I'll try to implement it :))

self._conversation_id = None
self._last_interrupt_id = 0

def _handle_message(self, message, ws):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing type annotations on functions (even if we don't use mypy in CICD, I've started to use mypy locally to sanity check my new code haha)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh shoot thanks a lot, adding them right away!

if event["ping_ms"] is None:
event["ping_ms"] = 0
self._callback_latency_measurement(self._latencies, int(event["ping_ms"]))
elif message["type"] == "client_tool_call":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do tool calls need to be in the chat history as the conversation runs? they already are? (just trying to follow the logic of what the voice agent actually sees)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, they're not in the chat history of ElevenLabs, that's why I stored them in the LlamaIndex-formatted one as text
But I'm happy to give it a second look :)

Copy link
Collaborator

@logan-markewich logan-markewich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine to merge as a beta.

So far from reading this and my experience from openai, some ideas for what a base class should provide:

  • voice APIs often operate on events -- should we design our own event schema that works across providers? I.e. interrupt, tool call, etc.?
  • the object for voice/device input/output should be common across all providers if we can
  • the methods/UX for starting/ending a session should be common across all providers
  • since voice APIs commonly include tool-calling, we can probably brand these "llama-index voice agents"
  • the concept of "handling events" reminds me of workflows honestly. I'm not sure if there's a tie in there or not, but maybe worth thinking about (should the base class be a workflow? Not sure lol)

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 4, 2025
@AstraBert
Copy link
Member Author

AstraBert commented Jun 5, 2025

I agree on pretty much everything, and I'll check, as the integrations for voice agents progress, the possibility of subclassing Workflows, which seems interesting! I'll just push some changes related to the example and re-version it as beta

@logan-markewich logan-markewich merged commit c1cd863 into main Jun 6, 2025
10 checks passed
@logan-markewich logan-markewich deleted the clelia/elevenlabs-integration branch June 6, 2025 17:55
@colca colca mentioned this pull request Jun 9, 2025
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants