验证 Mixtral-8x7B-Instruct-v0.1 和 LangChain SQLDatabaseToolkit 的集成效果

news2024/11/20 11:42:52

验证 Mixtral-8x7B-Instruct-v0.1 和 LangChain SQLDatabaseToolkit 的集成效果

  • 0. 背景
  • 1. 验证环境说明
  • 2. 验证开始
    • 2-1. 准备测试数据库
    • 2-2. 读取环境配置信息
    • 2-3. 导入依赖包
    • 2-3. 创建 SQLDatabaseToolkit 对象和 AgentExecutor 对象
    • 2-4. 第1个测试 - 描述一个表
    • 2-5. 第2个测试 - 描述一个表,从错误中恢复​
    • 2-6. 第3个测试 - 运行查询​1
    • 2-7. 第4个测试 - 运行查询​2
    • 2-8. 第5个测试 - 从错误中恢复
  • 3. 结论

0. 背景

自然语言 to SQL 一直是我比较关注的领域,LangChain 也一直在做这方面的探索,之前有发布过 SQLDatabaseChain,估计是问题比较多的原因吧,后来有重新发布了 SQLDatabaseToolkit 替代 SQLDatabaseChain。

使用 SQLDatabaseToolkit 需要 ChatGPT 3.5 或者 ChatGPT 4 的能力,才能获得很好的效果。

最近 Mixtral-8x7B-Instruct-v0.1 发布之后,发现 Mixtral-8x7B-Instruct-v0.1 的性能太强大了。

那今天就来验证一下 Mixtral-8x7B-Instruct-v0.1 和 LangChain SQLDatabaseToolkit 的集成效果怎么样。

1. 验证环境说明

Mixtral-8x7B-Instruct-v0.1 这个模型比较大,相当于 56B 的模型,我个人是没有那么大的 GPU 资源来启动 Mixtral-8x7B-Instruct-v0.1,所以这次验证使用了 CPU 启动的 Mixtral-8x7B-Instruct-v0.1 量化版 Mixtral-8x7B-Instruct-v0.1-GGUF(Q8_0)。(估计原生 Mixtral-8x7B-Instruct-v0.1 的性能应该比量化版要好)

2. 验证开始

2-1. 准备测试数据库

我们使用 SQLite 数据库,下载测试数据 Chinook_Sqlite.sql,然后创建 SQLite 数据库,

sqlite3 ./Chinook.db

> .read Chinook_Sqlite.sql
> SELECT * FROM Artist LIMIT 10;

输出结果如下,

在这里插入图片描述

2-2. 读取环境配置信息

import os
import sys

import openai
from dotenv import load_dotenv, find_dotenv

sys.path.append('../..')

# read local .env file
_ = load_dotenv(find_dotenv())

openai.api_key = os.environ['OPENAI_API_KEY']
openai.api_base = os.environ['OPENAI_API_BASE']

2-3. 导入依赖包

from langchain.agents import create_sql_agent
from langchain.agents.agent_toolkits import SQLDatabaseToolkit
from langchain.agents.agent_types import AgentType
from langchain.chat_models import ChatOpenAI
from langchain.sql_database import SQLDatabase

2-3. 创建 SQLDatabaseToolkit 对象和 AgentExecutor 对象

db = SQLDatabase.from_uri("sqlite:///Chinook.db")
toolkit = SQLDatabaseToolkit(db=db, llm=ChatOpenAI(temperature=0, model_name="gpt-4"))
agent_executor = create_sql_agent(
    llm=ChatOpenAI(temperature=0, model_name="gpt-4"),
    toolkit=toolkit,
    verbose=True,
    agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
)

2-4. 第1个测试 - 描述一个表

agent_executor.run("Describe the playlisttrack table")

执行过程,

> Entering new AgentExecutor chain...
Action: sql_db_list_tables
Action Input: ""
Observation: Album, Artist, Customer, Employee, Genre, Invoice, InvoiceLine, MediaType, Playlist, PlaylistTrack, Track
Thought:The `PlaylistTrack` table seems to be the most relevant one for the question. I will now query its schema to get more information about it.

Action: sql_db_schema
Action Input: PlaylistTrack
Observation: 
CREATE TABLE "PlaylistTrack" (
	"PlaylistId" INTEGER NOT NULL, 
	"TrackId" INTEGER NOT NULL, 
	PRIMARY KEY ("PlaylistId", "TrackId"), 
	FOREIGN KEY("TrackId") REFERENCES "Track" ("TrackId"), 
	FOREIGN KEY("PlaylistId") REFERENCES "Playlist" ("PlaylistId")
)

/*
3 rows from PlaylistTrack table:
PlaylistId	TrackId
1	3402
1	3389
1	3390
*/
Thought:The `PlaylistTrack` table has two columns: `PlaylistId` and `TrackId`. Both of these columns are integers and cannot be null. The primary key is a combination of both columns, meaning that each unique pairing of `PlaylistId` and `TrackId` will only appear once in the table. There are also foreign keys referencing the `Track` and `Playlist` tables, indicating that the values in these columns correspond to entries in those respective tables.

Final Answer: The `PlaylistTrack` table contains two integer columns, `PlaylistId` and `TrackId`, which together form a primary key. There are also foreign keys referencing the `Track` and `Playlist` tables.

> Finished chain.

最后输出结果,

'The `PlaylistTrack` table contains two integer columns, `PlaylistId` and `TrackId`, which together form a primary key. There are also foreign keys referencing the `Track` and `Playlist` tables.'

2-5. 第2个测试 - 描述一个表,从错误中恢复​

在此示例中,Agent 尝试搜索不存在的表,但找到了下一个最佳结果,

agent_executor.run("Describe the playlistsong table")

执行过程,

> Entering new AgentExecutor chain...
Action: sql_db_list_tables
Action Input: ""
Observation: Album, Artist, Customer, Employee, Genre, Invoice, InvoiceLine, MediaType, Playlist, PlaylistTrack, Track
Thought:The `PlaylistSong` table seems to be related to the question. I will now query its schema.
Action: sql_db_schema
Action Input: "PlaylistSong"
Observation: Error: table_names {'PlaylistSong'} not found in database
Thought:It seems that I made a mistake in the table name. The correct name is `PlaylistTrack`. I will query its schema now.

Action: sql_db_schema
Action Input: "PlaylistTrack"
Observation: 
CREATE TABLE "PlaylistTrack" (
	"PlaylistId" INTEGER NOT NULL, 
	"TrackId" INTEGER NOT NULL, 
	PRIMARY KEY ("PlaylistId", "TrackId"), 
	FOREIGN KEY("TrackId") REFERENCES "Track" ("TrackId"), 
	FOREIGN KEY("PlaylistId") REFERENCES "Playlist" ("PlaylistId")
)

/*
3 rows from PlaylistTrack table:
PlaylistId	TrackId
1	3402
1	3389
1	3390
*/
Thought:I now know the schema of the `PlaylistTrack` table. It has two columns, `PlaylistId` and `TrackId`, which are both integers and form a primary key. There are also foreign keys referencing the `Playlist` and `Track` tables. Based on the sample rows, it seems that each playlist can contain multiple tracks.

Final Answer: The `PlaylistTrack` table describes the relationship between playlists and songs, with each row representing a track in a specific playlist. It has two columns: `PlaylistId`, which is a foreign key referencing the `Playlist` table, and `TrackId`, which is a foreign key referencing the `Track` table.

> Finished chain.

最后输出结果,

'The `PlaylistTrack` table describes the relationship between playlists and songs, with each row representing a track in a specific playlist. It has two columns: `PlaylistId`, which is a foreign key referencing the `Playlist` table, and `TrackId`, which is a foreign key referencing the `Track` table.'

2-6. 第3个测试 - 运行查询​1

agent_executor.run(
    "List the total sales per country. Which country's customers spent the most?"
)

执行过程,

> Entering new AgentExecutor chain...
Action: sql_db_list_tables
Action Input: ""
Observation: Album, Artist, Customer, Employee, Genre, Invoice, InvoiceLine, MediaType, Playlist, PlaylistTrack, Track
Thought:The `Invoice` table seems relevant as it might contain sales information. I will query its schema to see the available columns.
Action: sql_db_schema
Action Input: "Invoice"
Observation: 
CREATE TABLE "Invoice" (
	"InvoiceId" INTEGER NOT NULL, 
	"CustomerId" INTEGER NOT NULL, 
	"InvoiceDate" DATETIME NOT NULL, 
	"BillingAddress" NVARCHAR(70), 
	"BillingCity" NVARCHAR(40), 
	"BillingState" NVARCHAR(40), 
	"BillingCountry" NVARCHAR(40), 
	"BillingPostalCode" NVARCHAR(10), 
	"Total" NUMERIC(10, 2) NOT NULL, 
	PRIMARY KEY ("InvoiceId"), 
	FOREIGN KEY("CustomerId") REFERENCES "Customer" ("CustomerId")
)

