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

OpenAI API推出结构化输出功能

  每周跟踪AI热点新闻动向和震撼发展 想要探索生成式人工智能的前沿进展吗?订阅我们的简报,深入解析最新的技术突破、实际应用案例和未来的趋势。与全球数同行一同,从行业内部的深度分析和实用指南中受益。不要错过这个机会,成为AI领域的领跑者。点击订阅,与未来同行! 订阅:https://rengongzhineng.io/

去年在DevDay大会上,OpenAI介绍了JSON模式,这个工具对于开发者来说是构建可靠应用程序的有用模块。虽然JSON模式提高了模型生成有效JSON输出的可靠性,但并不能保证模型的响应会符合特定的架构。今天,OpenAI推出了一项新功能——API中的结构化输出,旨在确保模型生成的输出完全符合开发者提供的JSON架构。

从非结构化输入生成结构化数据是现代应用程序中人工智能的核心用例之一。开发者使用OpenAI API构建功能强大的助手,这些助手可以通过函数调用获取数据并回答问题,提取结构化数据进行数据输入,并构建多步代理工作流,使大型语言模型能够采取行动。开发者长期以来一直通过开源工具、提示和反复重试请求来解决大型语言模型在这方面的局限性,确保模型输出符合其系统所需的格式。结构化输出通过约束OpenAI模型以符合开发者提供的架构,并训练模型更好地理解复杂的架构,解决了这一问题。

在对复杂JSON架构遵循性的评估中,OpenAI的新模型gpt-4o-2024-08-06在结构化输出方面得分为100%,而gpt-4-0613得分不到40%。

有了结构化输出,gpt-4o-2024-08-06在评估中实现了100%的可靠性,完美匹配输出架构。

如何使用结构化输出

OpenAI在API中以两种形式引入结构化输出:

  1. 函数调用:通过工具启用的结构化输出可以在函数定义中设置strict: true来实现。这一功能适用于所有支持工具的模型,包括gpt-4-0613和gpt-3.5-turbo-0613及其后续版本。当启用结构化输出时,模型输出将匹配提供的工具定义。

请求:
POST /v1/chat/completions
{"model": "gpt-4o-2024-08-06","messages": [{"role": "system","content": "You are a helpful assistant. The current date is August 6, 2024. You help users query for the data they are looking for by calling the query function."},{"role": "user","content": "look up all my orders in may of last year that were fulfilled but not delivered on time"}],"tools": [{"type": "function","function": {"name": "query","description": "Execute a query.","strict": true,"parameters": {"type": "object","properties": {"table_name": {"type": "string","enum": ["orders"]},"columns": {"type": "array","items": {"type": "string","enum": ["id","status","expected_delivery_date","delivered_at","shipped_at","ordered_at","canceled_at"]}},"conditions": {"type": "array","items": {"type": "object","properties": {"column": {"type": "string"},"operator": {"type": "string","enum": ["=", ">", "<", ">=", "<=", "!="]},"value": {"anyOf": [{"type": "string"},{"type": "number"},{"type": "object","properties": {"column_name": {"type": "string"}},"required": ["column_name"],"additionalProperties": false}]}},"required": ["column", "operator", "value"],"additionalProperties": false}},"order_by": {"type": "string","enum": ["asc", "desc"]}},"required": ["table_name", "columns", "conditions", "order_by"],"additionalProperties": false}}}]
}

输出:

{"table_name": "orders","columns": ["id", "status", "expected_delivery_date", "delivered_at"],"conditions": [{"column": "status","operator": "=","value": "fulfilled"},{"column": "ordered_at","operator": ">=","value": "2023-05-01"},{"column": "ordered_at","operator": "<","value": "2023-06-01"},{"column": "delivered_at","operator": ">","value": {"column_name": "expected_delivery_date"}}],"order_by": "asc"
}

  1. 响应格式的新选项:开发者现在可以通过json_schema提供JSON Schema,这是response_format参数的新选项。当模型不调用工具而是以结构化方式响应用户时,这一功能非常有用。这一功能适用于OpenAI最新的GPT-4o模型:gpt-4o-2024-08-06和gpt-4o-mini-2024-07-18。当提供response_format并设置strict: true时,模型输出将匹配提供的架构。

请求:

POST /v1/chat/completions
{"model": "gpt-4o-2024-08-06","messages": [{"role": "system","content": "You are a helpful math tutor."},{"role": "user","content": "solve 8x + 31 = 2"}],"response_format": {"type": "json_schema","json_schema": {"name": "math_response","strict": true,"schema": {"type": "object","properties": {"steps": {"type": "array","items": {"type": "object","properties": {"explanation": {"type": "string"},"output": {"type": "string"}},"required": ["explanation", "output"],"additionalProperties": false}},"final_answer": {"type": "string"}},"required": ["steps", "final_answer"],"additionalProperties": false}}}
}

输出:

{"steps": [{"explanation": "Subtract 31 from both sides to isolate the term with x.","output": "8x + 31 - 31 = 2 - 31"},{"explanation": "This simplifies to 8x = -29.","output": "8x = -29"},{"explanation": "Divide both sides by 8 to solve for x.","output": "x = -29 / 8"}],"final_answer": "x = -29 / 8"
}

安全的结构化输出

安全性是OpenAI的首要任务——新的结构化输出功能将遵循现有的安全政策,并且仍然允许模型拒绝不安全的请求。为了简化开发,API响应中增加了一个新的refusal字符串值,允许开发者以编程方式检测模型是否生成了拒绝,而不是匹配架构的输出。当响应不包含拒绝且模型的响应未被提前中断时(如由finish_reason指示),则模型的响应将可靠地产生匹配提供架构的有效JSON。

原生SDK支持

OpenAI的Python和Node SDK已更新,提供对结构化输出的原生支持。提供工具或响应格式的架构与提供Pydantic或Zod对象一样简单,SDK将处理将数据类型转换为支持的JSON架构,自动将JSON响应反序列化为类型化的数据结构,并在出现拒绝时解析它们。

以下示例显示了使用函数调用的结构化输出的原生支持。

Python:

from enum import Enum
from typing import Union
from pydantic import BaseModel
import openai
from openai import OpenAIclass Table(str, Enum):orders = "orders"customers = "customers"products = "products"class Column(str, Enum):id = "id"status = "status"expected_delivery_date = "expected_delivery_date"delivered_at = "delivered_at"shipped_at = "shipped_at"ordered_at = "ordered_at"canceled_at = "canceled_at"class Operator(str, Enum):eq = "="gt = ">"lt = "<"le = "<="ge = ">="ne = "!="class OrderBy(str, Enum):asc = "asc"desc = "desc"class DynamicValue(BaseModel):column_name: strclass Condition(BaseModel):column: stroperator: Operatorvalue: Union[str, int, DynamicValue]class Query(BaseModel):table_name: Tablecolumns: list[Column]conditions: list[Condition]order_by: OrderByclient = OpenAI()completion = client.beta.chat.completions.parse(model="gpt-4o-2024-08-06",messages=[{"role": "system","content": "You are a helpful assistant. The current date is August 6, 2024. You help users query for the data they are looking for by calling the query function.",},{"role": "user","content": "look up all my orders in may of last year that were fulfilled but not delivered on time",},],tools=[openai.pydantic_function_tool(Query),],
)print(completion.choices[0].message.tool_calls[0].function.parsed_arguments)

Node:

import OpenAI from 'openai';
import z from 'zod';
import { zodFunction } from 'openai/helpers/zod';const Table = z.enum(['orders', 'customers', 'products']);
const Column = z.enum(['id','status','expected_delivery_date','delivered_at','shipped_at','ordered_at','canceled_at',
]);
const Operator = z.enum(['=', '>', '<', '<=', '>=', '!=']);
const OrderBy = z.enum(['asc', 'desc']);const DynamicValue = z.object({column_name: z.string(),
});const Condition = z.object({column: z.string(),operator: Operator,value: z.union([z.string(), z.number(), DynamicValue]),
});const QueryArgs = z.object({table_name: Table,columns: z.array(Column),conditions: z.array(Condition),order_by: OrderBy,
});const client = new OpenAI();const completion = await client.beta.chat.completions.parse({model: 'gpt-4o-2024-08-06',messages: [{ role: 'system', content: 'You are a helpful assistant. The current date is August 6, 2024. You help users query for the data they are looking for by calling the query function.' },{ role: 'user', content: 'look up all my orders in may of last year that were fulfilled but not delivered on time' }],tools: [zodFunction({ name: 'query', parameters: QueryArgs })],
});
console.log(completion.choices[0].message.tool_calls[0].function.parsed_arguments);

