Skip to main content

LlamaIndex x Gemini Live Integration

Integration between LlamaIndex and Google Gemini Live. Install the integration with:

pip install llama-index-voice-agents-gemini-live

And test it with the following minimal example:

from llama_index.voice_agents.gemini_live import GeminiLiveVoiceAgent
from llama_index.core.tools import FunctionTool
from llama_index.core.voice_agents import BaseVoiceAgentEvent
from llama_index.core.llms import ChatMessage, TextBlock
from typing import List
import random
import json


# use filter functions to export messages and events without your terminal being swamped by base64-encoded audio bytes :)
def filter_events(
    events: List[BaseVoiceAgentEvent],
) -> List[BaseVoiceAgentEvent]:
    evs = []
    for event in events:
        if not "audio" in event.type_t:
            evs.append(event)
    return evs


def filter_messages(messages: List[ChatMessage]) -> List[ChatMessage]:
    msgs = []
    for message in messages:
        msg = ChatMessage(role=message.role, blocks=[])
        for b in message.blocks:
            if isinstance(b, TextBlock):
                msg.blocks.append(b)
        if len(msg.blocks) > 0:
            msgs.append(msg)
    return msgs


def get_weather(location: str) -> dict:
    """Fetch weather data for a given location."""
    return json.dumps(
        {
            "location": location,
            "temperature_c": round(random.uniform(15, 30), 1),
            "humidity_percent": random.randint(40, 90),
            "wind_speed_kmh": round(random.uniform(5, 25), 1),
            "precipitation_probability_percent": random.randint(0, 100),
        },
        indent=4,
    )


weather_tool = FunctionTool.from_defaults(
    fn=get_weather,
    name="get_weather",
    description="Get the weather at a given location",
)


async def main():
    conversation = GeminiLiveVoiceAgent(tools=[weather_tool])

    await conversation.start()

    if conversation._quitflag:
        print("Events")
        print(conversation.export_events(filter=filter_events))
        print()
        print("Messages")
        print(conversation.export_messages(filter=filter_messages))


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Remember that:

  • You have to either set GOOGLE_API_KEY as env variable or pass the api_key when initializing GoogleGeminiVoiceAgent
  • You have to start the conversation

Metadata

Release files for llama-index-voice-agents-gemini-live 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-voice-agents-gemini-live 0.5.0
File Size Uploaded Provenance Actions
llama_index_voice_agents_gemini_live-0.5.0.tar.gz 7.1 kB Without provenance Details for llama_index_voice_agents_gemini_live-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-voice-agents-gemini-live 0.5.0
File Interpreter ABI Platform Actions
llama_index_voice_agents_gemini_live-0.5.0-py3-none-any.whl Python 3 none any Details for llama_index_voice_agents_gemini_live-0.5.0-py3-none-any.whl

Total release size: 15.2 kB

Release files / llama_index_voice_agents_gemini_live-0.5.0.tar.gz

Download URL llama_index_voice_agents_gemini_live-0.5.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8bc587b9422697e143b70b90b59328ae0ed39e99d4b919811a7c198e83a22d7a
BLAKE2b-256 checksum
How to use checksums
6390b847d4d335de31a95bb9d715437d5f34352242e2452f5aa1a1ad7ae58dcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / llama_index_voice_agents_gemini_live-0.5.0-py3-none-any.whl

Download URL llama_index_voice_agents_gemini_live-0.5.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87a8797b391919f9855cb2fb60350d9e26900b42ab3401b9ce79034a8e9d9514
BLAKE2b-256 checksum
How to use checksums
d204c42205577532c2732379412393c34bae06fcc81fea3f16610fa85b3fe7ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for llama-index-voice-agents-gemini-live 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page