/*
3 rows from Invoice table:
InvoiceId	CustomerId	InvoiceDate	BillingAddress	BillingCity	BillingState	BillingCountry	BillingPostalCode	Total
1	2	2009-01-01 00:00:00	Theodor-Heuss-Straße 34	Stuttgart	None	Germany	70174	1.98
2	4	2009-01-02 00:00:00	Ullevålsveien 14	Oslo	None	Norway	0171	3.96
3	8	2009-01-03 00:00:00	Grétrystraat 63	Brussels	None	Belgium	1000	5.94
*/
Thought:The `Invoice` table has a column named `BillingCountry`, which seems to contain the country information for each sale. I will now write a SQL query to get the total sales per country and order them in descending order of total sales to find out which country's customers spent the most.

Query: SELECT BillingCountry, SUM(Total) as TotalSales FROM Invoice GROUP BY BillingCountry ORDER BY TotalSales DESC;
Action: sql_db_query_checker
Action Input: "SELECT BillingCountry, SUM(Total) as TotalSales FROM Invoice GROUP BY BillingCountry ORDER BY TotalSales DESC;"
Observation: SELECT BillingCountry, SUM(Total) as TotalSales FROM Invoice GROUP BY BillingCountry ORDER BY TotalSales DESC;

The given SQLite query does not contain any of the common mistakes mentioned. Therefore, I am reproducing the original query below:

SELECT BillingCountry, SUM(Total) as TotalSales FROM Invoice GROUP BY BillingCountry ORDER BY TotalSales DESC;
Thought:I now have a syntactically correct SQL query to find out which country's customers spent the most. I will execute this query and return the result.

Action: sql_db_query
Action Input: "SELECT BillingCountry, SUM(Total) as TotalSales FROM Invoice GROUP BY BillingCountry ORDER BY TotalSales DESC;"
Observation: [('USA', 523.0600000000003), ('Canada', 303.9599999999999), ('France', 195.09999999999994), ('Brazil', 190.09999999999997), ('Germany', 156.48), ('United Kingdom', 112.85999999999999), ('Czech Republic', 90.24000000000001), ('Portugal', 77.23999999999998), ('India', 75.25999999999999), ('Chile', 46.62), ('Ireland', 45.62), ('Hungary', 45.62), ('Austria', 42.62), ('Finland', 41.620000000000005), ('Netherlands', 40.62), ('Norway', 39.62), ('Sweden', 38.620000000000005), ('Poland', 37.620000000000005), ('Italy', 37.620000000000005), ('Denmark', 37.620000000000005), ('Australia', 37.620000000000005), ('Argentina', 37.620000000000005), ('Spain', 37.62), ('Belgium', 37.62)]
Thought:I now know the final answer
Final Answer: Customers from the USA spent the most with a total of $523.06, followed by customers from Canada who spent $303.96, and customers from France who spent $195.10.

> Finished chain.

最后输出结果,

'Customers from the USA spent the most with a total of $523.06, followed by customers from Canada who spent $303.96, and customers from France who spent $195.10.'

2-7. 第4个测试 - 运行查询​2

agent_executor.run(
    "Show the total number of tracks in each playlist. The Playlist name should be included in the result."
)

执行过程,

> Entering new AgentExecutor chain...
Action: sql_db_list_tables
Action Input: ""
Observation: Album, Artist, Customer, Employee, Genre, Invoice, InvoiceLine, MediaType, Playlist, PlaylistTrack, Track
Thought:The `Playlist` and `PlaylistTrack` tables seem relevant. I should query their schema to see what columns they have.
Action: sql_db_schema
Action Input: Playlist, PlaylistTrack
Observation: 
CREATE TABLE "Playlist" (
	"PlaylistId" INTEGER NOT NULL, 
	"Name" NVARCHAR(120), 
	PRIMARY KEY ("PlaylistId")
)

/*
3 rows from Playlist table:
PlaylistId	Name
1	Music
2	Movies
3	TV Shows
*/


CREATE TABLE "PlaylistTrack" (
	"PlaylistId" INTEGER NOT NULL, 
	"TrackId" INTEGER NOT NULL, 
	PRIMARY KEY ("PlaylistId", "TrackId"), 
	FOREIGN KEY("TrackId") REFERENCES "Track" ("TrackId"), 
	FOREIGN KEY("PlaylistId") REFERENCES "Playlist" ("PlaylistId")
)

/*
3 rows from PlaylistTrack table:
PlaylistId	TrackId
1	3402
1	3389
1	3390
*/
Thought:I can construct a SQL query to join the `Playlist` and `PlaylistTrack` tables on their common column `PlaylistId`, then group by the `Name` column in the `Playlist` table to get the total number of tracks in each playlist. I should double check this query before executing it.
Action: sql_db_query_checker
Action Input: SELECT Playlist.Name, COUNT(PlaylistTrack.TrackId) FROM Playlist INNER JOIN PlaylistTrack ON Playlist.PlaylistId = PlaylistTrack.PlaylistId GROUP BY Playlist.Name
Observation: SELECT Playlist.Name, COUNT(PlaylistTrack.TrackId) FROM Playlist 
INNER JOIN PlaylistTrack ON Playlist.PlaylistId = PlaylistTrack.PlaylistId 
GROUP BY Playlist.Name

The SQL query above does not contain any of the common mistakes listed. Therefore, I will reproduce the original query as the final SQL query:

SELECT Playlist.Name, COUNT(PlaylistTrack.TrackId) FROM Playlist 
INNER JOIN PlaylistTrack ON Playlist.PlaylistId = PlaylistTrack.PlaylistId 
GROUP BY Playlist.Name
Thought:I can now execute the final SQL query to get the answer.
Action: sql_db_query
Action Input: SELECT Playlist.Name, COUNT(PlaylistTrack.TrackId) FROM Playlist INNER JOIN PlaylistTrack ON Playlist.PlaylistId = PlaylistTrack.PlaylistId GROUP BY Playlist.Name
Observation: [('90’s Music', 1477), ('Brazilian Music', 39), ('Classical', 75), ('Classical 101 - Deep Cuts', 25), ('Classical 101 - Next Steps', 25), ('Classical 101 - The Basics', 25), ('Grunge', 15), ('Heavy Metal Classic', 26), ('Music', 6580), ('Music Videos', 1), ('On-The-Go 1', 1), ('TV Shows', 426)]
Thought:I now know the final answer.
Final Answer: Here are the total number of tracks in each playlist with their respective names: [('90’s Music', 1477), ('Brazilian Music', 39), ('Classical', 75), ('Classical 101 - Deep Cuts', 25), ('Classical 101 - Next Steps', 25), ('Classical 101 - The Basics', 25), ('Grunge', 15), ('Heavy Metal Classic', 26), ('Music', 6580), ('Music Videos', 1), ('On-The-Go 1', 1), ('TV Shows', 426)]

> Finished chain.

最后输出结果,

"Here are the total number of tracks in each playlist with their respective names: [('90’s Music', 1477), ('Brazilian Music', 39), ('Classical', 75), ('Classical 101 - Deep Cuts', 25), ('Classical 101 - Next Steps', 25), ('Classical 101 - The Basics', 25), ('Grunge', 15), ('Heavy Metal Classic', 26), ('Music', 6580), ('Music Videos', 1), ('On-The-Go 1', 1), ('TV Shows', 426)]"

2-8. 第5个测试 - 从错误中恢复

agent_executor.run("Who are the top 3 best selling artists?")

执行过程,

> Entering new AgentExecutor chain...
Action: sql_db_list_tables
Action Input: ""
Observation: Album, Artist, Customer, Employee, Genre, Invoice, InvoiceLine, MediaType, Playlist, PlaylistTrack, Track
Thought:The 'Artist' and 'Invoice' tables seem relevant. I should query their schema to see what columns they have.
Action: sql_db_schema
Action Input: Artist, Invoice
Observation: 
CREATE TABLE "Artist" (
	"ArtistId" INTEGER NOT NULL, 
	"Name" NVARCHAR(120), 
	PRIMARY KEY ("ArtistId")
)

/*
3 rows from Artist table:
ArtistId	Name
1	AC/DC
2	Accept
3	Aerosmith
*/


CREATE TABLE "Invoice" (
	"InvoiceId" INTEGER NOT NULL, 
	"CustomerId" INTEGER NOT NULL, 
	"InvoiceDate" DATETIME NOT NULL, 
	"BillingAddress" NVARCHAR(70), 
	"BillingCity" NVARCHAR(40), 
	"BillingState" NVARCHAR(40), 
	"BillingCountry" NVARCHAR(40), 
	"BillingPostalCode" NVARCHAR(10), 
	"Total" NUMERIC(10, 2) NOT NULL, 
	PRIMARY KEY ("InvoiceId"), 
	FOREIGN KEY("CustomerId") REFERENCES "Customer" ("CustomerId")
)

/*
3 rows from Invoice table:
InvoiceId	CustomerId	InvoiceDate	BillingAddress	BillingCity	BillingState	BillingCountry	BillingPostalCode	Total
1	2	2009-01-01 00:00:00	Theodor-Heuss-Straße 34	Stuttgart	None	Germany	70174	1.98
2	4	2009-01-02 00:00:00	Ullevålsveien 14	Oslo	None	Norway	0171	3.96
3	8	2009-01-03 00:00:00	Grétrystraat 63	Brussels	None	Belgium	1000	5.94
*/
Thought:The 'Artist' table has an 'ArtistId' and a 'Name' column, but it doesn't seem to have any information about sales. The 'Invoice' table has an 'InvoiceId', 'CustomerId', 'InvoiceDate', 'BillingAddress', 'BillingCity', 'BillingState', 'BillingCountry', 'BillingPostalCode', and 'Total' column, but it also doesn't seem to have any information about artists. I need to find a table that links artists to invoices or sales.

Action: sql_db_schema
Action Input: InvoiceLine
Observation: 
CREATE TABLE "InvoiceLine" (
	"InvoiceLineId" INTEGER NOT NULL, 
	"InvoiceId" INTEGER NOT NULL, 
	"TrackId" INTEGER NOT NULL, 
	"UnitPrice" NUMERIC(10, 2) NOT NULL, 
	"Quantity" INTEGER NOT NULL, 
	PRIMARY KEY ("InvoiceLineId"), 
	FOREIGN KEY("TrackId") REFERENCES "Track" ("TrackId"), 
	FOREIGN KEY("InvoiceId") REFERENCES "Invoice" ("InvoiceId")
)

/*
3 rows from InvoiceLine table:
InvoiceLineId	InvoiceId	TrackId	UnitPrice	Quantity
1	1	2	0.99	1
2	1	4	0.99	1
3	2	6	0.99	1
*/
Thought:The 'InvoiceLine' table seems to link invoices to tracks, and the 'Track' table might have information about artists. I should query the schema of the 'Track' table to see what columns it has.

Action: sql_db_schema
Action Input: Track
Observation: 
CREATE TABLE "Track" (
	"TrackId" INTEGER NOT NULL, 
	"Name" NVARCHAR(200) NOT NULL, 
	"AlbumId" INTEGER, 
	"MediaTypeId" INTEGER NOT NULL, 
	"GenreId" INTEGER, 
	"Composer" NVARCHAR(220), 
	"Milliseconds" INTEGER NOT NULL, 
	"Bytes" INTEGER, 
	"UnitPrice" NUMERIC(10, 2) NOT NULL, 
	PRIMARY KEY ("TrackId"), 
	FOREIGN KEY("MediaTypeId") REFERENCES "MediaType" ("MediaTypeId"), 
	FOREIGN KEY("GenreId") REFERENCES "Genre" ("GenreId"), 
	FOREIGN KEY("AlbumId") REFERENCES "Album" ("AlbumId")
)

/*
3 rows from Track table:
TrackId	Name	AlbumId	MediaTypeId	GenreId	Composer	Milliseconds	Bytes	UnitPrice
1	For Those About To Rock (We Salute You)	1	1	1	Angus Young, Malcolm Young, Brian Johnson	343719	11170334	0.99
2	Balls to the Wall	2	2	1	None	342562	5510424	0.99
3	Fast As a Shark	3	2	1	F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman	230619	3990994	0.99
*/
Thought:The 'Track' table has a 'TrackId', 'Name', 'AlbumId', 'MediaTypeId', 'GenreId', 'Composer', 'Milliseconds', 'Bytes', and 'UnitPrice' column, but it doesn't seem to have any information about artists. However, the 'ArtistId' from the 'Artist' table is not present in any of the tables I have queried so far. It seems like there might not be a direct link between the artists and their sales.

