And here we are in cursor and going into week eight and going into day five, we get day five. 我们现在处于光标位置，进入第八周，进入第五天，我们得到了第五天。
How did we get here so fast. 我们怎么这么快就到了这里。
All right. 好的。
So it's now time. 所以现在是时候了。
The final step building the user interface. 构建用户界面的最后一步。
And along with that, another uh, Python module that is going to help us out that I will introduce 除此之外，另一个呃，Python 模块将帮助我们解决这个问题，我将介绍它
for you in just a second. 只需一秒钟即可为您服务。
So first of all, that great line import gradio as G. 首先，那条伟大的线将 gradio 导入为 G。
And then this from deal agent framework import deal agent framework. 然后从交易代理框架导入交易代理框架。
What is that? 那是什么？
I told you we weren't going to use any frameworks. 我告诉过你我们不会使用任何框架。
So what is this exactly. 那么这到底是什么。
And then we're bringing in some of the classes we looked at before from deals. 然后我们引入了我们之前从交易中看到的一些课程。
Okay. 好的。
So so with that before before we go further, I want to quickly show you what is in this deal agent 因此，在我们进一步讨论之前，我想快速向您展示该交易代理的内容
framework thing. 框架的东西。
So here it is. 所以就是这样。
Here is the module deal agent framework. 这是模块交易代理框架。
And it's really just the kind of glue that goes around everything. 它确实是一种可以粘在所有东西上的胶水。
Uh, and it's just sort of to take us out of the notebook construct with just one little bit of extra 呃，这只是让我们摆脱笔记本结构，只需一点点额外的东西
functionality. 功能。
So first of all, it has something that sets up logging and does that properly. 首先，它有一些可以设置日志记录并正确执行此操作的功能。
And this is the class deal agent framework. 这就是类交易代理框架。
Um, I've added something called memory. 嗯，我添加了一个叫做内存的东西。
And that sounds like it's something very fancy. 这听起来像是一件非常奇特的事情。
Whenever you hear of memory it sounds like this is very something very clever, ingenious. 每当你听到记忆时，你都会觉得这是一个非常聪明、巧妙的东西。
But it's typically just talking about loading and saving something from disk. 但它通常只是谈论从磁盘加载和保存某些内容。
In some situations, memory is a is a tool that you give an agent so that it can look things up in memory. 在某些情况下，内存是您为代理提供的一种工具，以便它可以在内存中查找内容。
In other cases, it's just something that you'll shove in the prompt. 在其他情况下，您只需将其放入提示中即可。
So make sure that it knows about the prior conversation or to to know about deals that it surfaced in 因此，请确保它了解之前的对话或了解其出现的交易
the past. 过去。
In that case, that's what we're doing here. 在这种情况下，这就是我们在这里所做的。
So I've got a function read memory and a function write memory. 所以我有一个函数读取内存和一个函数写入内存。
And that quite literally reads and writes from a JSON file called memory and memory JSON. 从字面上看，它是从一个名为内存和内存 JSON 的 JSON 文件中读取和写入。
I've clicked on here. 我点击了这里。
It just has a bunch of JSON to describe prior deals that have been surfaced. 它只有一堆 JSON 来描述之前已经出现的交易。
In fact, because our deals are all pedantic objects, it simply writes those pedantic objects to JSON 事实上，因为我们的交易都是迂腐的对象，所以它只是将这些迂腐的对象写入 JSON
and into this file. 并进入这个文件。
And that's why the code is so light. 这就是代码如此简单的原因。
That's what read memory and write memory does. 这就是读内存和写内存的作用。
And there's also a class method reset memory that will put it back to just the first two items. 还有一个类方法重置内存，可以将其恢复到前两项。
So there's something a little in there. 所以里面有一些东西。
There's a log function. 有日志功能。
And then there's there's a run function that kicks things off and gets everything up and running. 然后有一个运行函数来启动并让一切启动并运行。
So this is this is what we have. 这就是我们所拥有的。
Uh, and with that I am now going to, uh, to, to go back to the code so that we can, we can get 呃，现在我要，呃，回到代码，这样我们就可以，我们可以得到
this thing running. 这件事正在运行。
Okay. 好的。
So we're going to do these imports, we're importing Gradio and we're creating this deal agent framework 因此，我们将进行这些导入，导入 Gradio，并创建这个交易代理框架
object. 目的。
Um, all right. 嗯，好吧。
Now the next thing I'm going to do is create a little gradio app. 现在我要做的下一件事是创建一个小渐变应用程序。
And, you know, this isn't a Gradio course. 而且，你知道，这不是普通课程。
So I'm not going to go super deep on it. 所以我不会太深入地讨论它。
But I just want to explain we're using GR blocks, which is when you want to build a Gradio interface 但我只是想解释一下我们正在使用 GR 块，这是当你想要构建 Gradio 界面时
piece by piece, which we did touch on briefly in week two. 我们在第二周确实简要地谈到了这一点。
We're giving it a title, The Price Is Right. 我们给它起了一个标题：价格合适。
We're saying we want to fill the whole width of the interface to not have margins on either side. 我们是说我们想要填充界面的整个宽度，两边都没有边距。
And we're going to have, uh, two, two fields here. 我们这里将有，呃，两个，两个字段。
Markdown. 降价。
The price is right deal hunting agent guy. 价格合适，寻找代理的家伙。
And then a sort of like a subheading. 然后有点像副标题。
Uh, let's just run this to see what happens if I do. 呃，让我们运行一下，看看如果我这样做会发生什么。
So, uh, when I run this, it pops up a screen. 所以，呃，当我运行这个时，它会弹出一个屏幕。
The price is right here. 价格就在这里。
It is a nice gradient UI with, with the with all the usual stuff on an empty screen. 这是一个很好的渐变用户界面，所有常用的东西都在空屏幕上。
Ready for some action. 准备采取一些行动。
Okay. 好的。
All right. 好的。
So let's go back to the code again and let me show you the next step in this UI. 因此，让我们再次回到代码，让我向您展示此 UI 中的下一步。
So we're going to create this deal agent framework. 所以我们将创建这个交易代理框架。
We're going to have that running. 我们将继续运行。
And meanwhile we're going to uh just just try and build out the user interface a little bit more. 与此同时，我们将尝试构建更多的用户界面。
I'm adding in a table which is called a data frame, a table with description, price estimate, discount 我添加了一个称为数据框的表，该表包含描述、价格估算、折扣
URL. 网址。
I'm also going to set up some some initial dummy objects, a deal which is going to have a description 我还将设置一些初始虚拟对象，该交易将有一个描述
example description. 示例描述。
And you know I'm using these things called Gradio callbacks. 你知道我正在使用这些称为“Gradio 回调”的东西。
This callback means when the user interface is loaded, I want you to call this function get table that's 这个回调意味着当用户界面加载时，我希望你调用这个函数获取表
written right here. 就写在这里。
Give it as the inputs, the current deals that I know about and whatever comes out of it. 将其作为输入，我所了解的当前交易以及由此产生的任何结果。
Connect that to this this gradio table. 将其连接到这个渐变表。
All right. 好的。
So this may have been a bit abstract for you, but it will come real when I run it. 所以这对你来说可能有点抽象，但当我运行它时它就会变成现实。
You see that the deal agent framework runs, which brings up lots of stuff. 您会看到交易代理框架正在运行，这会带来很多东西。
Then the UI appears and there's a dummy table with an example item in there. 然后出现 UI，并且有一个虚拟表，其中包含示例项目。
We're starting to see the beginnings of a user interface okay. 我们开始看到用户界面的雏形了。
And now and now I have put this user interface into a Python module and it is called Price is right.py. 现在，我已将此用户界面放入 Python 模块中，并将其命名为 Price is right.py。
Let's take a look at it. 我们来看一下。
It's it's got a bit more I've got some, some funky stuff to deal with with how it's going to uh, collect 它还有更多一些我还有一些一些时髦的东西来处理它如何收集
the logs, anything that's written to the log and display it in Gradio. 日志，写入日志的任何内容并将其显示在 Gradio 中。
And this is a little bit janky, but but otherwise it's all fine. 这有点笨拙，但除此之外一切都很好。
It's it's it's pretty Boilerplate stuff that can be a bit wordy, but I'm making it so that it shows 它是非常样板的东西，可能有点罗嗦，但我这样做是为了让它显示
all of the data on the UI. UI 上的所有数据。
And I've also got something built in here that means that it sets up a timer so that every five minutes 我还在这里内置了一些东西，这意味着它会设置一个计时器，以便每五分钟
it will wake up and start things running again. 它会醒来并重新开始运行。
Um. 一。
Meaning? 意义？
Meaning that this will always be running. 这意味着这将永远运行。
Always chugging. 总是嘎吱嘎吱的。
Um. 一。
Always doing some processing. 总是做一些处理。
And again, if I go back to the day five lab, um, first up, I've, uh, remember I have that reset 再说一次，如果我回到第五天的实验室，嗯，首先，我，呃，记得我已经重置了
memory function, a convenient function that is going to delete the memory down to just two recent things 记忆功能，一个方便的功能，可以将记忆删除到最近的两件事
that got surfaced so that we start fresh. 这件事浮出水面，让我们重新开始。
Um, and then the next thing that I can do is kick off the prices right dot pi by doing a UV run. 嗯，接下来我能做的就是通过 UV 运行来启动正确的点 pi 价格。
And that of course is is going to basically do a Python. 当然，这基本上是用 Python 实现的。
It's going to launch that app so that we can see this user interface together and that, that that is 它将启动该应用程序，以便我们可以一起看到这个用户界面，那就是
what we're going to be doing in the next video. 我们将在下一个视频中做什么。