Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Nov 22, 2023
1 parent 48366d7 commit dae5a21
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
11 changes: 11 additions & 0 deletions common/types/chat_saved_object_attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>;
parent_interaction_id?: string;
}

export interface ISession {
title: string;
version: number;
createdTimeMs: number;
updatedTimeMs: number;
messages: IMessage[];
interactions: Interaction[];
}

export interface ISessionFindResponse {
Expand Down
6 changes: 3 additions & 3 deletions server/services/storage/agent_framework_storage_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -55,6 +54,7 @@ export class AgentFrameworkStorageService implements StorageService {
createdTimeMs: Date.now(),
updatedTimeMs: Date.now(),
messages: finalMessages,
interactions: session.body.interactions,
};
}

Expand Down
12 changes: 1 addition & 11 deletions server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,14 @@
* 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
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<string, unknown>;
parent_interaction_id: string;
}

export interface MessageParser {
/**
* The id of the parser, should be unique among the parsers.
Expand Down
4 changes: 2 additions & 2 deletions server/utils/message_parser_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) {}
Expand Down

0 comments on commit dae5a21

Please sign in to comment.