mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `8.16`: - [[AI Assistant] Add scopes telemetry to AI Assistant events (#197983)](https://github.com/elastic/kibana/pull/197983) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Sander Philipse","email":"94373878+sphilipse@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-10-30T14:04:23Z","message":"[AI Assistant] Add scopes telemetry to AI Assistant events (#197983)\n\n## Summary\r\n\r\nThis adds telemetry to the Observability and Search assistant to judge\r\nwhether it's search or observability.","sha":"74cf0e4e2bd386ae38a6b8c537545acbd1707022","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Search","Team:Obs AI Assistant","ci:project-deploy-observability","v8.16.0","backport:version","v8.17.0"],"title":"[AI Assistant] Add scopes telemetry to AI Assistant events","number":197983,"url":"https://github.com/elastic/kibana/pull/197983","mergeCommit":{"message":"[AI Assistant] Add scopes telemetry to AI Assistant events (#197983)\n\n## Summary\r\n\r\nThis adds telemetry to the Observability and Search assistant to judge\r\nwhether it's search or observability.","sha":"74cf0e4e2bd386ae38a6b8c537545acbd1707022"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197983","number":197983,"mergeCommit":{"message":"[AI Assistant] Add scopes telemetry to AI Assistant events (#197983)\n\n## Summary\r\n\r\nThis adds telemetry to the Observability and Search assistant to judge\r\nwhether it's search or observability.","sha":"74cf0e4e2bd386ae38a6b8c537545acbd1707022"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Sander Philipse <94373878+sphilipse@users.noreply.github.com>
This commit is contained in:
parent
80ade8b15f
commit
07ea8ebd81
3 changed files with 20 additions and 5 deletions
|
@ -18,6 +18,7 @@ import { useLastUsedPrompts } from '../hooks/use_last_used_prompts';
|
|||
import { FunctionListPopover } from '../chat/function_list_popover';
|
||||
import { PromptEditorFunction } from './prompt_editor_function';
|
||||
import { PromptEditorNaturalLanguage } from './prompt_editor_natural_language';
|
||||
import { useScopes } from '../hooks/use_scopes';
|
||||
|
||||
export interface PromptEditorProps {
|
||||
disabled: boolean;
|
||||
|
@ -42,6 +43,7 @@ export function PromptEditor({
|
|||
onSendTelemetry,
|
||||
onSubmit,
|
||||
}: PromptEditorProps) {
|
||||
const scopes = useScopes();
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const [mode, setMode] = useState<'prompt' | 'function'>(
|
||||
|
@ -121,16 +123,15 @@ export function PromptEditor({
|
|||
|
||||
setInnerMessage(undefined);
|
||||
setMode('prompt');
|
||||
|
||||
onSendTelemetry({
|
||||
type: ObservabilityAIAssistantTelemetryEventType.UserSentPromptInChat,
|
||||
payload: message,
|
||||
payload: { ...message, scopes },
|
||||
});
|
||||
} catch (_) {
|
||||
setInnerMessage(oldMessage);
|
||||
setMode(oldMessage.function_call?.name ? 'function' : 'prompt');
|
||||
}
|
||||
}, [addLastUsedPrompt, innerMessage, loading, onSendTelemetry, onSubmit]);
|
||||
}, [addLastUsedPrompt, innerMessage, loading, onSendTelemetry, onSubmit, scopes]);
|
||||
|
||||
// Submit on Enter
|
||||
useEffect(() => {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import type { AnalyticsServiceSetup, AnalyticsServiceStart } from '@kbn/core-analytics-browser';
|
||||
import { AssistantScope } from '@kbn/ai-assistant-common';
|
||||
import type { Message } from '../../common';
|
||||
import { chatFeedbackEventSchema, ChatFeedback } from './schemas/chat_feedback';
|
||||
import { insightFeedbackEventSchema, InsightFeedback } from './schemas/insight_feedback';
|
||||
|
@ -17,7 +18,10 @@ const schemas = [chatFeedbackEventSchema, insightFeedbackEventSchema, userSentPr
|
|||
export type TelemetryEventTypeWithPayload =
|
||||
| { type: ObservabilityAIAssistantTelemetryEventType.ChatFeedback; payload: ChatFeedback }
|
||||
| { type: ObservabilityAIAssistantTelemetryEventType.InsightFeedback; payload: InsightFeedback }
|
||||
| { type: ObservabilityAIAssistantTelemetryEventType.UserSentPromptInChat; payload: Message };
|
||||
| {
|
||||
type: ObservabilityAIAssistantTelemetryEventType.UserSentPromptInChat;
|
||||
payload: Message & { scopes: AssistantScope[] };
|
||||
};
|
||||
|
||||
export const registerTelemetryEventTypes = (analytics: AnalyticsServiceSetup) => {
|
||||
schemas.forEach((schema) => {
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
*/
|
||||
|
||||
import type { RootSchema } from '@kbn/core/public';
|
||||
import { AssistantScope } from '@kbn/ai-assistant-common';
|
||||
import type { Message } from '../../../common';
|
||||
|
||||
export const messageSchema: RootSchema<Message> = {
|
||||
export const messageSchema: RootSchema<Message & { scopes: AssistantScope[] }> = {
|
||||
'@timestamp': {
|
||||
type: 'text',
|
||||
_meta: {
|
||||
|
@ -74,4 +75,13 @@ export const messageSchema: RootSchema<Message> = {
|
|||
},
|
||||
},
|
||||
},
|
||||
scopes: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'text',
|
||||
_meta: {
|
||||
description: 'The scopes that were used when generating the message.',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue