diff --git a/common/types/chat_saved_object_attributes.ts b/common/types/chat_saved_object_attributes.ts index fb3e0d2a..0421cd54 100644 --- a/common/types/chat_saved_object_attributes.ts +++ b/common/types/chat_saved_object_attributes.ts @@ -6,12 +6,23 @@ export const CHAT_SAVED_OBJECT = 'assistant-chat'; export const SAVED_OBJECT_VERSION = 1; +export interface Interaction { + input: string; + response: string; + conversation_id: string; + interaction_id: string; + create_time: string; + additional_info: Record; + parent_interaction_id?: string; +} + export interface ISession { title: string; version: number; createdTimeMs: number; updatedTimeMs: number; messages: IMessage[]; + interactions: Interaction[]; } export interface ISessionFindResponse { diff --git a/server/services/storage/agent_framework_storage_service.ts b/server/services/storage/agent_framework_storage_service.ts index 3448fd67..f4812d7c 100644 --- a/server/services/storage/agent_framework_storage_service.ts +++ b/server/services/storage/agent_framework_storage_service.ts @@ -6,15 +6,14 @@ import { ApiResponse } from '@opensearch-project/opensearch/.'; import { OpenSearchClient } from '../../../../../src/core/server'; import { - IInput, IMessage, - IOutput, ISession, ISessionFindResponse, + Interaction, } from '../../../common/types/chat_saved_object_attributes'; import { GetSessionsSchema } from '../../routes/chat_routes'; import { StorageService } from './storage_service'; -import { Interaction, MessageParser } from '../../types'; +import { MessageParser } from '../../types'; import { MessageParserRunner } from '../../utils/message_parser_runner'; export class AgentFrameworkStorageService implements StorageService { @@ -55,6 +54,7 @@ export class AgentFrameworkStorageService implements StorageService { createdTimeMs: Date.now(), updatedTimeMs: Date.now(), messages: finalMessages, + interactions: session.body.interactions, }; } diff --git a/server/types.ts b/server/types.ts index 9d9e7520..5b692036 100644 --- a/server/types.ts +++ b/server/types.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { IMessage } from '../common/types/chat_saved_object_attributes'; +import { IMessage, Interaction } from '../common/types/chat_saved_object_attributes'; import { ILegacyClusterClient, Logger } from '../../../src/core/server'; // eslint-disable-next-line @typescript-eslint/no-empty-interface @@ -11,16 +11,6 @@ export interface AssistantPluginSetup {} // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface AssistantPluginStart {} -export interface Interaction { - input: string; - response: string; - conversation_id: string; - interaction_id: string; - create_time: string; - additional_info: Record; - parent_interaction_id: string; -} - export interface MessageParser { /** * The id of the parser, should be unique among the parsers. diff --git a/server/utils/message_parser_runner.ts b/server/utils/message_parser_runner.ts index 2f5d7d59..60534247 100644 --- a/server/utils/message_parser_runner.ts +++ b/server/utils/message_parser_runner.ts @@ -3,8 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { IMessage } from '../../common/types/chat_saved_object_attributes'; -import { Interaction, MessageParser } from '../types'; +import { IMessage, Interaction } from '../../common/types/chat_saved_object_attributes'; +import { MessageParser } from '../types'; export class MessageParserRunner { constructor(private readonly messageParsers: MessageParser[]) {}