[AI Infra] Adds new temperature parameter to AI Connector and OpenAI, Bedrock, Gemini connectors#239806
Conversation
| @@ -338,6 +436,7 @@ export const AdditionalOptionsFields: React.FC<AdditionalOptionsFieldsProps> = ( | |||
| </UseField> | |||
| <EuiSpacer size="m" /> | |||
| {contextWindowLengthSettings} | |||
There was a problem hiding this comment.
Is temperature something that can be set with every connector or just when using chat_completion task type?
There was a problem hiding this comment.
Probably just chat_completion or completion 👀
There was a problem hiding this comment.
Yeah I assume it only makes sense for those two task types
| @@ -338,6 +436,7 @@ export const AdditionalOptionsFields: React.FC<AdditionalOptionsFieldsProps> = ( | |||
| </UseField> | |||
| <EuiSpacer size="m" /> | |||
| {contextWindowLengthSettings} | |||
There was a problem hiding this comment.
Yeah I assume it only makes sense for those two task types
| if (isNaN(numValue) || numValue < 0 || numValue > 1) { | ||
| return { | ||
| code: 'ERR_FIELD_INVALID', | ||
| path, | ||
| message: LABELS.TEMPERATURE_VALIDATION_MESSAGE, | ||
| }; |
There was a problem hiding this comment.
I don't think temperature is capped to 1. Note that the max value may depend on the provider and model 🙈. But it's probably fine to let them pick whatever they want here. Worth case it breaks when using the connector with an explicit error (which is the case) and the customer can just edit it again.
| return { temperature: connector.config.temperature }; | ||
| } | ||
|
|
||
| if (temperature === undefined || temperature < 0 || temperature > 1) return {}; |
There was a problem hiding this comment.
Same remark about max value
| // If user sets temperature in the connector config, use it by default | ||
| if (connector?.config?.temperature) { | ||
| return { temperature: connector.config.temperature }; | ||
| } |
There was a problem hiding this comment.
So - the approach is fine for any usage of the GenAI connectors going through the inference plugin.
This new temperature config param will not be used when calling the connectors directly. I'm not sure this is a problem, given the inference plugin is the recommended way of calling LLMs from Kibana, but I just wanted to make sure we were aware of it.
There was a problem hiding this comment.
Yeah I'm trying to support for those connectors not going through the inference plugin too for this PR but it's a bit time consuming, so maybe a follow up is fine. Thank you for bringing this up!
|
Pinging @elastic/ml-ui (:ml) |
|
Pinging @elastic/appex-ai-infra (Team:AI Infra) |
|
|
||
| const temperatureSettings = useMemo( | ||
| () => | ||
| taskTypeOptions?.some((option) => option.id === CHAT_COMPLETION_TASK_TYPE) || |
There was a problem hiding this comment.
Since this is only compatible with chat completion, then we should enforce that in the UI by only showing this setting if chat completion is selected.
|
Tested AI Connector (openAI provider) and confirmed temperature is sent along correctly. |
stephmilovic
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the improvement!
| import { FormattedMessage } from '@kbn/i18n-react'; | ||
| import * as i18n from './translations'; | ||
|
|
||
| export const temperatureField: ConfigFieldSchema = { |
There was a problem hiding this comment.
no,by design. Default value is meant to be undefined (defaulting to the provider's native default)
|
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Public APIs missing comments
Async chunks
History
cc @qn895 |
… Bedrock, Gemini connectors (elastic#239806) ## Summary Follow up of elastic#239626. This PR addresses elastic#239181. If a user defines/sets a temperature at the connector level, the connector's temperature will override the Kibana's default temperature for each connector. If temperature is not explicitly set by a user, then we respect the the temperature set by the request. AI connector <img width="866" height="880" alt="Screenshot 2025-10-28 at 09 16 29" src="https://github.com/user-attachments/assets/e5d28754-0b4d-46df-99b7-43c26bb9ab5a" /> <img width="866" height="880" alt="Screenshot 2025-10-28 at 09 20 18" src="https://github.com/user-attachments/assets/71e3a125-e8a3-4bd9-a04d-c34b29e0b7a1" /> <img width="866" height="880" alt="Screenshot 2025-10-28 at 09 18 18" src="https://github.com/user-attachments/assets/6fa62eb0-24dc-4245-bc3f-a84fa10b34c4" /> <img width="866" height="880" alt="Screenshot 2025-10-28 at 09 18 03" src="https://github.com/user-attachments/assets/b60391fd-f23f-40c5-b8a8-87c419f5b2c6" /> Before: <img width="1896" height="1386" alt="image" src="https://github.com/user-attachments/assets/6213ee44-d53e-440e-95c3-ac1abaded3c0" /> After: ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Melissa <melissa.alvarez@elastic.co>
… Bedrock, Gemini connectors (elastic#239806) ## Summary Follow up of elastic#239626. This PR addresses elastic#239181. If a user defines/sets a temperature at the connector level, the connector's temperature will override the Kibana's default temperature for each connector. If temperature is not explicitly set by a user, then we respect the the temperature set by the request. AI connector <img width="866" height="880" alt="Screenshot 2025-10-28 at 09 16 29" src="https://github.com/user-attachments/assets/e5d28754-0b4d-46df-99b7-43c26bb9ab5a" /> <img width="866" height="880" alt="Screenshot 2025-10-28 at 09 20 18" src="https://github.com/user-attachments/assets/71e3a125-e8a3-4bd9-a04d-c34b29e0b7a1" /> <img width="866" height="880" alt="Screenshot 2025-10-28 at 09 18 18" src="https://github.com/user-attachments/assets/6fa62eb0-24dc-4245-bc3f-a84fa10b34c4" /> <img width="866" height="880" alt="Screenshot 2025-10-28 at 09 18 03" src="https://github.com/user-attachments/assets/b60391fd-f23f-40c5-b8a8-87c419f5b2c6" /> Before: <img width="1896" height="1386" alt="image" src="https://github.com/user-attachments/assets/6213ee44-d53e-440e-95c3-ac1abaded3c0" /> After: ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Melissa <melissa.alvarez@elastic.co>
Summary
Follow up of #239626. This PR addresses #239181.
If a user defines/sets a temperature at the connector level, the connector's temperature will override the Kibana's default temperature for each connector. If temperature is not explicitly set by a user, then we respect the the temperature set by the request.
AI connector

Before:

After:
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:breakinglabel should be applied in these situations.release_note:*label is applied per the guidelinesbackport:*labels.Identify risks
Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss.
Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging.