当前位置: 首页 > news >正文

OpenAI Assistants API:如何使用代码或无需代码创建您自己的AI助手

It's now easier than ever to create your own AI Assistant that can handle a lot of computing tasks for you. See how you can get started with the OpenAI AI Assistant API.

现在比以往任何时候都更容易创建您自己的AI助手,它可以为您处理许多计算任务。了解如何使用OpenAI AI助手API开始操作。

New updates on 17th of April 2024 from OpenAI

来自OpenAI的2024年4月17日最新更新

OpenAI announced significant updates to the Assistants API. The update includes enhancements aimed at improving the capabilities and performance of the assistant.

OpenAI宣布了对Assistants API的重大更新。此次更新包括旨在提高助手功能和性能的改进。

  • Knowledge retrieval now supports up to 10,000 files.  知识检索支持高达10,000个文件
  • More control over token and model configuration.  对令牌和模型配置拥有更多的控制权。
  • Streaming support.   流式传输支持。

It's been a few days since OpenAI's DevDay and lots of interesting features and updates have been announced. Today, we're specifically interested in the new AI Assistant feature. So without further ado, let's get started!

OpenAI的开发者日已经过去几天了,宣布了许多有趣的功能和更新。今天,我们特别关注新的AI助手功能。那么,让我们开始吧!

"You just ask the computer for what you need, and it'll do all of these tasks for you." - Sam Altman - CEO, OpenAI

“你只需要向电脑提出你需要什么,它就会为你完成所有这些任务。”——萨姆·阿尔特曼(Sam Altman),OpenAI 首席执行官

AI Assistants        AI助手

An AI Assistant performs actions based on a given set of instructions and tools. You can think of an AI Assistant as a digital assistant (or agent) that you hire to solve specific problems for your use case.

AI助手根据给定的一组指令和工具来执行操作。你可以将AI助手视为你雇用的数字助手(或代理),用于解决特定用例中的特定问题。

AI Assistants are hosted within the OpenAI platform and use a chosen large language model to think, communicate, and take action.

AI助手托管在OpenAI平台上,并使用选定的大型语言模型进行思考、交流和采取行动。

We're going to see how to create an AI Assistant that reads a PDF file and converts it to a Twitter thread.

我们将学习如何创建一个AI助手,该助手可以读取PDF文件并将其转换为Twitter帖子。

We'll call it X Threads Converter.        我们将它称为“X线程转换器”。

How do I create an AI Assistant?        我如何创建一个AI助手?

There are two ways to do this:        有2种方式

    • Using the OpenAI Web Interface   使用OpenAI的Web界面 
    • Using the OpenAI Assistants API   使用OpenAI Assistants API

Method 1: Using the OpenAI Web Interface        方法1:使用OpenAI的Web界面

For this method, we do not need to write any code since everything will be done using the Web Interface provided by the OpenAI platform.

对于这种方法,我们不需要编写任何代码,因为所有操作都将通过OpenAI平台提供的Web界面来完成。

Let's go ahead and create our X Threads Converter AI Assistant using the Web Interface. Follow the steps below:

让我们继续使用Web界面来创建我们的X线程转换器AI助手。请按照以下步骤操作:

Step 1: Log into your OpenAI account        登录openai 账号
Step 2: On the left side navigation bar, you'll see the new Assistants tab:

步骤2:在左侧的导航栏中,您将看到新的“助手”选项卡:

Step 3: Click on the Assistants tab:        点击 助手 页签

As you can see, I don't have any assistants yet. We're going to create a new one.

如您所见,我还没有任何助手。我们将创建一个新的。

Step 4: Click on Create. You'll see the following options:

步骤4:点击“创建”。您将看到以下选项:

To create a new assistant, we'll need to enter the following:

要创建一个新的助手,我们需要输入以下内容:

  • Name: Let's call it X Threads Converter.    名称:让我们将其命名为“X线程转换器”。
  • Instructions: Use the following instructions: "You are a helpful assistant. Given a set of files, you extract the most interesting information and restructure it into Threads format for Twitter."

指令:使用以下指令:“你是一个有用的助手。给定一组文件,你提取最有趣的信息,并将其重新组织成Twitter帖子串的格式。”

  • Model: Select one of the supported OpenAI models. I will choose the new gpt-4-1106-preview model.

模型:选择支持的OpenAI模型之一。我将选择新的gpt-4-1106-preview模型。

  • Tools: We're just going to enable Retrieval for this example. This is because our assistant will need to retrieve the contents from the uploaded files.

工具:对于这个示例,我们只需要启用检索功能。这是因为我们的助手需要从上传的文件中检索内容。

  • Files: You can upload any supported file here. I uploaded a PDF version of this post. If you want to do the same, just open the link in your browser and save it as PDF.

文件:您可以在此处上传任何支持的文件。我上传了这篇帖子的PDF版本。如果您也想这样做,只需在浏览器中打开链接并将其保存为PDF即可。

Step 5: Click on Save. Your configuration should look like this:

步骤5:点击“保存”。您的配置应该如下所示:

That's it! Go ahead and click on the Save button. Our X Threads Converter will be ready in a few seconds.

就是这样!继续并点击“保存”按钮。我们的X线程转换器将在几秒钟内准备就绪。

Step 6: Try it out in the Playground:        步骤6:在测试区尝试一下:

Click on the "Test in Playground" button. The Playground is a chat interface where you can test and optimize your Assistant.

点击“在测试区测试”按钮。测试区是一个聊天界面,您可以在其中测试和优化您的助手。

Let's ask our shiny new assistant to "Create the X Threads Post" click "Add and run" and see what happens.

让我们向这个闪亮的新助手发出“创建X Threads帖子”的请求,点击“添加并运行”,看看会发生什么。

The AI Assistant will take a few seconds to think and process your request.

AI助手会花几秒钟的时间来思考和处理您的请求。

Behind the scenes, the following is happening:

在幕后,正在发生以下事情:

  1. The contents of the PDF are converted to Vector Embeddings

PDF的内容被转换为向量嵌入(Vector Embeddings)

  • Our Vector Embeddings are stored in a Vector Database

我们的向量嵌入(Vector Embeddings)被存储在向量数据库中。

  • The Query is used to find relevant and similar embeddings

查询用于查找相关和相似的嵌入

  • The relevant parts are sent to the chosen large language model

相关的部分被发送到所选的大型语言模型

  • The LLM will process and return the final output

大型语言模型(LLM)将处理并返回最终输出

You should end up with something like this:

您应该会得到类似这样的结果:

X Threads Converter        X 线程转换器

Based on the text extracted from the uploaded PDF, I will create a Twitter thread format for you. However, due to the length limitations of Twitter posts (280 characters each), the thread will summarize the content in concise tweets.

基于从上传的PDF中提取的文本,我将为您创建Twitter线程格式。但是,由于Twitter帖子的长度限制(每条280个字符),线程将以简洁的推文形式总结内容。

That's impressive! In no time we were able to build an assistant that can create a Twitter Thread given any PDF file. More importantly, we wrote exactly zero lines of code.

太令人印象深刻了!我们很快就构建了一个助手,可以根据任何PDF文件创建Twitter线程。更重要的是,我们一行代码都没有写。

Method 2: Using the OpenAI Assistants API        方法2:使用OpenAI助手API

Let's go ahead and create our X Threads Converter AI Assistant using the OpenAI Assistants API:

让我们继续使用OpenAI助手API来创建我们的X Threads Converter AI助手:

Step 1: Install the Official OpenAI Python SDK        步骤1:安装官方OpenAI Python SDK

In your terminal, type the below and hit return:        在您的终端中,输入以下命令并按下回车键:

pip install openai

To verify that the OpenAI SDK has been successfully installed, run the following command:

为了验证OpenAI SDK已成功安装,请运行以下命令:

pip show openai
Step 2: Import Required Packages        步骤2:导入所需的包

Great, now we can create a new directory for our project. In your terminal type the following commands:

很好,现在我们可以为我们的项目创建一个新目录。在您的终端中输入以下命令:

  • Create a new directory: mkdir openai-ai-assistant-demo

创建一个新目录:mkdir openai-ai-assistant-demo

  • cd into the new directory and create assistant.py file: cd openai-ai-assistant-demo && touch assistant.py

进入新目录并创建assistant.py文件:cd openai-ai-assistant-demo && touch assistant.py

  • Open the assistant.py file and import the OpenAI SDK

打开assistant.py文件并导入OpenAI SDK

from openai import OpenAI
Step 3: Create the OpenAI Client        步骤3:创建OpenAI客户端

We'll now create the OpenAI client. Make sure to replace with your own OpenAI API Key.

现在我们将创建OpenAI客户端。请确保使用您自己的OpenAI API密钥进行替换。

client = OpenAI(api_key="YOUR_API_KEY",
)
Step 4: Prepare the PDF File for Upload        步骤4:准备PDF文件以进行上传

Next, place the PDF file in the openai-ai-assistant-demo directory. In my case, the file name is document.pdf.

接下来,将PDF文件放在openai-ai-assistant-demo目录中。在我的情况下,文件名是document.pdf。

Let's create the file using the OpenAI SDK using client.files.create:

让我们使用client.files.create通过OpenAI SDK创建文件:

file = client.files.create(file=open("document.pdf", "rb"),purpose='assistants'
)file_id = file.id

Here, we specify the purpose property as 'assistants' so that the file becomes accessible by the Assistants API.

在这里,我们将purpose属性指定为'assistants',以便文件可通过助手API进行访问。

Step 5: Define the Required AI Assistant Tools        步骤5:定义所需的AI助手工具

We create our tools variable which is a list of required tools that the AI Assistant will have access to. In this case, we only need the retrieval tool.

我们创建一个名为“tools”的变量,它是一个列表,包含AI助手可以访问的所需工具。在这种情况下,我们只需要检索工具。

tools = [{"type": "retrieval"}
]

Step 6: Create our AI Assistant using client.beta.assistants.create:

步骤6:使用client.beta.assistants.create创建我们的AI助手:

Finally, we'll use the client.beta.assistants.create and pass the following parameters:

最后,我们将使用client.beta.assistants.create并传递以下参数:

assistant = client.beta.assistants.create(name="X Threads Converter",instructions="You are a helpful assistant. Given a set of files, you extract the most interesting information and restructure it into Threads format for Twitter.",model="gpt-4-1106-preview",tools=tools,file_ids=[file.id]
)assistant_id = assistant.id

The values used in the above code are exactly the same as the ones used to create the AI Assistant using the web interface in the previous example (Method 1).

上述代码中使用的值与在前面的示例(方法1)中使用网页界面创建AI助手时使用的值完全相同。

Step 7: Run the Code        步骤7:运行代码

To create our X Threads Converter AI Assistant, execute the assistant.py file:

创建我们的X Threads Converter AI助手,执行assistant.py文件:

python assistant.py

Once done, refresh the Assistants page​ and we can see our new X Threads Converter AI Assistant in the Assistants list.

一旦完成,刷新助手页面,我们就可以在助手列表中看到我们新的X Threads Converter AI助手了。

Once AI Assistant is up and running. We can take it for a spin in the Playground just like we did in Method 1.

一旦AI助手启动并运行。我们可以像在方法1中一样,在测试场上试用它。

How do I Use an AI Assistant?        我如何使用AI助手?

The Playground provided by OpenAI is a great tool to test our AI Assistant quickly. But, how do you actually use the AI Assistant using the API?

OpenAI提供的测试场是一个快速测试我们的AI助手的绝佳工具。但是,你如何实际使用API来使用AI助手呢?

Let's explore how AI Assistants work and go over two important concepts: Threads and Runs.

让我们探索AI助手是如何工作的,并介绍两个重要的概念:线程和运行。

What are Threads?        什么是线程?

Each thread represents a conversation. A thread contains a list of messages each belonging to the user and the large language model.

每个线程都代表一次对话。一个线程包含一系列消息,这些消息分别属于用户和大型语言模型。

That conversation with your spouse on WhatsApp? That's a thread.

你在WhatsApp上与配偶的对话?那就是一个线程。

The task we want to send to our assistant: "Create the X Threads Post." is represented as a message within a thread.

