При инициализации сервиса необходимо провалидировать конфигурацию согласно API,…
- User
При инициализации сервиса необходимо провалидировать конфигурацию согласно API, приведённому ниже.
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
Assistant
Ошибка возникает из-за того, что в вашем API схема валидации не корректно использует
allOfиoneOfдля проверки типа задания и соответствующей конфигурации. Вместо этого, вам нужно использоватьif-thenлогику, которая доступна в JSON Schema через ключевое словоif-then-else.Вот исправленный вариант 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 configuration: type: object allOf: - if: properties: type: const: universal_generation then: properties: configuration: $ref: '#/components/schemas/universalGenerationTaskConfiguration' - if: properties: type: const: custom_generation then: properties: configuration: $ref: '#/components/schemas/customGenerationTaskConfiguration' - if: properties: type: const: base_retrieval then: properties: configuration: $ref: '#/components/schemas/baseRetrievalTaskConfiguration' - if: properties: type: const: llm_retrieval then: properties: configuration: $ref: '#/components/schemas/llmRetrievalTaskConfiguration'Обратите внимание на следующие изменения:
- Удален
oneOf, так как он не нужен в этом случае. - Использован
allOfдля применения нескольких условий. - Добавлены блоки
if-thenдля каждого типа задания, которые проверяют тип задания и применяют соответствующую схему конфигурации.
Теперь, когда тип задания соответствует одному из заданных значений (
universal_generation,custom_generation,base_retrieval,llm_retrieval), будет применена соответствующая схема конфигурации.Также, убедитесь, что схемы конфигурации (
universalGenerationTaskConfiguration,customGenerationTaskConfiguration,baseRetrievalTaskConfiguration,llmRetrievalTaskConfiguration) правильно определены в вашем API.Например, схема
llmRetrievalTaskConfigurationможет выглядеть так:llmRetrievalTaskConfiguration: type: object properties: setting: type: string llm_enabled: type: boolean llm_params: type: object properties: model_name: type: string model_endpoint: type: string model_profanity_check: type: boolean temperature: type: number top_p: type: number repetition_penalty: type: number max_tokens: type: object properties: out_max_tokens: type: integer context_max_tokens: type: integer dialogue_max_tokens: type: integer max_user_messages: type: integer dialogue_crop_strategy: type: string prompts: type: object properties: system_prompt: type: string user_prompt: type: string output_format: type: object properties: key: type: string values: type: object additionalProperties: type: booleanС этими изменениями ваша схема валидации должна работать корректно.
- Удален
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.