In this case, I can provide the top 3 best-selling tracks instead of artists, as it is the closest information I can extract from the schema provided.

Question: Who are the top 3 best selling artists?
Thought: It seems like there isn't a direct link between the artists and their sales in the database schema. I will provide the top 3 best-selling tracks instead.
Final Answer: Here are the top 3 best-selling tracks:

> Finished chain.

最后输出结果(实际没有输出正确的结果),

'Here are the top 3 best-selling tracks:'

3. 结论

从执行过程可知,SQLDatabaseToolkit 有下面 4 个预置 Agent,根据我们发送的消息,调用相应的 Agent,查看数据库中有什么表,将要使用的表有什么字段,然后根据自然语言的消息,生成 SQL 语句,并且进行生成的 SQL。

sql_db_query, sql_db_schema, sql_db_list_tables, sql_db_query_checker

从执行过程可知,在我们发送的信息还比较 “靠谱” 的情况,大概率是能够得到正确的结果的。如果我们发送的信息 “不靠谱” 的情况,大语言模型就不一定给我们反馈什么结果了。

完结!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1337767.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

关于Axios发送Get请求无法添加Content-Type

在拦截器中尝试给headers添加Content-Type: request.interceptors.request.use(config > {if (!config.headers[Content-Type]) {config.headers[Content-Type] application/json;}return config;},error > {return Promise.reject(error)} )如果是GET请求&…

【流复制环境PostgreSQL-14.1到PostgreSQL-16.1大版本升级】

PostgreSQL大版本会定期添加新特性,这些新特性通常会改变系统表的布局,但内部数据存储格式很少改变。pg_upgrade通过创建新的系统表和重用旧的用户数据文件来执行快速升级。 pg_upgrade升级主要有三种用法: 1、使用pg_upgrade拷贝升级。 2、…

Redis分布式缓存之主从哨兵分片集群

Redis主从 数据同步原理 Redis哨兵 Redis分片集群 集群伸缩:在集群中插入或删除某个节点 集群故障转移

使用ffmpeg实现视频旋转并保持清晰度不变

1 原始视频信息 通过ffmpeg -i命令查看视频基本信息 ffmpeg -i source.mp4 ffmpeg version 6.1-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developersbuilt with gcc 12.2.0 (Rev10, Built by MSYS2 project)configuration: --enable-gpl --enable-…

Java 基础学习(十九)网络编程、反射

1 Socket编程 1.1 Socket编程概述 1.1.1 Socket简介 在网络编程中,Socket(套接字)是一种抽象概念,它用于在不同计算机之间进行通信。Socket可以看作是一种通信的端点,可以通过Socket与其他计算机上的程序进行数据传…

亚马逊云科技 re:Invent 2023 产品体验:亚马逊云科技产品应用实践 国赛选手带你看 Elasticache Serverless

抛砖引玉 讲一下作者背景,曾经参加过国内世界技能大赛云计算的选拔,那么在竞赛中包含两类,一类是架构类竞赛,另一类就是 TroubleShooting 竞赛,对应的分别为亚马逊云科技 GameDay 和亚马逊云科技 Jam,想必…

Pytest框架 —— 用例标记和测试执行篇!

pytest用例标记和测试执行篇 上一篇文章入门篇咱们介绍了pytest的前后置方法和fixture机制,这个章节主要给大家介绍pytest中的标记机制和用例执行的方法。pytest可以通过标记将数据传入于测试函数中,也可以通过标记中对执行的用例做筛选,接下…

WebGL开发安全培训应用

使用 WebGL 开发安全培训应用可以为员工提供在虚拟环境中体验危险情境、学习安全操作和应急处理技能的机会。以下是开发安全培训应用的一般步骤,希望对大家有所帮助。北京木奇移动技术有限公司,专业的软件外包开发公司,欢迎交流合作。 1.明确…

Web(10)XSS漏洞