我们想要发送给助手的任务:“创建X Threads帖子。”在线程中表示为一条消息。

What are Runs?        什么是运行?

A Run represents the execution of a thread. A Run also needs to know which AI Assistant to use for that execution. Once initialized, the Run will determine which steps are needed to complete the task.

一个“运行”表示一个线程的执行。一个“运行”还需要知道应该使用哪个AI助手来执行这个任务。一旦初始化,“运行”将确定完成该任务需要哪些步骤。

To create a run we'll need to supply the thread_id and assistant_id parameters.

要创建一个运行,我们需要提供thread_id和assistant_id参数。

Creating a Thread        创建一个线程

To create a Thread, we'll need to initialize it with a list of messages. For our example, there's only one message, which is: "Create the X Threads Post.".

要创建一个线程,我们需要用消息列表来初始化它。对于我们的示例,只有一条消息,即:“Create the X Threads Post.”。

Since our AI Assistant needs to process data from a PDF file, we'll also need to specify the file that it needs to use. We can find the file id on this page. Alternatively, the id property is accessible after you initialize the file object in Step 4 by calling file.id.

由于我们的AI助手需要处理PDF文件中的数据,我们还需要指定它需要使用哪个文件。我们可以在这个页面上找到文件ID。或者,在步骤4中初始化文件对象后,通过调用file.id也可以访问id属性。

Let's create our thread using client.beta.threads.create:

让我们使用client.beta.threads.create来创建我们的线程:

thread = client.beta.threads.create(messages=[{"role": "user","content": "Create the X Thread Post.","file_ids": [file_id]}]
)thread_id = thread.id

We'll need the thread_id property below when creating the Run.

在创建“运行”时,我们需要使用下面的thread_id属性。

Creating a Run        创建一个运行

Let's create our Run using the client.beta.threads.runs.create method:

让我们使用client.beta.threads.runs.create方法来创建我们的“运行”:

run = client.beta.threads.runs.create(thread_id=thread_id,assistant_id=assistant_id
)run_id = run.id

The assistant_id could be accessed using the id property after the assistant variable is created in Step 6.

 在步骤6中创建助手(assistant)变量后,可以通过访问其id属性来获取assistant_id。

Note: Using the API, you can retrieve all required IDs. For instance, the assistant_id could be retrieved by listing all the assistants and choosing the correct one using the client.beta.assistants.list method. 

注意:通过API,您可以检索所有必需的ID。例如,可以通过列出所有助手并选择正确的一个,使用client.beta.assistants.list方法来检索assistant_id。

Checking Run Status        检查运行状态

Our run will take a few seconds to complete. This is because the AI Assistant needs to determine the steps needed to complete the task. It also needs to process, store, and retrieve information from the PDF file and talk to the LLM for further processing.

我们的运行将需要几秒钟来完成。这是因为AI助手需要确定完成任务所需的步骤。它还需要处理、存储和从PDF文件中检索信息,并与LLM(大型语言模型)进行通信以进行进一步处理。

When using other tools such as the code_interpreter the Run may take even more time as it generates and runs Python code iteratively.

当使用其他工具(如code_interpreter)时,运行可能需要更长时间,因为它会迭代地生成和运行Python代码。

Therefore, we'll need to periodically check if the Run is completed. We can do this by checking its status property by calling the client.beta.threads.runs.retrieve method, as shown below:

因此,我们需要定期检查运行是否已完成。我们可以通过调用client.beta.threads.runs.retrieve方法来检查其状态属性,如下所示:

run = client.beta.threads.runs.retrieve(thread_id=thread_id,run_id=run_id
)

Once the status property changes to completed, we can see the model's response by retrieving the messages within our thread:

一旦状态属性更改为“已完成”,我们就可以通过检索线程中的消息来查看模型的响应:

thread_messages = client.beta.threads.messages.list(thread_id)
print(thread_messages.data)

Closing thoughts        总结

As we've seen, this should get you up and running with the new OpenAI AI Assistants in no time. It is now easier than ever to create your AI Assistant that can help you perform a variety of tasks useful to your business.