响应格式的原生支持也可用。

Python:

from pydantic import BaseModel
from openai import OpenAIclass Step(BaseModel):explanation: stroutput: strclass MathResponse(BaseModel):steps: list[Step]final_answer: strclient = OpenAI()completion = client.beta.chat.completions.parse(model="gpt-4o-2024-08-06",messages=[{"role": "system", "content": "You are a helpful math tutor."},{"role": "user", "content": "solve 8x + 31 = 2"},],response_format=MathResponse,
)message = completion.choices[0].message
if message.parsed:print(message.parsed.steps)print(message.parsed.final_answer)
else:print(message.refusal)

Node:

import OpenAI from 'openai';
import { zodResponseFormat } from 'openai/helpers/zod';
import { z } from 'zod';const Step = z.object({explanation: z.string(),output: z.string(),
});const MathResponse = z.object({steps: z.array(Step),final_answer: z.string(),
});const client = new OpenAI();const completion = await client.beta.chat.completions.parse({model: 'gpt-4o-2024-08-06',messages: [{"role": "system","content": "You are a helpful math tutor. Only use the schema for math responses.",},{ "role": "user", "content": "solve 8x + 3 = 21" },],response_format: zodResponseFormat(MathResponse, 'mathResponse'),
});const message = completion.choices[0]?.message;
if (message?.parsed) {console.log(message.parsed.steps);console.log(message.parsed.final_answer);
} else {console.log(message.refusal);
}

其他使用案例

开发者经常使用OpenAI的模型生成结构化数据以满足各种使用需求。以下是一些额外的示例:

根据用户意图动态生成用户界面

例如,开发者可以使用结构化输出创建代码或用户界面生成应用程序。以下所有示例都使用相同的response_format,可以根据用户输入生成不同的用户界面。

系统:

{"type": "div","label": "","children": [{"type": "header","label": "","children": [{"type": "div","label": "Green Thumb Gardening","children": [],"attributes": [{ "name": "className", "value": "site-title" }]},{"type": "div","label": "Bringing Life to Your Garden","children": [],"attributes": [{ "name": "className", "value": "site-tagline" }]}],"attributes": [{ "name": "className", "value": "header" }]},{"type": "section","label": "","children": [{"type": "div","label": "","children": [{"type": "div","label": "About Us","children": [{"type": "div","label": "At Green Thumb Gardening, we specialize in transforming your outdoor spaces into beautiful, thriving gardens. Our team has decades of experience in horticulture and landscape design.","children": [],"attributes": [{ "name": "className", "value": "about-description" }]}],"attributes": [{ "name": "className", "value": "about-section" }]}],"attributes": [{ "name": "className", "value": "content" }]}],"attributes": [{ "name": "className", "value": "about-container" }]},{"type": "section","label": "","children": [{"type": "div","label": "","children": [{"type": "div","label": "Our Services","children": [{"type": "div","label": "Garden Design","children": [],"attributes": [{ "name": "className", "value": "service-item" }]},{"type": "div","label": "Plant Care & Maintenance","children": [],"attributes": [{ "name": "className", "value": "service-item" }]},{"type": "div","label": "Seasonal Cleanup","children": [],"attributes": [{ "name": "className", "value": "service-item" }]},{"type": "div","label": "Custom Landscaping","children": [],"attributes": [{ "name": "className", "value": "service-item" }]}],"attributes": [{ "name": "className", "value": "services-list" }]}],"attributes": [{ "name": "className", "value": "content" }]}],"attributes": [{ "name": "className", "value": "services-container" }]}],"attributes": [{ "name": "className", "value": "landing-page" }]
}

将最终答案与支持推理或额外评论分开

给模型一个单独的思维链字段可以提高最终响应的质量。

请求:

{"model": "gpt-4o-2024-08-06","messages": [{"role": "system","content": "You are a helpful assistant"},{"role": "user","content": "9.11和9.9哪个更大?"}],"response_format": {"type": "json_schema","json_schema": {"name": "reasoning_schema","strict":true,"schema": {"type": "object","properties": {"reasoning_steps": {"type": "array","items": {"type": "string"},"description": "推理步骤,得出最终结论。"},"answer": {"type": "string","description": "最终答案,考虑推理步骤。"}},"required": ["reasoning_steps", "answer"],"additionalProperties": false}}}
}

输出:

{"reasoning_steps": ["第一步是比较数字9.11和9.9。","这两个数字都有相同的整数部分,即9。","要比较小数部分,请将它们转换为相同的小数位数。","9.11有两位小数:它是9.11。","9.9有一位小数:可以写成9.90。","现在,通过查看小数部分来比较9.11和9.90。","比较11和90。","90大于11,所以9.90大于9.11。"],"answer": "9.9大于9.11。"
}

从非结构化数据中提取结构化数据

例如,指示模型从会议记录中提取待办事项、截止日期和负责人。

请求:

POST /v1/chat/completions
{"model": "gpt-4o-2024-08-06","messages": [{"role": "system","content": "从会议记录中提取行动项、截止日期和负责人。"},{"role": "user","content": "...会议记录在此..."}],"response_format": {"type": "json_schema","json_schema": {"name": "action_items","strict": true,"schema": {"type": "object","properties": {"action_items": {"type": "array","items": {"type": "object","properties": {"description": {"type": "string","description": "行动项描述。"},"due_date": {"type": ["string", "null"],"description": "行动项的截止日期,如果没有指定可以为null。"},"owner": {"type": ["string", "null"],"description": "负责行动项的负责人,如果没有指定可以为null。"}},"required": ["description", "due_date", "owner"],"additionalProperties": false},"description": "会议中的行动项列表。"}},"required": ["action_items"],"additionalProperties": false}}}
}

输出:

{"action_items": [{"description": "协作优化路径规划算法","due_date": "2024-06-30","owner": "Jason Li"},{"description": "联系行业合作伙伴获取更多数据集","due_date": "2024-06-25","owner": "Aisha Patel"},{"description": "探索替代的LIDAR传感器配置并报告结果","due_date": "2024-06-27","owner": "Kevin Nguyen"},{"description": "安排集成导航系统的扩展压力测试","due_date": "2024-06-28","owner": "Emily Chen"},{"description": "修复错误后重新测试系统并更新团队","due_date": "2024-07-01","owner": "David Park"}]
}

工作原理

OpenAI采用了两步方法来提高与JSON Schema匹配的模型输出的可靠性。首先,训练了最新的模型gpt-4o-2024-08-06,以理解复杂的架构并最佳地生成匹配它们的输出。然而,模型行为本质上是非确定性的——尽管这一模型的性能有所提高(在基准测试中得分为93%),但它仍未达到开发者构建强大应用程序所需的可靠性。因此,OpenAI还采用了一种确定性、工程性的方法来约束模型的输出,以实现100%的可靠性。

限制与注意事项

使用结构化输出时需要注意以下几点:

  • 结构化输出仅允许JSON Schema的一个子集,详细信息请参见文档。这有助于确保最佳性能。
  • 第一次API响应使用新架构时会有额外的延迟,但随后的响应将快速且无延迟惩罚。因为在第一次请求期间,OpenAI需要处理架构并生成可高效重用的缓存结构。
  • 如果模型选择拒绝不安全的请求,它可能会无法遵循架构。如果选择拒绝,返回消息将包含refusal布尔值以指示这一点。
  • 如果生成达到max_tokens或其他停止条件之前,模型可能无法遵循架构。
  • 结构化输出并不能防止所有类型的模型错误。例如,模型仍可能在JSON对象的值中犯错(例如,在数学方程中出错)。如果开发者发现错误,建议在系统指令中提供示例或将任务拆分为更简单的子任务。
  • 结构化输出与并行函数调用不兼容。生成并行函数调用时,可能不会匹配提供的架构。设置parallel_tool_calls: false以禁用并行函数调用。
  • 提供的JSON架构不符合零数据保留(ZDR)资格。

可用性

结构化输出现已在API中普遍可用。

通过函数调用实现的结构化输出适用于所有支持函数调用的API模型。这包括OpenAI最新的模型(gpt-4o,gpt-4o-mini),所有gpt-4-0613及以后和gpt-3.5-turbo-0613及其后续版本,以及任何支持函数调用的微调模型。此功能适用于聊天补全API、助手API和批量API。通过函数调用实现的结构化输出也兼容视觉输入。

通过响应格式实现的结构化输出适用于gpt-4o-mini和gpt-4o-2024-08-06及基于这些模型的任何微调模型。此功能适用于聊天补全API、助手API和批量API。通过响应格式实现的结构化输出也兼容视觉输入。

通过切换到新的gpt-4o-2024-08-06,开发者在输入方面节省50%($2.50/百万输入tokens),在输出方面节省33%($10.00/百万输出tokens),相较于gpt-4o-2024-05-13。

要开始使用结构化输出,请查看OpenAI的文档。(https://platform.openai.com/docs/guides/structured-outputs)

相关文章:

OpenAI API推出结构化输出功能

每周跟踪AI热点新闻动向和震撼发展 想要探索生成式人工智能的前沿进展吗&#xff1f;订阅我们的简报&#xff0c;深入解析最新的技术突破、实际应用案例和未来的趋势。与全球数同行一同&#xff0c;从行业内部的深度分析和实用指南中受益。不要错过这个机会&#xff0c;成为AI领…...

Python 异步编程:Sqlalchemy 异步实现方式

SQLAlchemy 是 Python 中最流行的数据库工具之一&#xff0c;在新版本中引入了对异步操作的支持。这为使用异步框架&#xff08;如 FastAPI&#xff09;开发应用程序带来了极大的便利。在这篇文章中&#xff0c;简单介绍下 SQLAlchemy 是如何利用 Greenlet 实现异步操作的。 什…...

父类引用指向子类对象

在 Java 中&#xff0c;父类引用可以指向子类对象&#xff0c;这是多态的一种表现。这种特性允许你使用父类的引用来操作子类对象&#xff0c;从而实现更灵活和可扩展的代码设计。 基本概念 多态&#xff1a;父类引用可以指向子类对象。这使得你可以用统一的接口处理不同的对象…...

分享一个基于Spring Boot的面向社区的智能化健康管理系统的设计与实现(源码、调试、LW、开题、PPT)

&#x1f495;&#x1f495;作者&#xff1a;计算机源码社 &#x1f495;&#x1f495;个人简介&#xff1a;本人 八年开发经验&#xff0c;擅长Java、Python、PHP、.NET、Node.js、Android、微信小程序、爬虫、大数据、机器学习等&#xff0c;大家有这一块的问题可以一起交流&…...

【扒代码】reduction参数是什么

model DensityMapRegressor(in_channels256, reduction8)reduction 参数在 DensityMapRegressor 类中用于决定模型在上采样过程中的层级配置。具体来说&#xff0c;它决定了上采样过程中使用多少个 UpsamplingLayer&#xff0c;从而影响输出的分辨率。 reduction 参数的作用 …...

Python,Spire.Doc模块,处理word、docx文件,极致丝滑

Python处理word文件&#xff0c;一般都是推荐的Python-docx&#xff0c;但是只写出一个&#xff0c;一句话的文件&#xff0c;也没有什么样式&#xff0c;就是36K。 再打开word在另存一下&#xff0c;就可以到7-8k&#xff0c;我想一定是python-docx的问题&#xff0c;但一直没…...

redis的安装与命令

一、redis与memcache总体对比 1.性能 Redis&#xff1a;只使用单核&#xff0c;平均每一个核上Redis在存储小数据时比Memcached性能更高。 Memcached&#xff1a;可以使用多核&#xff0c;而在100k以上的数据中&#xff0c;Memcached性能要高于Redis。 2.内存使用效率 Mem…...

【C++】特殊类设计类型转换

目录 &#x1f4a1;前言一&#xff0c;特殊类设计1. 请设计一个类&#xff0c;不能被拷贝2. 请设计一个类&#xff0c;只能在堆上创建对象3. 请设计一个类&#xff0c;只能在栈上创建对象4. 请设计一个类&#xff0c;不能被继承5. 请设计一个类&#xff0c;只能创建一个对象(单…...

为git 命令行 设置代理环境变量

http://t.csdnimg.cn/cAxkg 国内需要修改pinoko根目录下gitconfig文件&#xff0c;添加 [http]proxy http://127.0.0.1:1080 [https]proxy https://127.0.0.1:1080或者通过命令行配置&#xff1a; git config --global http.proxy http://127.0.0.1:1080 git config --glo…...

自定义linux某些常见配置

1.当前路径 echo "PS1\u\h:\w\$ " >> /etc/profile source /etc/profile 2.ssh使能 1.开启openssh 2.权限赋予chown root.root /var/empty/ 3.开发板作为server echo "PermitRootLogin yes" >> /etc/ssh/sshd_config 3开机自启动脚本 1.init…...

告别手动操作!KeyMouseGo实现自动化工作流

前言 在这个快节奏的时代&#xff0c;我们每天都在与电脑打交道&#xff0c;重复着那些繁琐而单调的操作&#xff1b;你是否曾想过&#xff0c;能让电脑自己完成这些任务&#xff0c;而你则悠闲地喝着咖啡&#xff0c;享受着生活&#xff1f;今天&#xff0c;就让我们一起揭开一…...

大型语言模型微调 新进展-4篇 论文

1. Brevity is the soul of wit: Pruning long files for code generation 发布时间&#xff1a;2024-06-29链接&#xff1a;https://arxiv.org/abs/2407.00434机构&#xff1a;伦敦大学学院 (UCL) 本研究针对大型语言模型的代码生成任务中的数据清理问题进行了探索。研究发现…...

专业课140+杭电杭州电子科技大学843信号与系统考研经验电子信息与通信工程真题,大纲,参考书。

顺利上岸杭电&#xff0c;由于专业课考的不错140&#xff0c;群里不少同学希望分享一点经验&#xff0c;回头看看这一年考研复习&#xff0c;确实有得有失&#xff0c;总结一下自己的专业课复习经验&#xff0c;希望对大家有帮助&#xff0c;基础课考的没有专业好&#xff0c;而…...

php 中 (0 == ‘abc‘) 为真

https://andi.cn/page/621653.html...

MacOS Anaconda 安装教程及虚拟环境创建

一、下载 Anaconda 1、Anaconda 官网 2、清华大学开源软件镜像站 点 Date 按时间排序&#xff0c;根据自己 Mac 芯片类型下载对应最新版本的。 Intel 芯片的下载 x86_64 版本的Apple m1 芯片的下载 arm64 版本的 二、安装 Anaconda 将安装包下载到本地后&#xff0c;双击安…...

Mac快速配置ADB环境变量

ADB是进行 Androd 开发时很常用的调试工具&#xff0c;Android SDK 中就包含了该工具&#xff0c;所以如果安装了SDK那只需要在环境变量中配置 Android SDK 的路径即可&#xff0c;本文的环境配置也基于这种场景。 如果需要独立下载 ADB 工具&#xff0c;请参考下面网址&#x…...

Kylin的工作原理及使用分享

前言 在当今信息爆炸的时代&#xff0c;企业和研究机构每天都在生成和收集大量的数据。这些数据中蕴藏着巨大的商业价值和研究潜力&#xff0c;但要从中提取出有用的信息却并非易事。传统的数据处理和分析技术在面对如此庞大的数据量时&#xff0c;往往难以提供快速和有效的响…...

python 使用seleniumwire获取响应数据

seleniumwire 是一个在 Selenium WebDriver 基础上扩展的库&#xff0c;它允许你在使用 Selenium 进行网页自动化测试或爬虫时捕获和修改 HTTP 请求和响应。这对于需要分析网页数据或进行更复杂的网络交互的自动化任务特别有用。 以下是如何使用 seleniumwire 来获取响应数据的…...

用C语言实现双向链表

目录 一.双向链表的结构 二. 双向链表的实现 1. 在List.h中结构体的定义和各函数的声明 1.1 结构体&#xff08;节点&#xff09;的定义 1.2 各函数的声明 2. 在List.c中各函数的实现 2.1 初始化 LTInit 2.2 尾插 LTPushBack 2.3 打印 LTPrint 2.4 头插 LTPushFron…...

Github 2024-08-10 Rust开源项目日报Top10

根据Github Trendings的统计,今日(2024-08-10统计)共有10个项目上榜。根据开发语言中项目的数量,汇总情况如下: 开发语言项目数量Rust项目10Python项目1Turbo:下一代前端开发工具链 创建周期:977 天开发语言:Rust协议类型:MIT LicenseStar数量:25308 个Fork数量:1713 …...

【力扣数据库知识手册笔记】索引

索引 索引的优缺点 优点1. 通过创建唯一性索引&#xff0c;可以保证数据库表中每一行数据的唯一性。2. 可以加快数据的检索速度&#xff08;创建索引的主要原因&#xff09;。3. 可以加速表和表之间的连接&#xff0c;实现数据的参考完整性。4. 可以在查询过程中&#xff0c;…...

YSYX学习记录(八)

C语言&#xff0c;练习0&#xff1a; 先创建一个文件夹&#xff0c;我用的是物理机&#xff1a; 安装build-essential 练习1&#xff1a; 我注释掉了 #include <stdio.h> 出现下面错误 在你的文本编辑器中打开ex1文件&#xff0c;随机修改或删除一部分&#xff0c;之后…...

Qt Http Server模块功能及架构

Qt Http Server 是 Qt 6.0 中引入的一个新模块&#xff0c;它提供了一个轻量级的 HTTP 服务器实现&#xff0c;主要用于构建基于 HTTP 的应用程序和服务。 功能介绍&#xff1a; 主要功能 HTTP服务器功能&#xff1a; 支持 HTTP/1.1 协议 简单的请求/响应处理模型 支持 GET…...

Android15默认授权浮窗权限

我们经常有那种需求&#xff0c;客户需要定制的apk集成在ROM中&#xff0c;并且默认授予其【显示在其他应用的上层】权限&#xff0c;也就是我们常说的浮窗权限&#xff0c;那么我们就可以通过以下方法在wms、ams等系统服务的systemReady()方法中调用即可实现预置应用默认授权浮…...

CSS设置元素的宽度根据其内容自动调整

width: fit-content 是 CSS 中的一个属性值&#xff0c;用于设置元素的宽度根据其内容自动调整&#xff0c;确保宽度刚好容纳内容而不会超出。 效果对比 默认情况&#xff08;width: auto&#xff09;&#xff1a; 块级元素&#xff08;如 <div>&#xff09;会占满父容器…...

算法:模拟

1.替换所有的问号 1576. 替换所有的问号 - 力扣&#xff08;LeetCode&#xff09; ​遍历字符串​&#xff1a;通过外层循环逐一检查每个字符。​遇到 ? 时处理​&#xff1a; 内层循环遍历小写字母&#xff08;a 到 z&#xff09;。对每个字母检查是否满足&#xff1a; ​与…...

搭建DNS域名解析服务器(正向解析资源文件)

正向解析资源文件 1&#xff09;准备工作 服务端及客户端都关闭安全软件 [rootlocalhost ~]# systemctl stop firewalld [rootlocalhost ~]# setenforce 0 2&#xff09;服务端安装软件&#xff1a;bind 1.配置yum源 [rootlocalhost ~]# cat /etc/yum.repos.d/base.repo [Base…...

【JVM】Java虚拟机(二)——垃圾回收

目录 一、如何判断对象可以回收 &#xff08;一&#xff09;引用计数法 &#xff08;二&#xff09;可达性分析算法 二、垃圾回收算法 &#xff08;一&#xff09;标记清除 &#xff08;二&#xff09;标记整理 &#xff08;三&#xff09;复制 &#xff08;四&#xff…...

代码规范和架构【立芯理论一】(2025.06.08)

1、代码规范的目标 代码简洁精炼、美观&#xff0c;可持续性好高效率高复用&#xff0c;可移植性好高内聚&#xff0c;低耦合没有冗余规范性&#xff0c;代码有规可循&#xff0c;可以看出自己当时的思考过程特殊排版&#xff0c;特殊语法&#xff0c;特殊指令&#xff0c;必须…...

【Linux】自动化构建-Make/Makefile

前言 上文我们讲到了Linux中的编译器gcc/g 【Linux】编译器gcc/g及其库的详细介绍-CSDN博客 本来我们将一个对于编译来说很重要的工具&#xff1a;make/makfile 1.背景 在一个工程中源文件不计其数&#xff0c;其按类型、功能、模块分别放在若干个目录中&#xff0c;mak…...