Skip to content

Commit

Permalink
[Obs AI Assistant] Boost user prompt in recall (#184933)
Browse files Browse the repository at this point in the history
Closes: #180995

---------

Co-authored-by: Dario Gieselaar <[email protected]>
(cherry picked from commit baa22bb)
  • Loading branch information
sorenlouv committed Dec 10, 2024
1 parent 4fa7135 commit 164dc34
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
: '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
* 2.0.
*/

import {
correctCommonEsqlMistakes,
isChatCompletionChunkEvent,
isOutputEvent,
} from '@kbn/inference-plugin/common';
import { ToolDefinition, isChatCompletionChunkEvent, isOutputEvent } from '@kbn/inference-common';
import { correctCommonEsqlMistakes } from '@kbn/inference-plugin/common';
import { naturalLanguageToEsql } from '@kbn/inference-plugin/server';
import {
FunctionVisibility,
Expand Down Expand Up @@ -135,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',
});
Expand Down

0 comments on commit 164dc34

Please sign in to comment.