正如我们所见,这将使您很快上手新的OpenAI AI助手。现在比以往任何时候都更容易创建AI助手,帮助您执行各种对业务有用的任务。

You may also want to think about the fact that your application will be locked into the OpenAI platform. This means that if you decide to migrate to another LLM, storage, and vector database at a later time it may not be a simple task.

您可能还需要考虑到,您的应用程序将被锁定在OpenAI平台上。这意味着如果您决定在将来迁移到另一个大型语言模型(LLM)、存储和向量数据库,这可能不是一项简单的任务。

 

 

相关文章:

OpenAI Assistants API:如何使用代码或无需代码创建您自己的AI助手

Its now easier than ever to create your own AI Assistant that can handle a lot of computing tasks for you. See how you can get started with the OpenAI AI Assistant API. 现在比以往任何时候都更容易创建您自己的AI助手,它可以为您处理许多计算任务。了…...

CentOS7 配置Nginx域名HTTPS

Configuring Nginx with HTTPS on CentOS 7 involves similar steps to the ones for Ubuntu, but with some variations in package management and service control. Here’s a step-by-step guide for CentOS 7: Prerequisites Domain Name: “www.xxx.com”Nginx Install…...

C++入门8 构造函数析构函数顺序|拷贝构造

一&#xff0c;构造函数析构函数 调用顺序 我们先来看下面的代码&#xff1a; #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstring> using namespace std; class student { public:char my_name[20];int my_id;student(int a) {my_id a;co…...

【git使用四】git分支理解与操作(详解)

目录 &#xff08;1&#xff09;理解git分支 主分支&#xff08;主线&#xff09; 功能分支 主线和分支关系 将分支合并到主分支 快速合并 非快速合并 git代码管理流程 &#xff08;2&#xff09;理解git提交对象 提交对象与commitID Git如何保存数据 示例讲解 &a…...

【docker】如何解决artalk的跨域访问问题

今天折腾halo的时候&#xff0c;发现artalk出现跨域访问报错&#xff0c;内容如下。 Access to fetch at https://artk.musnow.top/api/stat from origin https://halo.musnow.top has been blocked by CORS policy: The Access-Control-Allow-Origin header contains multipl…...

MYSQL 索引下推 45讲

刘老师群里,看到一位小友 问<MYSQL 45讲>林晓斌的回答 大意是一个组合索引 (a,b,c) 条件 a > 5 and a <10 and b123, 这样的情况下是如何? 林老师给的回答是 A>5 ,然后下推B123 小友 问 "为什么不是先 进行范围查询,然后在索引下推 b123?" 然后就…...

CentOS7服务器中安装openCV4.8的教程

参考链接&#xff1a;Centos7环境下cmake3.25的编译与安装 参考链接&#xff1a;Linux安装或者升级cmake&#xff0c;例子为v3.10.2升级到v3.25.0(自己指定版本) 参考链接&#xff1a;Linux安装Opencv&#xff08;C&#xff09; 一、下载资源 1.下载cmake3.25.0的压缩包&am…...

Java课程设计:基于swing的贪吃蛇小游戏

文章目录 一、项目介绍二、核心代码三、项目展示四、源码获取 一、项目介绍 贪吃蛇是一款经典的休闲益智游戏,自问世以来便深受广大用户的喜爱。这个游戏的基本玩法是控制一条不断增长的蛇,目标是吃掉屏幕上出现的食物,同时避免撞到边缘或自身。随着游戏的进行,蛇的身体会越长…...

【HarmonyOS】HUAWEI DevEco Studio 下载地址汇总

目录 OpenHarmony 4.x Releases 4.1 Release4.0 Release OpenHarmony 3.x Releases 3.2.1 Release3.2 Release3.1.3 Release3.1.2 Release3.1.1 Release3.1 Release 说明 Full SDK&#xff1a;面向OEM厂商提供&#xff0c;包含了需要使用系统权限的系统接口。 Public SDK&am…...

华为OD刷题C卷 - 每日刷题30(小明找位置,分隔均衡字符串)

1、&#xff08;小明找位置&#xff09;&#xff1a; 这段代码是解决“小明找位置”的问题。它提供了一个Java类Main&#xff0c;其中包含main方法和getResult方法&#xff0c;用于帮助小明快速找到他在排队中应该站的位置。 main方法首先读取已排列好的小朋友的学号数组和小…...