XSS跨站脚本攻击 XSS是什么 XSS(cross-site-scripting) 即是跨站脚本攻击,是一种网站应用程序的安全漏洞攻击,是代码注入的一种。它允许恶意用户将代码注入到网页上,其他用户在观看网页时就会受到影响。这类攻击通常包含了 HTML 以及用户端…

实战10 角色管理

目录 1、角色后端接口 2、角色列表查询 2.1 效果图 2.2页面原型代码 2.3 角色api代码 role.js 2.4 查询角色列表代码 4、 新增和编辑角色 5、删除角色 6、分配权限 6.1 分配权限思路 6.2 分配权限回显接口 6.3 分配权限回显前端实现 6.4分配权限后端接口 6.4.1 R…

实验八 基于FPGA的分频器的设计

基本任务一:设计一个分频器,输入信号50MHZ,输出信号频率分别为1KHZ,500HZ,1HZ。 m100: 扩展任务二:控制蜂鸣器发出滴滴滴的声音

补题与总结:leetcode第 377 场周赛

文章目录 写在最前面的复盘2977. 转换字符串的最小成本 II(Flody 爆搜优化->dp) 写在最前面的复盘 感谢leetcode,丰富了我为数不多的卡常经验 2是简单思维题,但卡常 4是爆搜优化,也卡常,补题时给卡麻了…

【HBase】——简介

1 HBase 定义 Apache HBase™ 是以 hdfs 为数据存储的,一种分布式、可扩展的 NoSQL 数据库。 2 HBase 数据模型 • HBase 的设计理念依据 Google 的 BigTable 论文,论文中对于数据模型的首句介绍。 Bigtable 是一个稀疏的、分布式的、持久的多维排序 m…

.Net7.0 或更高版本 System.Drawing.Common 上传图片跨平台方案

项目升级.Net7.0以后,System.Drawing.Common开关已经被删除,且System.Drawing.Common仅在 Windows 上支持 ,于是想办法将原来上传图片验证文件名和获取图片扩展名方法替换一下,便开始搜索相关解决方案。 .Net6.0文档:…

Python 高级(四):线程池 ThreadPoolExecutor

大家好,我是水滴~~ 当涉及到需要同时处理多个任务的情况时,使用线程池是一种高效的方法。Python提供了concurrent.futures模块,其中的ThreadPoolExecutor类使得使用线程池变得非常方便。本文将详细介绍Python线程池的概念、使用方法和示例代…

使用 AnyGo 修改 iPhone 手机定位

在当今数字化时代,我们的手机已经成为我们日常生活中不可或缺的一部分。然而,有时我们可能会遇到一些情况,需要修改手机的定位信息。这个需求可能来自于各种不同的原因,包括但不限于保护个人隐私、测试应用程序的地理位置相关功能…

数据仓库【5】:项目实战

数据仓库【5】:项目实战 1、项目概述1.1、项目背景1.2、复购率计算 2、数据描述3、架构设计3.1、数据仓库架构图 4、环境搭建4.1、环境说明4.2、集群规划4.3、搭建流程 5、项目开发5.1、业务数据生成5.2、ETL数据导入5.3、ODS层创建&数据接入5.4、DWD层创建&…

【面试】Java中的多种设计模式(十种主要设计模式)

Java中的多种设计模式(十种主要设计模式) 文章概述 设计模式是一套被反复使用、多数人知晓的、经过分类的、代码设计经验的总结。它是软件工程中常见问题的解决方案的一种描述或模板。设计模式可以提供一种通用的、可重用的解决方案,帮助开发…

leetcode 75. 颜色分类(medium)(优质解法)

链接&#xff1a;力扣&#xff08;LeetCode&#xff09;官网 - 全球极客挚爱的技术成长平台 代码&#xff1a; class Solution {public void sortColors(int[] nums) {int left-1,rightnums.length,i0;while(i<right){if(nums[i]0){left;swap(nums,left,i);i;}else if(nums…

【学习笔记】Java函数式编程03 Stream流-终结操作

书接上回 3.3.3 终结操作 3.3.3.1 forEach 对集合的每一个元素进行处理 接触很多了不赘述 3.3.3.2 count 用来获取当前流中的元素的个数 比如&#xff0c;打印出所有作家的作品的总数 System.out.println(authors.stream().flatMap(author -> author.getBooks().stre…