[Obs AI Assistant] Default to "native" function calling if the connector config is not exposed (#210455)

Closes https://github.com/elastic/kibana/issues/210451

## Summary

If the connector config is not exposed (e.g.: in a pre-configured
connector), default to `native` function calling.


### Checklist

- [x] [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
- [x] 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)
This commit is contained in:
Viduni Wickramarachchi 2025-02-11 07:47:15 -05:00 committed by GitHub
parent 4f5ee4ff72
commit d36df89025
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View file

@ -60,5 +60,13 @@ describe('isNativeFunctionCallingSupported', () => {
});
expect(isNativeFunctionCallingSupported(connector)).toBe(false);
});
it('returns true if the config is not exposed', () => {
const connector = createConnector({
type: InferenceConnectorType.OpenAI,
config: {},
});
expect(isNativeFunctionCallingSupported(connector)).toBe(true);
});
});
});

View file

@ -11,9 +11,9 @@ import { OpenAiProviderType } from '../adapters/openai/types';
export const isNativeFunctionCallingSupported = (connector: InferenceConnector): boolean => {
switch (connector.type) {
case InferenceConnectorType.OpenAI:
const apiProvider =
(connector.config.apiProvider as OpenAiProviderType) ?? OpenAiProviderType.Other;
return apiProvider !== OpenAiProviderType.Other;
const apiProvider = (connector.config.apiProvider as OpenAiProviderType) ?? undefined;
// defaulting to `true` when the config is not accessible
return apiProvider ? apiProvider !== OpenAiProviderType.Other : true;
case InferenceConnectorType.Inference:
// note: later we might need to check the provider type, for now let's assume support
// will be handled by ES and that all providers will support native FC.