back to indexFaster LLM Function Calling — Dynamic Routes
Chapters
0:0 Fast LLM Function Calling
0:56 Semantic Router Setup for LLMs
2:20 Function Calling Schema
4:4 Dynamic Routes for Function Calling
5:51 How we can use Faster Agents
00:00:00.000 |
Today, we're going to take a look at dynamic routes 00:00:11.300 |
Unlike a static route, a dynamic route is able 00:00:21.100 |
into whatever you want to do with those parameters. 00:00:23.940 |
So the main use case here is function calling. 00:00:32.500 |
but they're still very fast, just like our static routes. 00:00:38.900 |
And I think what would be best is to just take a look 00:00:41.980 |
at how they differ, which is not by a huge amount. 00:00:53.340 |
and I'm just going to open that notebook in Colab. 00:01:18.600 |
because we want to see what the difference is 00:01:26.020 |
And then we're going to initialize our route layer. 00:01:31.460 |
whether you have dynamic or static routes or both, 00:01:36.580 |
And again, we can use Cohere, we can use OpenAI. 00:01:39.360 |
There's also now a new FastEmbed encoder as well 00:01:42.580 |
if you want to run the embedding part locally. 00:01:46.160 |
I'm going to use OpenAI because we will also want 00:02:02.500 |
And soon enough, you will also have local LLMs. 00:02:13.020 |
It's working, and this is purely static routes. 00:02:15.400 |
Let's see how we might create a dynamic route. 00:02:19.260 |
So here is how we would set up our dynamic route. 00:02:26.820 |
You can actually, sorry, this is the actual definition 00:02:35.840 |
the function schema that is required for our dynamic route. 00:02:50.460 |
Now, what I'm doing here with the get schema function here 00:03:03.420 |
So we're using the sphinx.string format here. 00:03:09.180 |
as to how exactly this function should actually be used. 00:03:14.180 |
So finds the current time in a specific time zone. 00:03:23.420 |
We need this for our dynamic route to understand 00:03:29.100 |
Then we specify, okay, we have our time zone. 00:03:37.100 |
Okay, so the time zone to find the current time in. 00:03:47.460 |
And then we specify, do not put the place name 00:03:52.700 |
You must provide this particular IANA format. 00:03:57.140 |
That is then going to, okay, we provide this format 00:04:01.140 |
and it's gonna give us a time in that particular place. 00:04:10.060 |
We put that through our get schema function here. 00:04:30.260 |
So if I remove that, this is now a static route. 00:04:33.220 |
If I add that back in, it's a dynamic route, okay? 00:04:46.980 |
And then I'm going to ask a time-related question, okay? 00:05:43.940 |
with any function call that you'd expect an LLM 00:05:53.940 |
is we're setting up that kind of like agentic workflow 00:06:02.180 |
and then generate the input for whatever it decides to do. 00:06:13.460 |
And we're using semantics to make that decision, 00:06:24.460 |
which we've seen it does and it does pretty quickly.