HomeVideos

Voice Agent observability with LangSmith

Now Playing

Voice Agent observability with LangSmith

Transcript

159 segments

0:00

Hello How are we today.

0:02

Good thank you.

0:03

What's the weather in San Francisco.

0:08

It's currently 85 degrees Fahrenheit and sunny there.

0:11

Anything else you'd like to know.

0:12

Today, we're going to take a voice agent built

0:15

using the Google ADK and the Gemini Live model

0:18

and trace it to lamb-smith to see

0:20

exactly what's happening under the hood of this voice agent.

0:23

Gemini app live is Google's native audio model.

0:26

It's speech to speech, which means it takes audio directly

0:29

as input and produces audio directly

0:32

as output without ever transcribing that audio to text.

0:37

This means voice agents built with Gemini Live

0:39

are low latency, meaning there's very little lag between when

0:43

the user is done speaking and when the agent responds.

0:46

And it also enables the agent's voice

0:48

to sound a lot more natural and a lot more emotive.

0:51

When you're working on building a great voice agent,

0:54

using the Google ADK and the Gemini Live model

0:57

is the first step to building that agent.

1:00

But to take that agent to production safely,

1:03

you need visibility into what your agent is doing,

1:06

and the ability to test its behavior

1:08

in a number of different scenarios

1:10

that it might encounter with real end users.

1:12

And that's where blanc-smith comes in.

1:15

Blanc-smith is a platform built by LangChain for AI agent

1:18

observability and evaluations.

1:21

So today, we're going to walk through how

1:23

to set up tracing billings-smith for a voice agent

1:26

that's built on the Google ADK using the Gemini Live model.

1:30

The agent that we're tracing today

1:32

is a very simple weather assistant

1:34

that you can run from the terminal.

1:36

The agent has access to two tools, one

1:38

to get the time and one to get the weather.

1:42

This means that we can ask the agent

1:43

for the weather in any city, and the agent

1:46

is able to do the lookup and respond

1:48

to us with a full weather update for the city that we requested.

1:52

We've also given this agent a prompt in a real voice agent.

1:56

This prompt would be much longer,

1:58

with complex instructions for how

2:00

the agent should behave in a number of different situations.

2:03

Here it's only a few sentences long,

2:05

because we just want to set the tone for the agent

2:07

and make it aware of its capabilities.

2:09

The rest of the code is just plumbing

2:11

to get the agent working.

2:13

So for example, here we're just taking the user's audio

2:16

and sending it to the model for processing.

2:20

And in this code here we're setting up some configurations

2:23

for our voice agent.

2:24

So for example, we are enabling input and output audio

2:28

transcription as well as setting some sensitivity thresholds

2:33

for our voice activity detection.

2:36

The rest of the code in this event loop

2:38

here is for updating the UI in the terminal,

2:41

so that we can follow along as we're talking to the agent.

2:44

Now let's set up tracing to set up our tracing.

2:47

We're going to use the native Smith aidc tracing integration

2:50

that was released by.

2:52

In the Details of the integration

2:54

are in the docs under trace voice AI frameworks Gemini Live.

3:00

The docs walk through the steps required

3:02

to set up the tracing to Smith, and those are the same steps

3:05

that we're going to follow now.

3:07

The Smith tracing integration is a plugin to the SDK.

3:10

So the first thing that we need to do is define the plugin.

3:16

This links with Google ADK plugin class

3:19

is imported directly from the SDK.

3:23

On it, we're setting some configurations

3:25

like a project name to trace to some tags, some metadata,

3:30

as well as a lambda for pulling the thread ID.

3:34

Then we need to register the plugin on the runner

3:36

and we need to do that here.

3:40

The plugin handles the bulk of the tracing,

3:43

but the one thing that we still need to set up

3:45

is capturing the conversation audio.

3:48

Making sure that we record the conversation audio is

3:50

important because at the end of the day,

3:52

the source of truth for the voice agent's interaction

