As another cute feature to know about Gradio forget, forget sharing. 作为了解 Gradio 的另一个可爱功能，忘记，忘记分享。
We won't come back to that. 我们不会再讨论这个了。
You can use that as you wish, but something just when you're running it locally is that you can call 您可以根据需要使用它，但是当您在本地运行它时，您可以调用
this thing in-browser equals true. 浏览器中的这件事等于 true。
And all that does is it means when you when you run this, it instantly pops up the browser window. 这意味着当您运行它时，它会立即弹出浏览器窗口。
It's just convenient if you're always going to be working in a browser window, not in your notebook. 如果您总是要在浏览器窗口而不是笔记本中工作，这会很方便。
In browser equals true means it pops one up locally instantly so that you can, uh, um, immediately 在浏览器中等于 true 意味着它会立即在本地弹出一个，这样你就可以，呃，嗯，立即
get your user interface running. 让您的用户界面运行。
And there we have it. 现在我们就有了。
Super easy. 超级简单。
And Gradio also makes it very easy for you to add user ID password login to your app. Gradio 还使您可以非常轻松地将用户 ID 密码登录添加到您的应用程序中。
Particularly perhaps if you're using share equals true, that might be a good thing to think about. 特别是如果您使用 share equals true，这可能是一件值得考虑的好事情。
Uh, this is how you do it in that in that call to launch, you just also add in auth equals and then 呃，这就是您在启动调用中执行此操作的方法，您还只需添加 auth equals ，然后
you can put in a user ID and password in a tuple like this. 您可以将用户 ID 和密码放入这样的元组中。
And as the user ID and bananas as the password, say not my password anywhere else. 并作为用户ID和banana作为密码，不要在其他地方说我的密码。
In case you're wondering, uh, there we have it. 如果你想知道，呃，我们有。
Um, and you can also, instead of passing in just one user ID and password, you can pass in a list 嗯，您还可以传入一个列表，而不是只传入一个用户 ID 和密码
of user ID and password tuples. 用户 ID 和密码元组。
A whole list of them and all those people will be able to log in. 他们的完整列表以及所有这些人都将能够登录。
What do I mean? 我是什么意思？
Well, if I run this, up comes my Gradio app and now it has a login and password. 好吧，如果我运行这个，我的 Gradio 应用程序就会出现，现在它有一个登录名和密码。
And if I type add and I type in any old thing there and I do log in, it's going to say invalid credentials. 如果我输入 add 并在那里输入任何旧内容并登录，则会显示无效凭据。
Up comes my password manager. 我的密码管理器出现了。
Try that again. 再试一次。
Add bananas and in we go. 添加香蕉，然后开始。
We are logged in now to the app. 我们现在已登录该应用程序。
I can say hi there and I can press submit. 我可以在那里打个招呼，然后按提交。
And it works. 它有效。
We have authentication. 我们有认证。
And obviously back in cursor we can see that it called the shout function. 显然，回到光标处我们可以看到它调用了shout函数。
Now before you all email me at once, I know perfectly well you should not ever have passwords in plain 现在，在你们立即给我发电子邮件之前，我非常清楚你们不应该拥有简单的密码
text like that. 像那样的文字。
At a very minimum, you could use your env file if you wanted to have some passwords there, but of 如果您想在其中设置一些密码，至少可以使用您的 env 文件，但是
course it would be recommended to use something proper, like a proper security database and maybe even 当然，建议使用适当的东西，例如适当的安全数据库，甚至可能
some sort of hashing system. 某种哈希系统。
You can google any of that should you wish. 如果你愿意的话，你可以用谷歌搜索其中任何一个。
But as a quick way to add in authentication, this shows you how easy it is. 但作为添加身份验证的快速方法，这向您展示了它是多么容易。
And if you have share equals true so that you're giving the outside world the ability to come in and 如果你有分享就等于真实，这样你就给了外界进来的能力
run things you might well want to put in authentication. 运行您可能想要放入身份验证的内容。
It couldn't be easier. 这再简单不过了。
Okay, let's move on. 好吧，我们继续吧。
You can tell I like gradio. 你可以看出我喜欢渐变。
Uh, the one more thing is that I've been showing you all these screens. 呃，还有一件事是我已经向你们展示了所有这些屏幕。
They've been coming up in dark mode for me because that's my default on my system. 它们一直以深色模式出现，因为这是我系统上的默认设置。
You might have been seeing a light mode version. 您可能已经看到了轻型模式版本。
Now, if you want, you can force Gradio to bring up the user interface in dark mode. 现在，如果您愿意，您可以强制 Gradio 以深色模式显示用户界面。
Actually, Gradio advises against this, and they don't make it easy because they point out that it's 事实上，Gradio 建议不要这样做，而且他们并没有让这件事变得容易，因为他们指出这是
important for accessibility reasons that you respect the user's choice for light mode or dark mode, 出于可访问性的原因，您尊重用户对浅色模式或深色模式的选择很重要，
but should you wish to, this is how you can do it. 但如果您愿意，也可以这样做。
You can write some JavaScript, you can pass in that JavaScript, and then it will always be in dark 你可以写一些 JavaScript，你可以传入该 JavaScript，然后它就永远是黑暗的
mode. 模式。
And here it is in dark mode every time. 而且这里每次都是深色模式。
And in fact, I can show you that again by by actually making it light mode instead. 事实上，我可以通过实际将其设置为浅色模式来再次向您展示这一点。
Uh, let me just change this. 呃，让我改变一下这个。
I change that word dark to light. 我把这个词“暗”改为“亮”。
I believe now it should be in light mode. 我相信现在它应该处于轻型模式。
There we go. 我们开始吧。
Bam! 嘭！
Ha ha! 哈哈！
This is what it may have looked like already for you. 这对你来说可能已经是这个样子了。
The light mode version of it. 它的灯光模式版本。
I say hi there, submit. 我在那里打个招呼，提交。
And there it is in capitals. 这是在首都。
So that is the light mode variation. 这就是光模式的变化。
I will put this back to dark. 我会把它放回黑暗。
Uh. 呃。
There we have it. 我们就有了。
And back to dark mode. 并返回黑暗模式。
So, uh, you can switch between dark mode and light mode. 所以，呃，你可以在深色模式和浅色模式之间切换。
But as I say, Gradio recommends that you leave it be. 但正如我所说，Gradio 建议您不要管它。
Let the user decide. 让用户决定。
Respect the user's choice on that. 尊重用户对此的选择。
Okay. 好的。
Now we're just going to take this user interface a little bit further. 现在我们将进一步改进这个用户界面。
And so there's a little bit of a block of code here. 所以这里有一些代码块。
But it's all going to be super sensible I hope it's not going to surprise you at all. 但这一切都将是非常明智的，我希望它不会让你感到惊讶。
Uh, we can choose to specify explicitly the fields that will appear on our user interface. 呃，我们可以选择明确指定将出现在用户界面上的字段。
So let's say we want to have an input and an output. 假设我们想要有一个输入和一个输出。
And instead of just going with all of those defaults, we're going to say I want it to be the input 我们不只是使用所有这些默认值，而是说我希望它作为输入
to be a text box. 成为一个文本框。
I want the label to be your message. 我希望标签成为您的信息。
Extra info. 额外信息。
Enter a message to be shouted. 输入要喊出的消息。
Let it have seven lines and then message output will be another text box labeled response with eight 让它有七行，然后消息输出将是另一个文本框，标记为响应八
lines. 线。
And now I can. 现在我可以了。
I can say here that my view is a great interface. 我可以在这里说，我的观点是一个很棒的界面。
The function. 功能。
The callback function I'm going to call will be the word shout. 我要调用的回调函数是“shout”一词。
Let's say you don't need to put function there. 假设您不需要将函数放在那里。
You can just do it like that. 你就可以这样做。
But but we'll leave it in. 但是我们会把它留在里面。
Function is shout. 功能就是喊。
The title of the window will be the word shout. 窗口的标题将是“shout”一词。
The inputs will be this input we've just written right here. 输入将是我们刚刚在这里编写的输入。
The outputs will be this output we've written right there. 输出将是我们在那里编写的输出。
We can give some examples. 我们可以举一些例子。
Hello and howdy. 你好，你好。
And then again this flagging mode is never. 再说一次，这种标记模式永远不会。
You can take that out if you want and you'll see what it does. 如果你愿意的话，你可以把它拿出来，你就会看到它的作用。
It's just an extra little tool that we don't need. 它只是一个我们不需要的额外小工具。
And then view dot launch. 然后查看点启动。
So it's just like spelt out a little bit more. 所以这就像拼写得更多一点。
And when I open it up you can see this nice user interface. 当我打开它时，您可以看到这个漂亮的用户界面。
It's got a heading of shout just as we promised. 正如我们所承诺的那样，它的标题是喊叫。
Message. 信息。
Enter a message to be shouted hi there. 输入要在那里打招呼的消息。
Press submit. 按提交。
Up comes hi there. 上来了，你好。
There you can see it's printed. 在那里你可以看到它被打印出来。
It called the callback down. 它调用了回调。
Here are some examples I can click howdy and it populates with howdy. 以下是一些示例，我可以单击 howdy，它会填充 howdy。
Press submit and there's howdy and there's the print. 按“提交”，然后就会出现“你好”和打印内容。
So it's just a bit tidier, more organized. 所以它更整洁，更有组织。
We're using a little bit less out of the box with Gradio. 我们使用的 Gradio 的开箱即用程度要少一些。
And we're being a bit more explicit about what we want. 我们对我们想要的东西更加明确。
And it shows you how you can have some control. 它向您展示了如何拥有一定的控制权。
Defining radio fields, passing them in in the inputs and outputs, giving some examples, a title, 定义无线电字段，将它们传递到输入和输出中，给出一些示例，标题，
and so on. 等等。
One other thing I will mention, and this might have already caught you off guard, is that when you're 我要提到的另一件事，这可能已经让你措手不及，那就是当你
when you're moving your mouse, if your mouse is hovering over the Gradio interface, it appears that 当您移动鼠标时，如果您的鼠标悬停在 Gradio 界面上，则显示
you suddenly can't scroll up and down if you use your mouse wheel to go up and down. 如果您使用鼠标滚轮上下滚动，您突然无法上下滚动。
And the reason is because it's trying to scroll up and down within within this user interface, you 原因是因为它试图在此用户界面内上下滚动，您
have to move your mouse off to one side, and then you can scroll up and down. 必须将鼠标移到一侧，然后才能上下滚动。
I've had people be stuck with that be like, why can't my why is my mouse working? 我曾经有人被这样的问题困扰过，为什么我的鼠标不能工作？
It's like a cursor thing. 这就像一个光标的东西。
You just have to have your mouse outside the Gradio UI just worth mentioning. 您只需将鼠标放在值得一提的 Gradio UI 之外即可。
All right, so now, now is a big moment of truth for you and it's going to be crazy. 好吧，现在对你来说是一个重要的关键时刻，这将会是疯狂的。
I hope this is going to be like a whoa moment for you. 我希望这对你来说是一个令人惊叹的时刻。
Do you remember what seemed like an age ago, but was in fact just a few minutes ago? 你还记得那件事看似很久以前，但实际上只是几分钟前吗？
At the beginning of this lab, we wrote a function called message GPT. 在本实验开始时，我们编写了一个名为消息 GPT 的函数。
You remember that? 你还记得吗？
Let's go back up and look at it, because I feel like you're like, did we? 让我们回过头来看看它，因为我觉得你就像，是吗？
Yes we did. 是的，我们做到了。
Let me show it to you. 让我给你展示一下。
Blah blah blah all the way back up here. 巴拉巴拉巴拉一路回到这里。
Goodness, it seems like it was a long time ago. 天哪，好像已经是很久以前的事了。
Message GPT, you're a helpful assistant. 留言GPT，你是得力助手。
It takes a message and it. 它需要一条消息。
And it returns the answer. 它返回答案。
It calls GPT on the cloud. 它称为云上的GPT。
Are you with me now? 你现在和我在一起吗？
Okay, so back we go. 好的，我们回去吧。
Uh, so. 呃，所以。
So that was the one that we we we made. 这就是我们自己创造的。
So let's just rewrite exactly the same thing as in the prior cell. 因此，让我们重写与前面的单元格中完全相同的内容。
But we're going to change shout to GP to message GPT a different function. 但我们将更改对 GP 的呼喊，以向 GPT 发送不同的函数消息。
But it's still a function that takes one input and gives one output just like Xiao did. 但它仍然是一个接受一个输入并给出一个输出的函数，就像肖一样。
Just like xiao was a function with an input and an output message, GPT took an input, the prompt and 就像 xiao 是一个有输入和输出消息的函数一样，GPT 也有输入、提示和消息
the output. 输出。
The response. 回应。
That was it. 就是这样。
Nothing else. 没有别的了。
Okay, I'm going to change like the info. 好的，我要更改信息。
I'm going to change the, uh, example. 我要改变这个，呃，例子。
I'm not going to change the examples. 我不会改变这些例子。
Hello and howdy will do just fine. 你好和你好就可以了。
Uh, I'm going to change the title. 呃，我去改一下标题。
Otherwise no change at all. 否则根本没有改变。
Okay. 好的。
Are you with me? 你和我在一起吗？
You see that? 你看到了吗？
Nothing's changed. 什么都没有改变。
Just one callback function. 只有一个回调函数。
Different function. 功能不同。
Otherwise the same. 否则都一样。
Here we go. 开始了。
I'm going to run it. 我要运行它。
And okay, we get an interface that is headed GPT. 好吧，我们得到了一个以 GPT 为标题的界面。
Your message. 您的留言。
Enter a message for GPT mini. 输入 GPT mini 的消息。
We can type, but we can use the one we got right here. 我们可以打字，但我们可以使用我们这里得到的。
Hello. 你好。
Press submit. 按提交。
And hello. 你好。
How can I assist you today? 今天我能为您提供什么帮助？
It just called GPT. 它只是称为 GPT。
It called that function. 它调用了该函数。
It got back an answer. 它得到了答案。
The answer went here. 答案就到这里了。
That's it. 就是这样。
And so you know obviously the point I'm making is that hugging face a gradio has no idea that it just 所以你显然知道我要表达的观点是拥抱渐变的脸并不知道它只是
made a call to GPT. 拨打了 GPT 电话。
As far as it's concerned, it's just another callback function. 就其而言，它只是另一个回调函数。
It happens to be a callback function we've given it that's called GPT. 它恰好是我们给它的一个回调函数，称为 GPT。
It's not called shout. 这不叫叫喊。
It doesn't doesn't care. 它并不关心。
It doesn't even know the name. 它甚至不知道名字。
That's just a variable. 那只是一个变量。
It just calls that function and it doesn't have anything. 它只是调用该函数而没有任何内容。
It doesn't know anything about llms. 它对 llms 一无所知。
It's simply hooks up the input to the output through the submit button. 它只是通过提交按钮将输入连接到输出。
That's all it is. 仅此而已。
That is what's happening here. 这就是这里发生的事情。
So easy. 太容易了。
We've just put an LLM on a user interface. 我们刚刚将法学硕士放在用户界面上。
And now you know how to use like share equals true. 现在您知道如何使用 share equals true 了。
And you can use auth so that you can now have something that logs in. 您可以使用 auth，这样您现在就可以登录了。
And then people are able to connect to GPT just like this. 然后人们就可以像这样连接到 GPT。
Wow. 哇。