-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Obs AI Assistant] Implement contextual actions #178405
Changes from all commits
ae91174
507bb36
8837408
dc4d2f8
f7665f8
e7abb08
6c00691
342a546
19bd361
605f18a
3d6c949
d05d2dd
b032a47
2198889
ff3b039
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import type { ObservabilityAIAssistantChatService } from '../public'; | ||
import type { CompatibleJSONSchema, FunctionResponse } from './functions/types'; | ||
|
||
export enum MessageRole { | ||
System = 'system', | ||
|
@@ -77,11 +79,37 @@ export interface KnowledgeBaseEntry { | |
role: KnowledgeBaseEntryRole; | ||
} | ||
|
||
export interface ObservabilityAIAssistantScreenContextRequest { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Off topic: Is it needed to prefix so many types with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. auto-imports search across all projects so in the end I think it's better to be more verbose... e.g. try to import |
||
screenDescription?: string; | ||
data?: Array<{ | ||
name: string; | ||
description: string; | ||
value: any; | ||
}>; | ||
actions?: Array<{ name: string; description: string; parameters?: CompatibleJSONSchema }>; | ||
} | ||
|
||
export type ScreenContextActionRespondFunction<TArguments extends unknown> = ({}: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Would it be wrong to just call this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's an action and then it's the respond property of the action. I do understand it's verbose and I'm not too happy with it but I think it's better than those alternatives |
||
args: TArguments; | ||
signal: AbortSignal; | ||
connectorId: string; | ||
client: Pick<ObservabilityAIAssistantChatService, 'chat' | 'complete'>; | ||
messages: Message[]; | ||
}) => Promise<FunctionResponse>; | ||
|
||
export interface ScreenContextActionDefinition<TArguments = undefined> { | ||
name: string; | ||
description: string; | ||
parameters?: CompatibleJSONSchema; | ||
respond: ScreenContextActionRespondFunction<TArguments>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Off topic: It's interesting to see how the language gets mixed between it being an "action" (function) and a "part of conversation" (respond). |
||
} | ||
|
||
export interface ObservabilityAIAssistantScreenContext { | ||
screenDescription?: string; | ||
data?: Array<{ | ||
name: string; | ||
description: string; | ||
value: any; | ||
}>; | ||
actions?: ScreenContextActionDefinition[]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { createFunctionResponseMessage } from './create_function_response_message'; | ||
|
||
export function createFunctionResponseError({ | ||
name, | ||
error, | ||
message, | ||
}: { | ||
name: string; | ||
error: Error; | ||
message?: string; | ||
}) { | ||
return createFunctionResponseMessage({ | ||
name, | ||
content: { | ||
error: { | ||
...error, | ||
name: error.name, | ||
message: error.message, | ||
cause: error.cause, | ||
stack: error.stack, | ||
}, | ||
message: message || error.message, | ||
}, | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it allowed for
common
to import frompublic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for types, yes