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

Azure OpenAI Swagger Validation Failure with APIM

题意:Azure OpenAI Swagger 验证失败与 APIM

问题背景:

I'm converting the Swagger for Azure OpenAI API Version 2023-07-01-preview from json to yaml

我正在将 Azure OpenAI API 版本 2023-07-01-preview 的 Swagger 从 JSON 转换为 YAML。

My Swagger looks like this        我的 Swagger 看起来是这样的

openapi: 3.0.1
info:title: OpenAI Models APIdescription: ''version: '123'
servers:- url: https://def.com/openai
paths:/gpt-35-turbo/chat/completions:post:tags:- openaisummary: Creates a completion for the chat messagedescription: gpt-35-turbo-chat-completionoperationId: GPT_35_Turbo_ChatCompletions_CreaterequestBody:required: truecontent:application/json:schema:$ref: '#/components/schemas/createChatCompletionRequest'responses:'200':description: OKcontent:application/json:schema:$ref: '#/components/schemas/createChatCompletionResponse'headers:apim-request-id:description: Request ID for troubleshooting purposesschema:type: stringdefault:description: Service unavailablecontent:application/json:schema:$ref: '#/components/schemas/errorResponse'headers:apim-request-id:description: Request ID for troubleshooting purposesschema:type: string
components:schemas:errorResponse:type: objectproperties:error:$ref: '#/components/schemas/error'errorBase:type: objectproperties:code:type: stringmessage:type: stringerror:type: objectallOf:- $ref: '#/components/schemas/errorBase'properties:code:type: stringmessage:type: stringparam:type: stringtype:type: stringinner_error:$ref: '#/components/schemas/innerError'innerError:description: Inner error with additional details.type: objectproperties:code:$ref: '#/components/schemas/innerErrorCode'content_filter_results:$ref: '#/components/schemas/contentFilterResults'innerErrorCode:description: Error codes for the inner error object.enum:- ResponsibleAIPolicyViolationtype: stringx-ms-enum:name: InnerErrorCodemodelAsString: truevalues:- value: ResponsibleAIPolicyViolationdescription: The prompt violated one of more content filter rules.  contentFilterResult:type: objectproperties:severity:type: stringenum:- safe- low- medium- highx-ms-enum:name: ContentFilterSeveritymodelAsString: truevalues:- value: safedescription: >-General content or related content in generic or non-harmfulcontexts.- value: lowdescription: Harmful content at a low intensity and risk level.- value: mediumdescription: Harmful content at a medium intensity and risk level.- value: highdescription: Harmful content at a high intensity and risk level.filtered:type: booleanrequired:- severity- filteredcontentFilterResults:type: objectdescription: >-Information about the content filtering category (hate, sexual,violence, self_harm), if it has been detected, as well as the severitylevel (very_low, low, medium, high-scale that determines the intensityand risk level of harmful content) and if it has been filtered or not.properties:sexual:$ref: '#/components/schemas/contentFilterResult'violence:$ref: '#/components/schemas/contentFilterResult'hate:$ref: '#/components/schemas/contentFilterResult'self_harm:$ref: '#/components/schemas/contentFilterResult'error:$ref: '#/components/schemas/errorBase'promptFilterResult:type: objectdescription: Content filtering results for a single prompt in the request.properties:prompt_index:type: integercontent_filter_results:$ref: '#/components/schemas/contentFilterResults'promptFilterResults:type: arraydescription: >-Content filtering results for zero or more prompts in the request. In astreaming request, results for different prompts may arrive at differenttimes or in different orders.items:$ref: '#/components/schemas/promptFilterResult'  createChatCompletionRequest:type: objectallOf:- $ref: '#/components/schemas/chatCompletionsRequestCommon'- properties:messages:description: >-A list of messages comprising the conversation so far. [ExamplePythoncode](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb).type: arrayminItems: 1items:$ref: '#/components/schemas/chatCompletionRequestMessage'functions:description: A list of functions the model may generate JSON inputs for.type: arrayminItems: 1items:$ref: '#/components/schemas/chatCompletionFunctions'function_call:description: >-Controls how the model responds to function calls. "none" meansthe model does not call a function, and responds to theend-user. "auto" means the model can pick between an end-user orcalling a function.  Specifying a particular function via`{"name":\ "my_function"}` forces the model to call thatfunction. "none" is the default when no functions are present."auto" is the default if functions are present.oneOf:- type: stringenum:- none- auto- type: objectproperties:name:type: stringdescription: The name of the function to call.required:- name'n':type: integerminimum: 1maximum: 128default: 1example: 1nullable: truedescription: >-How many chat completion choices to generate for each inputmessage.required:- messages    chatCompletionsRequestCommon:type: objectproperties:temperature:description: >-What sampling temperature to use, between 0 and 2. Higher valueslike 0.8 will make the output more random, while lower values like0.2 will make it more focused and deterministic.We generally recommend altering this or `top_p` but not both.type: numberminimum: 0maximum: 2default: 1example: 1nullable: truetop_p:description: >-An alternative to sampling with temperature, called nucleussampling, where the model considers the results of the tokens withtop_p probability mass. So 0.1 means only the tokens comprising thetop 10% probability mass are considered.We generally recommend altering this or `temperature` but not both.type: numberminimum: 0maximum: 1default: 1example: 1nullable: truestop:description: Up to 4 sequences where the API will stop generating further tokens.oneOf:- type: stringnullable: true- type: arrayitems:type: stringnullable: falseminItems: 1maxItems: 4description: Array minimum size of 1 and maximum of 4default: nullmax_tokens:description: >-The maximum number of tokens allowed for the generated answer. Bydefault, the number of tokens the model can return will be (4096 -prompt tokens).type: integerdefault: 4096presence_penalty:description: >-Number between -2.0 and 2.0. Positive values penalize new tokensbased on whether they appear in the text so far, increasing themodel's likelihood to talk about new topics.type: numberdefault: 0minimum: -2maximum: 2frequency_penalty:description: >-Number between -2.0 and 2.0. Positive values penalize new tokensbased on their existing frequency in the text so far, decreasing themodel's likelihood to repeat the same line verbatim.type: numberdefault: 0minimum: -2maximum: 2logit_bias:description: >-Modify the likelihood of specified tokens appearing in thecompletion. Accepts a json object that maps tokens (specified bytheir token ID in the tokenizer) to an associated bias value from-100 to 100. Mathematically, the bias is added to the logitsgenerated by the model prior to sampling. The exact effect will varyper model, but values between -1 and 1 should decrease or increaselikelihood of selection; values like -100 or 100 should result in aban or exclusive selection of the relevant token.type: objectnullable: trueuser:description: >-A unique identifier representing your end-user, which can help AzureOpenAI to monitor and detect abuse.type: stringexample: user-1234nullable: falsechatCompletionRequestMessage:type: objectproperties:role:type: stringenum:- system- user- assistant- functiondescription: >-The role of the messages author. One of `system`, `user`,`assistant`, or `function`.content:type: stringdescription: >-The contents of the message. `content` is required for all messagesexcept assistant messages with function calls.name:type: stringdescription: >-The name of the author of this message. `name` is required if roleis `function`, and it should be the name of the function whoseresponse is in the `content`. May contain a-z, A-Z, 0-9, andunderscores, with a maximum length of 64 characters.function_call:type: objectdescription: >-The name and arguments of a function that should be called, asgenerated by the model.properties:name:type: stringdescription: The name of the function to call.arguments:type: stringdescription: >-The arguments to call the function with, as generated by themodel in JSON format. Note that the model does not alwaysgenerate valid JSON, and may hallucinate parameters not definedby your function schema. Validate the arguments in your codebefore calling your function.required:- rolecreateChatCompletionResponse:type: objectallOf:- $ref: '#/components/schemas/chatCompletionsResponseCommon'- properties:prompt_filter_results:$ref: '#/components/schemas/promptFilterResults'choices:type: arrayitems:type: objectallOf:- $ref: '#/components/schemas/chatCompletionChoiceCommon'- properties:message:$ref: '#/components/schemas/chatCompletionResponseMessage'content_filter_results:$ref: '#/components/schemas/contentFilterResults'required:- id- object- created- model- choices                chatCompletionFunctions:type: objectproperties:name:type: stringdescription: >-The name of the function to be called. Must be a-z, A-Z, 0-9, orcontain underscores and dashes, with a maximum length of 64.description:type: stringdescription: The description of what the function does.parameters:$ref: '#/components/schemas/chatCompletionFunctionParameters'required:- namechatCompletionFunctionParameters:type: objectdescription: >-The parameters the functions accepts, described as a JSON Schema object.See the [guide](/docs/guides/gpt/function-calling) for examples, and the[JSON Schemareference](https://json-schema.org/understanding-json-schema/) fordocumentation about the format.additionalProperties: truechatCompletionsResponseCommon:type: objectproperties:id:type: stringobject:type: stringcreated:type: integerformat: unixtimemodel:type: stringusage:type: objectproperties:prompt_tokens:type: integercompletion_tokens:type: integertotal_tokens:type: integerrequired:- prompt_tokens- completion_tokens- total_tokensrequired:- id- object- created- modelchatCompletionChoiceCommon:type: objectproperties:index:type: integerfinish_reason:type: stringchatCompletionResponseMessage:type: objectproperties:role:type: stringenum:- system- user- assistant- functiondescription: The role of the author of this message.content:type: stringdescription: The contents of the message.function_call:type: objectdescription: >-The name and arguments of a function that should be called, asgenerated by the model.properties:name:type: stringdescription: The name of the function to call.arguments:type: stringdescription: >-The arguments to call the function with, as generated by themodel in JSON format. Note that the model does not alwaysgenerate valid JSON, and may hallucinate parameters not definedby your function schema. Validate the arguments in your codebefore calling your function.required:- role          securitySchemes:apiKeyHeader:type: apiKeyname: Ocp-Apim-Subscription-Keyin: headerapiKeyQuery:type: apiKeyname: subscription-keyin: query
security:- apiKeyHeader: [ ]- apiKeyQuery: [ ]

I used this in azure apim and validating the content like this

我在 Azure APIM 中使用了这个,并像这样验证内容。

<validate-content unspecified-content-type-action="ignore" max-size="102400" size-exceeded-action="detect" errors-variable-name="requestBodyValidation"><content type="application/json" validate-as="json" action="prevent" allow-additional-properties="false" /></validate-content>

Now I tried to give the request like the actual property

现在我尝试像实际属性一样提供请求。

{"messages": [{"role": "user", "content": "Find beachfront hotels in San Diego for less than $300 a month with free breakfast."}],"temperature": 1,"top_p": 1,"stop": "","max_tokens": 2000,"presence_penalty": 0,"frequency_penalty": 0,"logit_bias": {},"user": "user-1234","n": 1,"function_call" : "auto","functions" : [{"name": "search_hotels","description": "Retrieves hotels from the search index based on the parameters provided","parameters": {"type": "object","properties": {"location": {"type": "string","description": "The location of the hotel (i.e. Seattle, WA)"},"max_price": {"type": "number","description": "The maximum price for the hotel"},"features": {"type": "string","description": "A comma separated list of features (i.e. beachfront, free wifi, etc.)"}},"required": ["location"]}}]
}

And the APIM is giving the error like

而 APIM 给出了如下错误:

{"statusCode": 400,"message": "Body of the request does not conform to the definition which is associated with the content type application/json. JSON does not match all schemas from 'allOf'. Invalid schema indexes: 0, 1. Line: 42, Position: 1"
}

But the same request is working when I directly hit the azure openai.

但当我直接请求 Azure OpenAI 时,同样的请求是有效的。

What could be the possible issue here ?

这里可能是什么问题?

问题解决:

I believe your problem is this line allow-additional-properties="false"

我认为你遇到的问题是这一行 allow-additional-properties="false"

allow-additional-properties Boolean. For a JSON schema, specifies whether to implement a runtime override of the additionalProperties value configured in the schema:

  • true: allow additional properties in the request or response body, even if the JSON schema's additionalProperties field is configured to not allow additional properties.

true:允许在请求或响应主体中添加额外的属性,即使 JSON 模式的 additionalProperties 字段配置为不允许额外属性。

  • false: do not allow additional properties in the request or response body, even if the JSON schema's additionalProperties field is configured to allow additional properties

false:不允许在请求或响应主体中添加额外的属性,即使 JSON 模式的 additionalProperties 字段配置为允许额外属性。

If the attribute isn't specified, the policy validates additional properties according to configuration of the additionalProperties field in the schema.

如果未指定该属性,则策略将根据模式中 additionalProperties 字段的配置来验证额外属性。

source:    来源        https://learn.microsoft.com/en-us/azure/api-management/validate-content-policy#content-attributes

This property overrides your JSON Schema. Even though your allOf definition does not use additionalProperties: false, apim will inject this constraint to the root schema, which translates to

此属性会覆盖你的 JSON Schema。即使你的 allOf 定义没有使用 additionalProperties: false,APIM 仍会将此约束注入到根模式中,这会转化为

{"type": "object","additionalProperties": false,"allOf": [{...}, {...}]
}

This schema doesn't allow any properties to be validated because no properties are defined at the root.

该模式不允许验证任何属性,因为根本没有定义属性。

The only valid schemas in this situation would be

在这种情况下,唯一有效的模式是

{}ORtrue

There are a few ways to tackle this but IMHO, the best option is to use the schema definition, rather than the apim attribute because you're introducing constraints on the schema where they are not defined. If someone else were to review the schema, they would run into the same issue you are having.

解决这个问题有几种方法,但依我看来,最好的选择是使用模式定义,而不是使用 APIM 属性,因为你在模式中引入了未定义的约束。如果其他人来审查这个模式,他们也会遇到你现在面临的相同问题。

This is where it may get tricky for you depending on which version of JSON Schema is supported in APIM and which version you are using.

这可能会变得棘手,具体取决于 APIM 支持的 JSON Schema 版本以及你正在使用的版本。

Draft-04 - 07 requires some massaging to the schema, in most circumstances, to achieve the desired behavior of using allOf with additionalProperties": false

在大多数情况下,Draft-04 到 Draft-07 需要对模式进行一些调整,以实现使用 allOfadditionalProperties: false 的预期行为。

  • turn off the content attribute in your apim validation

在你的 APIM 验证中关闭 content 属性。

  • add all properties of the first depth of subschemas to the root with an empty schema. This will allow the validator to recognize those properties at the root level to satisfy additionalProperties

将所有子模式第一层的属性添加到根模式中,并使用一个空模式。这将允许验证器在根级别识别这些属性,以满足 additionalProperties 的要求。

{"$schema": "http://json-schema.org/draft-07/schema#","type": "object","additionalProperties": false,"properties": {"messages": {},"temperature": {},"top_p": {},"stop": {},"max_tokens": {},"presence_penalty": {},"frequency_penalty": {},"logit_bias": {},"user": { },"n": { },"function_call": { },"functions": { }},"allOf": [{"type": "object","properties": {"temperature": {},"top_p": {},"stop": {},"max_tokens": {},"presence_penalty": {},"frequency_penalty": {},"logit_bias": {},"user": {}}},{"type": "object","properties": {"messages": {},"n": {},"function_call": {},"functions": {}}}]
}

If you're using JSON Schema draft 2019-09 or later, you can use the newer keyword unevaluatedProperties which performs the behavior described above, automatically.

如果你使用的是 JSON Schema draft 2019-09 或更高版本,你可以使用较新的关键字 unevaluatedProperties,它会自动执行上述描述的行为。

{"$schema": "https://json-schema.org/draft/2019-09/schema","type": "object","unevaluatedProperties": false,"allOf": [{"type": "object","properties": {"temperature": {},"top_p": {},"stop": {},"max_tokens": {},"presence_penalty": {},"frequency_penalty": {},"logit_bias": {},"user": {}}},{"type": "object","properties": {"messages": {},"n": {},"function_call": {},"functions": {}}}]
}

This example fails:        这个示例失败了

{"messages": [{"role": "user", "content": "Find beachfront hotels in San Diego for less than $300 a month with free breakfast."}],"stackOverflow": -1
}
Invalid# fails schema constraint https://json-schema.hyperjump.io/schema#/unevaluatedProperties#/stackOverflow fails schema constraint https://json-schema.hyperjump.io/schema#/unevaluatedProperties

 

相关文章:

Azure OpenAI Swagger Validation Failure with APIM

题意&#xff1a;Azure OpenAI Swagger 验证失败与 APIM 问题背景&#xff1a; Im converting the Swagger for Azure OpenAI API Version 2023-07-01-preview from json to yaml 我正在将 Azure OpenAI API 版本 2023-07-01-preview 的 Swagger 从 JSON 转换为 YAML。 My S…...

haproxy高级功能配置

介绍HAProxy高级配置及实用案例 一.基于cookie会话保持 cookie value:为当前server指定cookie值&#xff0c;实现基于cookie的会话黏性&#xff0c;相对于基于 source 地址hash 调度算法对客户端的粒度更精准&#xff0c;但同时也加大了haproxy负载&#xff0c;目前此模式使用…...

XXL-JOB分布式定时任务框架快速入门

文章目录 前言定时任务分布式任务调度 1、XXL-JOB介绍1.1 XXL-JOB概述1.2 XXL-JOB特性1.3 整体架构 2、XXL-JOB任务中心环境搭建2.1 XXL-JOB源码下载2.2 IDEA导入xxljob工程2.3 初始化数据库2.4 Docker安装任务管理中心 3、XXL-JOB任务注册测试3.1 引入xxl-job核心依赖3.2 配置…...

直流电机及其驱动

直流电机是一种将电能转换为机械能的装置&#xff0c;有两个电极&#xff0c;当电极正接时&#xff0c;电机正转&#xff0c;当电极反接时&#xff0c;电机反转。 直流电机属于大功率器件&#xff0c;GPIO口无法直接驱动&#xff0c;需要配合电机驱动电路来操作 TB6612是一款双…...

Java-判断一个字符串是否为有效的JSON字符串

在 Java 中判断一个字符串是否为有效的 JSON 字符串&#xff0c;可以使用不同的库来进行验证。常见的库 包括 org.json、com.google.gson 和 com.alibaba.fastjson 等。这里我将展示如何使用 com.alibaba.fastjson 库来实现一个简单的工具类&#xff0c;用于判断给定的字符串…...

FPGA开发板的基本知识及应用

FPGA开发板是一种专门设计用于开发和测试现场可编程门阵列(Field-Programmable Gate Array, FPGA)的硬件平台。FPGA是一种高度可配置的集成电路&#xff0c;能够在制造后被编程以执行各种数字逻辑功能。FPGA开发板通常包含一个FPGA芯片以及一系列支持电路和接口&#xff0c;以便…...

JVM知识总结(性能调优)

文章收录在网站&#xff1a;http://hardyfish.top/ 文章收录在网站&#xff1a;http://hardyfish.top/ 文章收录在网站&#xff1a;http://hardyfish.top/ 文章收录在网站&#xff1a;http://hardyfish.top/ 性能调优 何时进行JVM调优&#xff1f; 遇到以下情况&#xff0c…...

基于Ascend C的Matmul算子性能优化最佳实践

矩阵乘法是深度学习计算中的基础操作&#xff0c;对于提升模型训练和推理速度至关重要。昇腾AI处理器是一款专门面向AI领域的AI加速器&#xff0c;其AI Core采用达芬奇架构&#xff0c;以高性能Cube计算引擎为基础&#xff0c;针对矩阵运算进行加速&#xff0c;可大幅提高单位面…...

SQL注入之EVAL长度限制突破技巧

要求&#xff1a; PHP Eval函数参数限制在16个字符的情况下 &#xff0c;如何拿到Webshell&#xff1f; widows小皮环境搭建&#xff1a; 使用phpstudy搭建一个网站。 随后在该eval文件夹下创建一个webshell.php文件&#xff0c;并在其输入代码环境 解题思路&#xff1a; 通…...

稀疏注意力:时间序列预测的局部性和Transformer的存储瓶颈

时间序列预测是许多领域的重要问题&#xff0c;包括对太阳能发电厂发电量、电力消耗和交通拥堵情况的预测。在本文中&#xff0c;提出用Transformer来解决这类预测问题。虽然在我们的初步研究中对其性能印象深刻&#xff0c;但发现了它的两个主要缺点:(1)位置不可知性:规范Tran…...

详谈系统中的环境变量

目录 前言1. 指令背后的本质2. 环境变量背后的本质3. 环境变量到底是什么4. 命令行参数5. 本地变量 与 内置命令6. 环境变量的相关命令 前言 相信在 it 行业学习或者工作的小伙伴们&#xff0c;基本都配置过环境变量&#xff08;windows环境下&#xff09;&#xff0c;如果你也…...

RAG与LLM原理及实践(11)--- Milvus hybrid search 源码分析及思想

目录 背景 hybrid search 源码分析 WeightedRanker 源码 hybrid search 核心 参数详解 基本入参 扩展入参 aysnc方式代码调用案例 说明 源码逻辑 prepare 调用过程 stub 调用结果 stub 调用过程 blocking 与 async 调用方式 深入内部core weightedRanker 的ch…...

JavaScript模拟空调效果

JavaScript模拟空调效果https://www.bootstrapmb.com/item/15074 在JavaScript中模拟空调效果主要依赖于前端界面的交互和状态变化&#xff0c;因为实际的温度调节、风扇速度调整等硬件操作无法直接通过JavaScript在浏览器中实现。不过&#xff0c;我们可以通过JavaScript来模…...

14.2 Pandas数据处理

欢迎来到我的博客,很高兴能够在这里和您见面!欢迎订阅相关专栏: 工💗重💗hao💗:野老杂谈 ⭐️ 全网最全IT互联网公司面试宝典:收集整理全网各大IT互联网公司技术、项目、HR面试真题. ⭐️ AIGC时代的创新与未来:详细讲解AIGC的概念、核心技术、应用领域等内容。 ⭐…...

python学习7---多进程

一、介绍 多进程是指在同一程序中创建多个独立的进程来执行任务。每个进程都有自己独立的内存空间&#xff0c;相互之间不干扰。 因为GIL锁的存在&#xff0c;对于CPU密集型任务&#xff08;例如计算密集型操作&#xff09;&#xff0c;使用多进程可以提高程序的效率。 优点&am…...

基于Spring + Vue的旅游景区项目+源代码+文档说明

文章目录 源代码下载地址项目介绍项目功能界面预览 项目备注源代码下载地址 源代码下载地址 点击这里下载源码 项目介绍 基于Spring Vue的旅游景区项目 项目功能 民宿管理员&#xff1a;订单数量统计&#xff0c;订单交易额统计&#xff0c;客房统计饼图&#xff0c;酒店…...

Java后端面试题

Redis缓存穿透、雪崩、击穿&#xff0c;布隆过滤器 一致性hash 一致性hash sharding-jdbc实现一致性hash #一致性hash, 应用在mysql数据库的分库分表上&#xff0c; 现在已经完成了分库分表&#xff0c; 现在的问题出现了&#xff0c; 需要继续新增数据库节点&#xff0c; 请…...

【Git】远程仓库新建分支后,拉到本地开发

1. 在远程仓库上创建分支 2. git fetch origin&#xff1a;在本地同步远程仓库的分支&#xff08;获取远程仓库所有分支的所有修改&#xff09; 3. git remote -a&#xff1a;查看所有分支&#xff08;远程&#xff0b;本地&#xff09; 4. git checkout -b 本地名 远程仓库…...

React H5设置企业级v6版本路由的配置

路由配置是项目开发的必要一环&#xff0c;尤其是目前流行SPA&#xff0c;下面看看如何使用v6版本路由进行合理的H5路由配置 一、基本页面结构&#xff08;目录根据开发要求建&#xff0c;下面仅用于展示配置路由&#xff09; 二、具体文件实现 1. index.tsx import React f…...

【微信小程序】全局配置

1. 全局配置文件及常用的配置项 2.window (1).小程序窗口的组成部分 (2). 了解 window 节点常用的配置项 (3). 设置导航栏的标题 (4). 设置导航栏的背景色 (5). 设置导航栏的标题颜色 (6). 全局开启下拉刷新功能 (7). 设置下拉刷新时窗口的背景色 (8).设置下拉刷新时 loading …...

后进先出(LIFO)详解

LIFO 是 Last In, First Out 的缩写&#xff0c;中文译为后进先出。这是一种数据结构的工作原则&#xff0c;类似于一摞盘子或一叠书本&#xff1a; 最后放进去的元素最先出来 -想象往筒状容器里放盘子&#xff1a; &#xff08;1&#xff09;你放进的最后一个盘子&#xff08…...

深度学习在微纳光子学中的应用

深度学习在微纳光子学中的主要应用方向 深度学习与微纳光子学的结合主要集中在以下几个方向&#xff1a; 逆向设计 通过神经网络快速预测微纳结构的光学响应&#xff0c;替代传统耗时的数值模拟方法。例如设计超表面、光子晶体等结构。 特征提取与优化 从复杂的光学数据中自…...

在鸿蒙HarmonyOS 5中实现抖音风格的点赞功能

下面我将详细介绍如何使用HarmonyOS SDK在HarmonyOS 5中实现类似抖音的点赞功能&#xff0c;包括动画效果、数据同步和交互优化。 1. 基础点赞功能实现 1.1 创建数据模型 // VideoModel.ets export class VideoModel {id: string "";title: string ""…...

Vue3 + Element Plus + TypeScript中el-transfer穿梭框组件使用详解及示例

使用详解 Element Plus 的 el-transfer 组件是一个强大的穿梭框组件&#xff0c;常用于在两个集合之间进行数据转移&#xff0c;如权限分配、数据选择等场景。下面我将详细介绍其用法并提供一个完整示例。 核心特性与用法 基本属性 v-model&#xff1a;绑定右侧列表的值&…...

家政维修平台实战20:权限设计

目录 1 获取工人信息2 搭建工人入口3 权限判断总结 目前我们已经搭建好了基础的用户体系&#xff0c;主要是分成几个表&#xff0c;用户表我们是记录用户的基础信息&#xff0c;包括手机、昵称、头像。而工人和员工各有各的表。那么就有一个问题&#xff0c;不同的角色&#xf…...

Java多线程实现之Callable接口深度解析

Java多线程实现之Callable接口深度解析 一、Callable接口概述1.1 接口定义1.2 与Runnable接口的对比1.3 Future接口与FutureTask类 二、Callable接口的基本使用方法2.1 传统方式实现Callable接口2.2 使用Lambda表达式简化Callable实现2.3 使用FutureTask类执行Callable任务 三、…...

C# 类和继承(抽象类)

抽象类 抽象类是指设计为被继承的类。抽象类只能被用作其他类的基类。 不能创建抽象类的实例。抽象类使用abstract修饰符声明。 抽象类可以包含抽象成员或普通的非抽象成员。抽象类的成员可以是抽象成员和普通带 实现的成员的任意组合。抽象类自己可以派生自另一个抽象类。例…...

BCS 2025|百度副总裁陈洋:智能体在安全领域的应用实践

6月5日&#xff0c;2025全球数字经济大会数字安全主论坛暨北京网络安全大会在国家会议中心隆重开幕。百度副总裁陈洋受邀出席&#xff0c;并作《智能体在安全领域的应用实践》主题演讲&#xff0c;分享了在智能体在安全领域的突破性实践。他指出&#xff0c;百度通过将安全能力…...

Redis数据倾斜问题解决

Redis 数据倾斜问题解析与解决方案 什么是 Redis 数据倾斜 Redis 数据倾斜指的是在 Redis 集群中&#xff0c;部分节点存储的数据量或访问量远高于其他节点&#xff0c;导致这些节点负载过高&#xff0c;影响整体性能。 数据倾斜的主要表现 部分节点内存使用率远高于其他节…...

laravel8+vue3.0+element-plus搭建方法

创建 laravel8 项目 composer create-project --prefer-dist laravel/laravel laravel8 8.* 安装 laravel/ui composer require laravel/ui 修改 package.json 文件 "devDependencies": {"vue/compiler-sfc": "^3.0.7","axios": …...