3:55

with your customer is that audio recording.

3:59

And so the trace would be incomplete without it.

4:01

The plugin here has two functions for us

4:04

to use to record the conversation audio record user

4:07

audio and record agent audio, both of which

4:11

take a chunk of audio and append it to the recording

4:13

that we're tracing on the user's audio side.

4:17

That's easy to do when we receive

4:19

an audio chunk from our user.

4:21

We're also going to trace it.

4:23

And so we can do that here.

4:27

The tricky part is recording the agent's audio

4:30

because we want to record only what the user heard,

4:34

not what the agent generated.

4:36

So for example, if the agent generated

4:38

a very lengthy response, but the user interrupted the agent

4:41

before the agent was done speaking,

4:44

we want to cut that audio to whatever the agent said

4:47

before it stopped talking.

4:50

Getting that set up correctly is going

4:52

to depend a lot on where your input and output audio are

4:55

streaming from, and how you're integrating with those speakers.

5:00

In my demo, I have a set play callback function

5:03

on this audio out class, and so this is the right place for me

5:07

to record the agent audio.

5:10

So let me add it here.

5:17

And with that, we're done.

5:19

Let's run our agent to take a look at a trace.

5:26

Hey there.

5:29

How are you today.

5:31

Good Thank you.

5:32

What's the weather in San Francisco.

5:37

It's currently 85 degrees Fahrenheit and sunny there.

5:40

Anything else you'd like to know.

5:42

Yes what's the weather in Los Angeles.

5:47

It's about 86.

5:49

Tokyo in Tokyo, it's sunny and 83 degrees.

5:55

Anything else I can help you.

5:56

Check like, maybe the time somewhere.

5:59

No that's it.

6:01

All right.

6:01

Sounds good.

6:02

Have a great day.

6:03

This is what the trace looks for the conversation I just

6:06

had with the voice agent.

6:08

You can see all of the details of the conversation,

6:10

as well as all of the implementation

6:12

details of the voice agent.

6:14

So first off, you have the audio right here above the trace.

6:19

You can see when I spoke highlighted in blue.

6:21

And when the agent spoke highlighted in orange.

6:24

You can see the transcript of the conversation

6:26

here on the right.

6:28

This is based on the input and output transcriptions

6:31

that Gemini Live provides us and that we enabled in our code.

6:35

If you remember back to the configurations

6:37

that I was showing.

6:39

You can see every tool call, including

6:41

the arguments, the result, and how long it took.

6:47

You can see all the different events

6:49

like turn completed, as well as the interruption

6:52

event from when I interrupted the agent's response.

6:56

And lastly, you can also see all of the costs breakdown

7:00

under usage metadata.

7:02

You can see all of the tokens that

7:04

were used, including the special audio tokens,

7:06

both for input and for output.

7:09

And this is great to give you visibility and accountability

7:12

into the costs of your agent.

7:14

Tracing is the first step to taking your agent

7:17

into production.

7:18

From these traces that your agent is sending to lindsmith,

7:21

you can now do everything you'd normally do with text traces,

7:24

run evals, add traces to data sets,

7:27

annotation queues, build dashboards, share traces, debug,

7:31

and much more.

Interactive Summary

The video demonstrates how to build and trace a voice agent using Google ADK, Gemini Live, and LangSmith. Gemini Live is highlighted as Google's native speech-to-speech audio model, offering low latency and natural, emotive voice interactions. The core focus is on integrating LangSmith for robust observability and evaluation of these voice agents in production environments. The demonstration involves setting up tracing for a simple weather assistant, emphasizing the importance of capturing both user and agent conversation audio, especially handling interruptions to accurately record what the user heard. A detailed walkthrough of a LangSmith trace is provided, showcasing features like audio playback, conversation transcripts, tool call details, various agent events, and a comprehensive cost breakdown, including audio tokens, to provide full visibility and accountability.

Suggested questions

6 ready-made prompts