SOFTS: 时间序列预测的最新模型以及Python使用示例

近年来&#xff0c;深度学习一直在时间序列预测中追赶着提升树模型&#xff0c;其中新的架构已经逐渐为最先进的性能设定了新的标准。 这一切都始于2020年的N-BEATS&#xff0c;然后是2022年的NHITS。2023年&#xff0c;PatchTST和TSMixer被提出&#xff0c;最近的iTransforme…...

C++ 取近似值

描述 写出一个程序&#xff0c;接受一个正浮点数值&#xff0c;输出该数值的近似整数值。如果小数点后数值大于等于 0.5 ,向上取整&#xff1b;小于 0.5 &#xff0c;则向下取整。 数据范围&#xff1a;保证输入的数字在 32 位浮点数范围内 输入描述&#xff1a; 输入一个正…...

云原生系列之Docker常用命令

&#x1f339;作者主页&#xff1a;青花锁 &#x1f339;简介&#xff1a;Java领域优质创作者&#x1f3c6;、Java微服务架构公号作者&#x1f604; &#x1f339;简历模板、学习资料、面试题库、技术互助 &#x1f339;文末获取联系方式 &#x1f4dd; 系列文章目录 云原生之…...

opencv_GUI

图像入门 import numpy as np import cv2 as cv # 用灰度模式加载图像 img cv.imread(C:/Users/HP/Downloads/basketball.png, 0)# 即使图像路径错误&#xff0c;它也不会抛出任何错误&#xff0c;但是打印 img会给你Nonecv.imshow(image, img) cv.waitKey(5000) # 一个键盘绑…...

FlowUs轻量化AI:趁这波升级专业版,全年无限AI助力笔记产出与二次编写

在数字时代&#xff0c;信息管理与知识产出的效率直接影响个人的生产力。FlowUs作为一款集笔记、文档、多维表、文件夹于一体的新一代知识管理平台&#xff0c;其轻量化AI的加入更是如虎添翼。特别是在活动期间&#xff0c;升级专业版将带来全年无限AI使用次数&#xff0c;让每…...

Day 22:2786. 访问数组中的位置使分数最大

Leetcode 2786. 访问数组中的位置使分数最大 给你一个下标从 0 开始的整数数组 nums 和一个正整数 x 。 你 一开始 在数组的位置 0 处&#xff0c;你可以按照下述规则访问数组中的其他位置&#xff1a; 如果你当前在位置 i &#xff0c;那么你可以移动到满足 i < j 的 任意 …...

理解Es的DSL语法(二):聚合

前一篇已经系统介绍过查询语法&#xff0c;详细可直接看上一篇文章&#xff08;理解DSL语法&#xff08;一&#xff09;&#xff09;&#xff0c;本篇主要介绍DSL中的另一部分&#xff1a;聚合 理解Es中的聚合 虽然Elasticsearch 是一个基于 Lucene 的搜索引擎&#xff0c;但…...

matlab-2-simulink-小白教程-如何绘制电路图进行电路仿真

以上述电路图为例&#xff1a;包含D触发器&#xff0c;时钟CLK,与非门 一、启动simulink的三种方式 方式1 在MATLAB的命令行窗口输入“Simulink”命令。 方式2 在MATLAB主窗口的“主页”选项卡中&#xff0c;单击“SIMULINK”命令组中的Simulink命令按钮。 方式3 从MATLAB…...

CSS从入门到精通——背景样式

目录 背景颜色 任务描述 相关知识 背景色 编程要求 背景图片 任务描述 相关知识 背景图片 设置背景图片 平铺背景图像 任务要求 背景定位与背景关联 任务描述 相关知识 背景定位 背景关联 简写背景 编程要求 背景颜色 任务描述 本关任务&#xff1a;在本关…...

网络编程---Java飞机大战联机

解析服务器端代码 代码是放在app/lib下的src下的main/java&#xff0c;而与之前放在app/src/main下路径不同 Main函数 Main函数里只放着创建MyServer类的一行 public static void main(String args[]){new MyServer();} MyServer构造函数 1.获取本机IP地址 //获取本机IP地…...

