Join us and get access to thousands of tutorials and a community of expert Pythonistas.
This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.
Seeing the Agent in Action
00:00
The instructions to run the agent are in the README file. So they start on line 25, well on 26 technically, all the way down to line 41.
00:13 So here you can see everything in my REPL. So what we’re doing is you’re importing here your email agent, your graph. You’re also importing some emails, which are example emails.
00:23 And you define your escalation criteria. And then you define a message that you want to come back if there is an escalation to be done. And then the email that’s being fed in is a specific one.
00:36
It’s email index three, because that is one that has something to escalate, if you like. Then there’s a message created here, and you’ll recognize that structure of the dictionary with messages and then a list of AI messages.
00:50 And then the last two lines just trigger the model. So then when you run that, when you hit Enter twice, you get this.
01:16
So there’s obviously a lot happening. So looking at the output, it starts with a HumanMessage. And it says there is an immediate risk of electrical, water, fire damage, and so on.
01:26 And then you can read the email in your own time if you like. You then have a detail of what the Ai Message looks like. So you have a tool call here, which has a Call ID as expected.
01:38 And there’s dates in there, and then there’s a From and To, and so on. So that’s your tool call. But then interestingly here, you see the agent in action. So it’s the logger functionality that creates all this on the screen.
01:54 But you can see it’s calling the email notice extraction graph. Then it’s parsing the notice, then determining the status, escalation needed. Then it sends the escalation emails to these particular emails here.
02:08 And then it creates a legal ticket for the notice. And then the legal ticket is created. You might recognize the state graph of the notice extraction tool you’ve covered in a little bit of detail during the course.
02:23
So the ToolMessage then looks like this. It has strings in there and has all the information in there. But the AIMessage then converts this to a nice-looking output.
02:35
So this is, of course, where your Pydantic BaseModel comes in because it defines the output structure. For example, if I look at the last one here, this returns a datetime.
02:45
So it’s a date object. Whereas the output, the 5th of August, is here in the Ai Message as a string, which is what was requested by the output structure.
02:59 There is, of course, a lot more to go through here, a lot more interesting stuff. But I’ll leave it to you to discover that in your own time because you have reached the end of this course.
03:10 So all that’s left to do for you is to go through what you have learned in the next lesson.
Become a Member to join the conversation.