При инициализации сервиса необходимо провалидировать конфигурацию согласно API,…
- User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
При инициализации сервиса необходимо провалидировать конфигурацию согласно API, приведённому ниже.
components:
schemas:
agentConfiguration:
description: Конфигурация скилла оценка качества
type: object
properties:
tasks:
type: array
description: Набор заданий для оценки качества
items:
type: object
required:
- name
- type
- configuration
properties:
name:
type: string
description: Название задачи - должно быть уникальным
type:
type: string
description: Тип задания
enum:
- universal_generation
- custom_generation
- base_retrieval
- llm_retrieval
allOf: # ДАЛЬШЕ НЕ УВЕРЕН ЧТО ДОЛЖНО РАБОТАТЬ ТАК:
- oneOf:
- type: object
properties:
type:
const: universal_generation
configuration:
ref: '#/components/schemas/universalGenerationTaskConfiguration'
required:
- configuration
- type: object
properties:
type:
const: custom_generation
configuration:
ref: '#/components/schemas/customGenerationTaskConfiguration'
required:
- configuration
- type: object
properties:
type:
const: base_retrieval
configuration:
ref: '#/components/schemas/baseRetrievalTaskConfiguration'
required:
- configuration
- type: object
properties:
type:
const: llm_retrieval
configuration:
ref: '#/components/schemas/llmRetrievalTaskConfiguration'
required:
- configuration
При этом если передавать на этапе валидации конфиги, выдаёт такую ошибку: ValueError: error configuration: {'type': 'llm_retrieval', 'name': 'relevance', 'configuration': {'setting': 'aboba', 'llm_enabled': True, 'llm_params': {'model_name': 'GigaChat-2-Max', 'model_endpoint': 'default', 'model_profanity_check': False, 'temperature': 1e-07, 'top_p': 1, 'repetition_penalty': 1}, 'max_tokens': {'out_max_tokens': 200000, 'context_max_tokens': 200000, 'dialogue_max_tokens': 200000}, 'max_user_messages': 1, 'dialogue_crop_strategy': 'tokens', 'prompts': {'system_prompt': "SYSTEM_PROMPT", 'user_prompt': 'USER_PROMPT'}, 'output_format': {'key': None, 'values': {'r': True, 's': True, 'i': False}}}} is valid under each of {'type': 'object', 'properties': {'type': {'const': 'llm_retrieval'}, 'configuration': {'ref': '#/components/schemas/llmRetrievalTaskConfiguration'}}, 'required': ['configuration']}, {'type': 'object', 'properties': {'type': {'const': 'custom_generation'}, 'configuration': {'ref': '#/components/schemas/customGenerationTaskConfiguration'}}, 'required': ['configuration']}
Скорректируй API
Проблема в вашей OpenAPI схеме связана с неправильным использованием allOf и oneOf. Вот исправленная версия:
components:
schemas:
agentConfiguration:
description: Конфигурация скилла оценка качества
type: object
properties:
tasks:
type: array
description: Набор заданий для оценки качества
items:
oneOf:
- type: object
required:
- name
- type
- configuration
properties:
name:
type: string
description: Название задачи - должно быть уникальным
type:
const: universal_generation
description: Тип задания
configuration:
$ref: '#/components/schemas/universalGenerationTaskConfiguration'
- type: object
required:
- name
- type
- configuration
properties:
name:
type: string
description: Название задачи - должно быть уникальным
type:
const: custom_generation
description: Тип задания
configuration:
$ref: '#/components/schemas/customGenerationTaskConfiguration'
- type: object
required:
- name
- type
- configuration
properties:
name:
type: string
description: Название задачи - должно быть уникальным
type:
const: base_retrieval
description: Тип задания
configuration:
$ref: '#/components/schemas/baseRetrievalTaskConfiguration'
- type: object
required:
- name
- type
- configuration
properties:
name:
type: string
description: Название задачи - должно быть уникальным
type:
const: llm_retrieval
description: Тип задания
configuration:
$ref: '#/components/schemas/llmRetrievalTaskConfiguration'
discriminator:
propertyName: type
mapping:
universal_generation: '#/components/schemas/universalGenerationTask'
custom_generation: '#/components/schemas/customGenerationTask'
base_retrieval: '#/components/schemas/baseRetrievalTask'
llm_retrieval: '#/components/schemas/llmRetrievalTask'
Основные изменения:
Убрал allOf - он здесь не нужен, так как allOf означает, что объект должен соответствовать ВСЕМ схемам одновременно, что невозможно при разных значениях type.
Переместил oneOf на уровень items - теперь каждый элемент массива должен соответствовать одной из четырёх схем.
Использовал const вместо enum для поля type в каждой схеме, так как для каждого варианта есть только одно допустимое значение.
Добавил discriminator (опционально) - это помогает валидаторам быстрее определить, какую схему использовать, основываясь на значении поля type.
Альтернативный, более компактный вариант с использованием композиции:
components:
schemas:
agentConfiguration:
description: Конфигурация скилла оценка качества
type: object
properties:
tasks:
type: array
description: Набор заданий для оценки качества
items:
$ref: '#/components/schemas/task'
task:
oneOf:
- $ref: '#/components/schemas/universalGenerationTask'
- $ref: '#/components/schemas/customGenerationTask'
- $ref: '#/components/schemas/baseRetrievalTask'
- $ref: '#/components/schemas/llmRetrievalTask'
discriminator:
propertyName: type
baseTask:
type: object
required:
- name
- type
- configuration
properties:
name:
type: string
description: Название задачи - должно быть уникальным
universalGenerationTask:
allOf:
- $ref: '#/components/schemas/baseTask'
- type: object
properties:
type:
const: universal_generation
configuration:
$ref: '#/components/schemas/universalGenerationTaskConfiguration'
customGenerationTask:
allOf:
- $ref: '#/components/schemas/baseTask'
- type: object
properties:
type:
const: custom_generation
configuration:
$ref: '#/components/schemas/customGenerationTaskConfiguration'
baseRetrievalTask:
allOf:
- $ref: '#/components/schemas/baseTask'
- type: object
properties:
type:
const: base_retrieval
configuration:
$ref: '#/components/schemas/baseRetrievalTaskConfiguration'
llmRetrievalTask:
allOf:
- $ref: '#/components/schemas/baseTask'
- type: object
properties:
type:
const: llm_retrieval
configuration:
$ref: '#/components/schemas/llmRetrievalTaskConfiguration'
Этот вариант более модульный и избегает дублирования кода для общих полей.