一个简单的Oracle函数

CREATE OR REPLACE FUNCTION getyj_zhibiao_value(p_name IN varchar2, p_index IN varchar2) RETURN NUMBER IS -- 定义返回的指标值变量 v_result NUMBER; -- 定义临时变量来存储查询到的指标值 v_index1 VARCHAR2(50); v_index2 VARCHAR2(50); …...

word中根据上级设置下级编号

如上级是3.13.4&#xff0c;如下图 现在想设置下级编码跟随上级逐级显示成3.13.4.1 则在标题功能说明这点击顶部菜单栏的编号按钮&#xff0c;如下图 然后&#xff0c;选择自定义编号-自定义列表-自定义按钮 然后重点是编号格式这一栏&#xff0c;需要手动填写下前三级的编号&…...

【康复学习--LeetCode每日一题】2786. 访问数组中的位置使分数最大

题目描述&#xff1a; 给你一个下标从 0 开始的整数数组 nums 和一个正整数 x 。 你一开始 在数组的位置 0 处&#xff0c;你可以按照下述规则访问数组中的其他位置&#xff1a; 如果你当前在位置 i &#xff0c;那么你可以移动到满足 i < j 的 任意 位置 j 。 对于你访问的…...

bash和sh区别

bash 和 sh 是两种常用的 Unix Shell&#xff0c;它们有一些区别&#xff0c;特别是在功能和兼容性方面。以下是一些主要的区别&#xff1a; 1. **历史与实现**&#xff1a; - sh&#xff08;Bourne Shell&#xff09;是第一个 Unix Shell&#xff0c;最初由 Stephen Bourn…...

Git 代码管理规范 !

分支命名 master 分支 master 为主分支&#xff0c;也是用于部署生产环境的分支&#xff0c;需要确保master分支稳定性。master 分支一般由 release 以及 hotfix 分支合并&#xff0c;任何时间都不能直接修改代码。 develop 分支 develop 为开发环境分支&#xff0c;始终保持最…...

MGRS坐标

一 概述 MGRS坐标系统&#xff0c;即军事格网参考系统&#xff0c;是北约(NATO)军事组织使用的标准坐标系统。它基于UTM&#xff08;通用横向墨卡托&#xff09;系统&#xff0c;并将每个UTM区域进一步划分为100km100km的小方块。这些方块通过两个相连的字母标识&#xff0c;其…...

FreeRTOS简单内核实现4 临界段

文章目录 0、思考与回答0.1、思考一0.2、思考二0.3、思考三 1、关中断1.1、带返回值1.2、不带返回值 2、开中断3、临界段4、应用 0、思考与回答 0.1、思考一 为什么需要临界段&#xff1f; 有时候我们需要部分代码一旦这开始执行&#xff0c;则不允许任何中断打断&#xff0…...

Scala的字符串插值

Scala的字符串插值 期待您的关注 ☀Scala学习笔记 目录 Scala的字符串插值 1. s插值器&#xff1a; 2. f插值器&#xff1a; 3. raw插值器&#xff1a; 在Scala中&#xff0c;字符串插值是一种方便的方式&#xff0c;可以在字符串中插入变量或表达式的值。Scala支持三种类型…...

EasyGBS服务器和终端配置

服务器配置 修改easygbs.ini sip/host为本机IP&#xff0c;否则终端能登录&#xff0c;无法视频。 [sip] host192.168.3.190 终端用于登录的用户名和密码 default_usertest default_passwordtest1234 default_guest_userguest default_guest_passwordtest1234终端配置 关…...

git配置2-不同的代码托管平台配置不同的ssh key

1. 配置单个ssh key 1.1. 原理1.2. 生成 ssh key1.3. 代码托管平台配置公钥 2. 配置多个ssh key 2.1. 应用场景2.2. 生成两个不同的key2.3. 修改config文件2.4. 配置代码托管平台2.5. 测试是否成功 1. 配置单个ssh key 1.1. 原理 使用ssh命令行工具&#xff08;git安装成功…...