mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Obs AI Assistant] Fix null pointer in function definition (#203344)
Closes #201713
This commit is contained in:
parent
cafab5eb64
commit
1d9ca1ebf6
4 changed files with 10 additions and 7 deletions
|
@ -43,7 +43,7 @@ export const useJsonEditorModel = ({
|
|||
|
||||
const initialJsonString = initialJsonValue
|
||||
? JSON.stringify(safeJsonParse(initialJsonValue), null, 4) // prettify the json
|
||||
: functionDefinition.parameters.properties
|
||||
: functionDefinition.parameters?.properties
|
||||
? JSON.stringify(createInitializedObject(functionDefinition.parameters), null, 4)
|
||||
: '';
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import type { FunctionDefinition } from '@kbn/observability-ai-assistant-plugin/common';
|
||||
|
||||
type Params = FunctionDefinition['parameters'];
|
||||
type Params = NonNullable<FunctionDefinition['parameters']>;
|
||||
|
||||
export function createInitializedObject(parameters: Params) {
|
||||
const emptyObject: Record<string, string | any> = {};
|
||||
|
|
|
@ -35,7 +35,9 @@ export type FunctionResponse =
|
|||
}
|
||||
| Observable<ChatCompletionChunkEvent | MessageAddEvent>;
|
||||
|
||||
export interface FunctionDefinition<TParameters extends CompatibleJSONSchema = any> {
|
||||
export interface FunctionDefinition<
|
||||
TParameters extends CompatibleJSONSchema = CompatibleJSONSchema
|
||||
> {
|
||||
name: string;
|
||||
description: string;
|
||||
visibility?: FunctionVisibility;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { isChatCompletionChunkEvent, isOutputEvent } from '@kbn/inference-common';
|
||||
import { ToolDefinition, isChatCompletionChunkEvent, isOutputEvent } from '@kbn/inference-common';
|
||||
import { correctCommonEsqlMistakes } from '@kbn/inference-plugin/common';
|
||||
import { naturalLanguageToEsql } from '@kbn/inference-plugin/server';
|
||||
import {
|
||||
|
@ -132,9 +132,10 @@ export function registerQueryFunction({
|
|||
),
|
||||
logger: resources.logger,
|
||||
tools: Object.fromEntries(
|
||||
actions
|
||||
.concat(esqlFunctions)
|
||||
.map((fn) => [fn.name, { description: fn.description, schema: fn.parameters }])
|
||||
[...actions, ...esqlFunctions].map((fn) => [
|
||||
fn.name,
|
||||
{ description: fn.description, schema: fn.parameters } as ToolDefinition,
|
||||
])
|
||||
),
|
||||
functionCalling: useSimulatedFunctionCalling ? 'simulated' : 'native',
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue