From dfa56861bd1d75d380055a97197ab077f526b0fa Mon Sep 17 00:00:00 2001 From: Stanislas Polu Date: Fri, 15 Nov 2024 15:27:10 +0100 Subject: [PATCH] Pack together all actions related types/events in the same files (#8681) * Move events next to types part I * move actions * fix imports * more fixes * fix * fix rebase --- types/src/front/assistant/actions/browse.ts | 34 ++++- .../actions/conversation/list_files.ts | 2 +- .../front/assistant/actions/dust_app_run.ts | 42 ++++- types/src/front/assistant/actions/guards.ts | 16 +- .../{lib/api => }/assistant/actions/index.ts | 7 +- types/src/front/assistant/actions/process.ts | 35 ++++- .../src/front/assistant/actions/retrieval.ts | 39 ++++- .../front/assistant/actions/tables_query.ts | 41 ++++- .../src/front/assistant/actions/websearch.ts | 34 ++++- types/src/front/assistant/agent.ts | 144 +++++++++++++++++- types/src/front/assistant/conversation.ts | 38 +++++ .../{lib/api => }/assistant/generation.ts | 0 types/src/front/assistant/pubsub.ts | 3 + .../front/lib/api/assistant/actions/browse.ts | 29 ---- .../lib/api/assistant/actions/dust_app_run.ts | 41 ----- .../lib/api/assistant/actions/process.ts | 35 ----- .../lib/api/assistant/actions/retrieval.ts | 33 ---- .../lib/api/assistant/actions/tables_query.ts | 36 ----- .../lib/api/assistant/actions/websearch.ts | 33 ---- types/src/front/lib/api/assistant/agent.ts | 127 --------------- .../front/lib/api/assistant/conversation.ts | 38 ----- types/src/front/lib/api/assistant/pubsub.ts | 3 - types/src/front/lib/assistant.ts | 4 +- types/src/front/lib/core_api.ts | 4 +- types/src/index.ts | 14 +- 25 files changed, 419 insertions(+), 413 deletions(-) rename types/src/front/{lib/api => }/assistant/actions/index.ts (77%) rename types/src/front/{lib/api => }/assistant/generation.ts (100%) create mode 100644 types/src/front/assistant/pubsub.ts delete mode 100644 types/src/front/lib/api/assistant/actions/browse.ts delete mode 100644 types/src/front/lib/api/assistant/actions/dust_app_run.ts delete mode 100644 types/src/front/lib/api/assistant/actions/process.ts delete mode 100644 types/src/front/lib/api/assistant/actions/retrieval.ts delete mode 100644 types/src/front/lib/api/assistant/actions/tables_query.ts delete mode 100644 types/src/front/lib/api/assistant/actions/websearch.ts delete mode 100644 types/src/front/lib/api/assistant/agent.ts delete mode 100644 types/src/front/lib/api/assistant/conversation.ts delete mode 100644 types/src/front/lib/api/assistant/pubsub.ts diff --git a/types/src/front/assistant/actions/browse.ts b/types/src/front/assistant/actions/browse.ts index 2a0d13e603f7..df42245d9567 100644 --- a/types/src/front/assistant/actions/browse.ts +++ b/types/src/front/assistant/actions/browse.ts @@ -1,7 +1,7 @@ import * as t from "io-ts"; +import { BaseAction } from "../../../front/assistant/actions"; import { ModelId } from "../../../shared/model_id"; -import { BaseAction } from "../../lib/api/assistant/actions"; export type BrowseConfigurationType = { id: ModelId; @@ -38,3 +38,35 @@ export interface BrowseActionType extends BaseAction { step: number; type: "browse_action"; } + +/** + * Browse Action Events + */ + +// Event sent before the execution with the finalized params to be used. +export type BrowseParamsEvent = { + type: "browse_params"; + created: number; + configurationId: string; + messageId: string; + action: BrowseActionType; +}; + +export type BrowseErrorEvent = { + type: "browse_error"; + created: number; + configurationId: string; + messageId: string; + error: { + code: string; + message: string; + }; +}; + +export type BrowseSuccessEvent = { + type: "browse_success"; + created: number; + configurationId: string; + messageId: string; + action: BrowseActionType; +}; diff --git a/types/src/front/assistant/actions/conversation/list_files.ts b/types/src/front/assistant/actions/conversation/list_files.ts index 3d098c87ee2a..bb4ae232f707 100644 --- a/types/src/front/assistant/actions/conversation/list_files.ts +++ b/types/src/front/assistant/actions/conversation/list_files.ts @@ -1,4 +1,4 @@ -import { BaseAction } from "../../../../front/lib/api/assistant/actions/index"; +import { BaseAction } from "../../../../front/assistant/actions/index"; import { ModelId } from "../../../../shared/model_id"; export type ConversationFileType = { diff --git a/types/src/front/assistant/actions/dust_app_run.ts b/types/src/front/assistant/actions/dust_app_run.ts index 0a3f060b0bfa..edd6e12560e7 100644 --- a/types/src/front/assistant/actions/dust_app_run.ts +++ b/types/src/front/assistant/actions/dust_app_run.ts @@ -1,4 +1,4 @@ -import { BaseAction } from "../../../front/lib/api/assistant/actions/index"; +import { BaseAction } from "../../../front/assistant/actions/index"; import { ModelId } from "../../../shared/model_id"; export type DustAppRunConfigurationType = { @@ -35,3 +35,43 @@ export interface DustAppRunActionType extends BaseAction { step: number; type: "dust_app_run_action"; } + +/** + * DustAppRun Action Events + */ + +// Event sent before the execution of a dust app run with the finalized params to be used. +export type DustAppRunParamsEvent = { + type: "dust_app_run_params"; + created: number; + configurationId: string; + messageId: string; + action: DustAppRunActionType; +}; + +export type DustAppRunErrorEvent = { + type: "dust_app_run_error"; + created: number; + configurationId: string; + messageId: string; + error: { + code: string; + message: string; + }; +}; + +export type DustAppRunBlockEvent = { + type: "dust_app_run_block"; + created: number; + configurationId: string; + messageId: string; + action: DustAppRunActionType; +}; + +export type DustAppRunSuccessEvent = { + type: "dust_app_run_success"; + created: number; + configurationId: string; + messageId: string; + action: DustAppRunActionType; +}; diff --git a/types/src/front/assistant/actions/guards.ts b/types/src/front/assistant/actions/guards.ts index fa52b0e1cc25..3d02905cbc19 100644 --- a/types/src/front/assistant/actions/guards.ts +++ b/types/src/front/assistant/actions/guards.ts @@ -1,7 +1,12 @@ +import { + BrowseActionType, + BrowseConfigurationType, +} from "../../../front/assistant/actions/browse"; import { DustAppRunActionType, DustAppRunConfigurationType, } from "../../../front/assistant/actions/dust_app_run"; +import { BaseAction } from "../../../front/assistant/actions/index"; import { ProcessActionType, ProcessConfigurationType, @@ -14,14 +19,15 @@ import { TablesQueryActionType, TablesQueryConfigurationType, } from "../../../front/assistant/actions/tables_query"; -import { AgentActionType } from "../../../front/assistant/conversation"; -import { BaseAction } from "../../../front/lib/api/assistant/actions/index"; +import { + WebsearchActionType, + WebsearchConfigurationType, +} from "../../../front/assistant/actions/websearch"; import { AgentConfigurationType, TemplateAgentConfigurationType, -} from "../agent"; -import { BrowseActionType, BrowseConfigurationType } from "./browse"; -import { WebsearchActionType, WebsearchConfigurationType } from "./websearch"; +} from "../../../front/assistant/agent"; +import { AgentActionType } from "../../../front/assistant/conversation"; export function isTablesQueryConfiguration( arg: unknown diff --git a/types/src/front/lib/api/assistant/actions/index.ts b/types/src/front/assistant/actions/index.ts similarity index 77% rename from types/src/front/lib/api/assistant/actions/index.ts rename to types/src/front/assistant/actions/index.ts index ceaf4c7c0bbe..902af1b70168 100644 --- a/types/src/front/lib/api/assistant/actions/index.ts +++ b/types/src/front/assistant/actions/index.ts @@ -1,5 +1,8 @@ -import { ModelId } from "../../../../../shared/model_id"; -import { FunctionCallType, FunctionMessageTypeModel } from "../generation"; +import { + FunctionCallType, + FunctionMessageTypeModel, +} from "../../../front/assistant/generation"; +import { ModelId } from "../../../shared/model_id"; type BaseActionType = | "dust_app_run_action" diff --git a/types/src/front/assistant/actions/process.ts b/types/src/front/assistant/actions/process.ts index 9392f2588c75..79aaf4e151ea 100644 --- a/types/src/front/assistant/actions/process.ts +++ b/types/src/front/assistant/actions/process.ts @@ -1,9 +1,9 @@ +import { BaseAction } from "../../../front/assistant/actions/index"; import { DataSourceConfiguration, RetrievalTimeframe, TimeFrame, } from "../../../front/assistant/actions/retrieval"; -import { BaseAction } from "../../../front/lib/api/assistant/actions/index"; import { ModelId } from "../../../shared/model_id"; export const PROCESS_SCHEMA_ALLOWED_TYPES = [ @@ -91,3 +91,36 @@ export interface ProcessActionType extends BaseAction { step: number; type: "process_action"; } + +/** + * Process Action Events + */ + +// Event sent before the execution with the finalized params to be used. +export type ProcessParamsEvent = { + type: "process_params"; + created: number; + configurationId: string; + messageId: string; + dataSources: DataSourceConfiguration[]; + action: ProcessActionType; +}; + +export type ProcessErrorEvent = { + type: "process_error"; + created: number; + configurationId: string; + messageId: string; + error: { + code: string; + message: string; + }; +}; + +export type ProcessSuccessEvent = { + type: "process_success"; + created: number; + configurationId: string; + messageId: string; + action: ProcessActionType; +}; diff --git a/types/src/front/assistant/actions/retrieval.ts b/types/src/front/assistant/actions/retrieval.ts index 44ceb6d78467..efa8e5dd6edf 100644 --- a/types/src/front/assistant/actions/retrieval.ts +++ b/types/src/front/assistant/actions/retrieval.ts @@ -2,11 +2,11 @@ * Data Source configuration */ -import { BaseAction } from "../../../front/lib/api/assistant/actions/index"; +import { BaseAction } from "../../../front/assistant/actions/index"; +import { ConnectorProvider } from "../../../front/data_source"; +import { DataSourceViewType } from "../../../front/data_source_view"; import { ModelId } from "../../../shared/model_id"; import { ioTsEnum } from "../../../shared/utils/iots_utils"; -import { ConnectorProvider } from "../../data_source"; -import { DataSourceViewType } from "../../data_source_view"; export const TIME_FRAME_UNITS = [ "hour", @@ -143,3 +143,36 @@ export interface RetrievalActionType extends BaseAction { step: number; type: "retrieval_action"; } + +/** + * Retrieval Action Events + */ + +// Event sent during retrieval with the finalized query used to retrieve documents. +export type RetrievalParamsEvent = { + type: "retrieval_params"; + created: number; + configurationId: string; + messageId: string; + dataSources: DataSourceConfiguration[]; + action: RetrievalActionType; +}; + +export type RetrievalErrorEvent = { + type: "retrieval_error"; + created: number; + configurationId: string; + messageId: string; + error: { + code: string; + message: string; + }; +}; + +export type RetrievalSuccessEvent = { + type: "retrieval_success"; + created: number; + configurationId: string; + messageId: string; + action: RetrievalActionType; +}; diff --git a/types/src/front/assistant/actions/tables_query.ts b/types/src/front/assistant/actions/tables_query.ts index 8265795eeb58..46842202295f 100644 --- a/types/src/front/assistant/actions/tables_query.ts +++ b/types/src/front/assistant/actions/tables_query.ts @@ -1,5 +1,5 @@ import { DustAppParameters } from "../../../front/assistant/actions/dust_app_run"; -import { BaseAction } from "../../../front/lib/api/assistant/actions/index"; +import { BaseAction } from "../../../front/assistant/actions/index"; import { ModelId } from "../../../shared/model_id"; export type TablesQueryConfigurationType = { @@ -67,3 +67,42 @@ export function getTablesQueryResultsFileAttachment({ return `${attachment}>\n${resultsFileSnippet}\n`; } + +/** + * TablesQuey Events + */ + +export type TablesQueryErrorEvent = { + type: "tables_query_error"; + created: number; + configurationId: string; + messageId: string; + error: { + code: "tables_query_error" | "too_many_result_rows"; + message: string; + }; +}; + +export type TablesQueryStartedEvent = { + type: "tables_query_started"; + created: number; + configurationId: string; + messageId: string; + action: TablesQueryActionType; +}; + +export type TablesQueryModelOutputEvent = { + type: "tables_query_model_output"; + created: number; + configurationId: string; + messageId: string; + action: TablesQueryActionType; +}; + +export type TablesQueryOutputEvent = { + type: "tables_query_output"; + created: number; + configurationId: string; + messageId: string; + action: TablesQueryActionType; +}; diff --git a/types/src/front/assistant/actions/websearch.ts b/types/src/front/assistant/actions/websearch.ts index 4dc22a5954ab..93903ba15768 100644 --- a/types/src/front/assistant/actions/websearch.ts +++ b/types/src/front/assistant/actions/websearch.ts @@ -1,7 +1,7 @@ import * as t from "io-ts"; +import { BaseAction } from "../../../front/assistant/actions"; import { ModelId } from "../../../shared/model_id"; -import { BaseAction } from "../../lib/api/assistant/actions"; export type WebsearchConfigurationType = { id: ModelId; @@ -60,3 +60,35 @@ export interface WebsearchActionType extends BaseAction { step: number; type: "websearch_action"; } + +/** + * WebSearch Action Events + */ + +// Event sent before the execution with the finalized params to be used. +export type WebsearchParamsEvent = { + type: "websearch_params"; + created: number; + configurationId: string; + messageId: string; + action: WebsearchActionType; +}; + +export type WebsearchErrorEvent = { + type: "websearch_error"; + created: number; + configurationId: string; + messageId: string; + error: { + code: string; + message: string; + }; +}; + +export type WebsearchSuccessEvent = { + type: "websearch_success"; + created: number; + configurationId: string; + messageId: string; + action: WebsearchActionType; +}; diff --git a/types/src/front/assistant/agent.ts b/types/src/front/assistant/agent.ts index c6c13ffc3128..a612e0394fc9 100644 --- a/types/src/front/assistant/agent.ts +++ b/types/src/front/assistant/agent.ts @@ -1,12 +1,36 @@ -import { DustAppRunConfigurationType } from "../../front/assistant/actions/dust_app_run"; -import { ProcessConfigurationType } from "../../front/assistant/actions/process"; -import { RetrievalConfigurationType } from "../../front/assistant/actions/retrieval"; -import { TablesQueryConfigurationType } from "../../front/assistant/actions/tables_query"; +import { + BrowseConfigurationType, + BrowseParamsEvent, +} from "../../front/assistant/actions/browse"; +import { + DustAppRunBlockEvent, + DustAppRunConfigurationType, + DustAppRunParamsEvent, +} from "../../front/assistant/actions/dust_app_run"; +import { + ProcessConfigurationType, + ProcessParamsEvent, +} from "../../front/assistant/actions/process"; +import { + RetrievalConfigurationType, + RetrievalParamsEvent, +} from "../../front/assistant/actions/retrieval"; +import { + TablesQueryConfigurationType, + TablesQueryModelOutputEvent, + TablesQueryOutputEvent, + TablesQueryStartedEvent, +} from "../../front/assistant/actions/tables_query"; +import { + WebsearchConfigurationType, + WebsearchParamsEvent, +} from "../../front/assistant/actions/websearch"; +import { + AgentActionType, + AgentMessageType, +} from "../../front/assistant/conversation"; import { ModelIdType, ModelProviderIdType } from "../../front/lib/assistant"; import { ModelId } from "../../shared/model_id"; -import { BrowseConfigurationType } from "./actions/browse"; -import { WebsearchConfigurationType } from "./actions/websearch"; - /** * Agent Action configuration */ @@ -215,3 +239,109 @@ export interface TemplateAgentConfigurationType { } export const MAX_STEPS_USE_PER_RUN_LIMIT = 8; + +/** + * Agent events + */ + +// Event sent when an agent error occured before we have a agent message in the database. +export type AgentMessageErrorEvent = { + type: "agent_message_error"; + created: number; + configurationId: string; + error: { + code: string; + message: string; + }; +}; + +// Generic event sent when an error occured (whether it's during the action or the message generation). +export type AgentErrorEvent = { + type: "agent_error"; + created: number; + configurationId: string; + messageId: string; + error: { + code: string; + message: string; + }; +}; + +export type AgentDisabledErrorEvent = { + type: "agent_disabled_error"; + created: number; + configurationId: string; + error: { + code: string; + message: string; + }; +}; + +// Event sent during the execution of an action. These are action specific. +export type AgentActionSpecificEvent = + | RetrievalParamsEvent + | DustAppRunParamsEvent + | DustAppRunBlockEvent + | TablesQueryStartedEvent + | TablesQueryModelOutputEvent + | TablesQueryOutputEvent + | ProcessParamsEvent + | WebsearchParamsEvent + | BrowseParamsEvent; + +// Event sent once the action is completed, we're moving to generating a message if applicable. +export type AgentActionSuccessEvent = { + type: "agent_action_success"; + created: number; + configurationId: string; + messageId: string; + action: AgentActionType; +}; + +// Event sent to stop the generation. +export type AgentGenerationCancelledEvent = { + type: "agent_generation_cancelled"; + created: number; + configurationId: string; + messageId: string; +}; + +// Event sent once the message is completed and successful. +export type AgentMessageSuccessEvent = { + type: "agent_message_success"; + created: number; + configurationId: string; + messageId: string; + message: AgentMessageType; + runIds: string[]; +}; + +export type AgentActionsEvent = { + type: "agent_actions"; + created: number; + runId: string; + actions: Array<{ + action: AgentActionConfigurationType; + inputs: Record; + specification: AgentActionSpecification | null; + functionCallId: string | null; + }>; +}; + +export type AgentChainOfThoughtEvent = { + type: "agent_chain_of_thought"; + created: number; + configurationId: string; + messageId: string; + message: AgentMessageType; + chainOfThought: string; +}; + +export type AgentContentEvent = { + type: "agent_message_content"; + created: number; + configurationId: string; + messageId: string; + content: string; + processedContent: string; +}; diff --git a/types/src/front/assistant/conversation.ts b/types/src/front/assistant/conversation.ts index 1bf83a1f18ae..45ee2b0734cf 100644 --- a/types/src/front/assistant/conversation.ts +++ b/types/src/front/assistant/conversation.ts @@ -272,3 +272,41 @@ export interface FetchConversationMessagesResponse { lastValue: number | null; messages: MessageWithRankType[]; } + +/** + * Conversation events. + */ + +// Event sent when the user message is created. +export type UserMessageNewEvent = { + type: "user_message_new"; + created: number; + messageId: string; + message: UserMessageWithRankType; +}; + +// Event sent when the user message is created. +export type UserMessageErrorEvent = { + type: "user_message_error"; + created: number; + error: { + code: string; + message: string; + }; +}; + +// Event sent when a new message is created (empty) and the agent is about to be executed. +export type AgentMessageNewEvent = { + type: "agent_message_new"; + created: number; + configurationId: string; + messageId: string; + message: AgentMessageWithRankType; +}; + +// Event sent when the conversation title is updated. +export type ConversationTitleEvent = { + type: "conversation_title"; + created: number; + title: string; +}; diff --git a/types/src/front/lib/api/assistant/generation.ts b/types/src/front/assistant/generation.ts similarity index 100% rename from types/src/front/lib/api/assistant/generation.ts rename to types/src/front/assistant/generation.ts diff --git a/types/src/front/assistant/pubsub.ts b/types/src/front/assistant/pubsub.ts new file mode 100644 index 000000000000..b4edcb383a8f --- /dev/null +++ b/types/src/front/assistant/pubsub.ts @@ -0,0 +1,3 @@ +import { APIErrorWithStatusCode } from "../../front/lib/error"; + +export type PubSubError = APIErrorWithStatusCode; diff --git a/types/src/front/lib/api/assistant/actions/browse.ts b/types/src/front/lib/api/assistant/actions/browse.ts deleted file mode 100644 index 7ebc94b1b5f0..000000000000 --- a/types/src/front/lib/api/assistant/actions/browse.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { BrowseActionType } from "../../../../assistant/actions/browse"; - -// Event sent before the execution with the finalized params to be used. -export type BrowseParamsEvent = { - type: "browse_params"; - created: number; - configurationId: string; - messageId: string; - action: BrowseActionType; -}; - -export type BrowseErrorEvent = { - type: "browse_error"; - created: number; - configurationId: string; - messageId: string; - error: { - code: string; - message: string; - }; -}; - -export type BrowseSuccessEvent = { - type: "browse_success"; - created: number; - configurationId: string; - messageId: string; - action: BrowseActionType; -}; diff --git a/types/src/front/lib/api/assistant/actions/dust_app_run.ts b/types/src/front/lib/api/assistant/actions/dust_app_run.ts deleted file mode 100644 index aece0cabdb5a..000000000000 --- a/types/src/front/lib/api/assistant/actions/dust_app_run.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Action execution. - */ - -import { DustAppRunActionType } from "../../../../../front/assistant/actions/dust_app_run"; - -// Event sent before the execution of a dust app run with the finalized params to be used. -export type DustAppRunParamsEvent = { - type: "dust_app_run_params"; - created: number; - configurationId: string; - messageId: string; - action: DustAppRunActionType; -}; - -export type DustAppRunErrorEvent = { - type: "dust_app_run_error"; - created: number; - configurationId: string; - messageId: string; - error: { - code: string; - message: string; - }; -}; - -export type DustAppRunBlockEvent = { - type: "dust_app_run_block"; - created: number; - configurationId: string; - messageId: string; - action: DustAppRunActionType; -}; - -export type DustAppRunSuccessEvent = { - type: "dust_app_run_success"; - created: number; - configurationId: string; - messageId: string; - action: DustAppRunActionType; -}; diff --git a/types/src/front/lib/api/assistant/actions/process.ts b/types/src/front/lib/api/assistant/actions/process.ts deleted file mode 100644 index 3a384845bee1..000000000000 --- a/types/src/front/lib/api/assistant/actions/process.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Action execution. - */ - -import { ProcessActionType } from "../../../../../front/assistant/actions/process"; -import { DataSourceConfiguration } from "../../../../../front/assistant/actions/retrieval"; - -// Event sent before the execution with the finalized params to be used. -export type ProcessParamsEvent = { - type: "process_params"; - created: number; - configurationId: string; - messageId: string; - dataSources: DataSourceConfiguration[]; - action: ProcessActionType; -}; - -export type ProcessErrorEvent = { - type: "process_error"; - created: number; - configurationId: string; - messageId: string; - error: { - code: string; - message: string; - }; -}; - -export type ProcessSuccessEvent = { - type: "process_success"; - created: number; - configurationId: string; - messageId: string; - action: ProcessActionType; -}; diff --git a/types/src/front/lib/api/assistant/actions/retrieval.ts b/types/src/front/lib/api/assistant/actions/retrieval.ts deleted file mode 100644 index 5435b05c1a1e..000000000000 --- a/types/src/front/lib/api/assistant/actions/retrieval.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { - DataSourceConfiguration, - RetrievalActionType, -} from "../../../../../front/assistant/actions/retrieval"; - -// Event sent during retrieval with the finalized query used to retrieve documents. -export type RetrievalParamsEvent = { - type: "retrieval_params"; - created: number; - configurationId: string; - messageId: string; - dataSources: DataSourceConfiguration[]; - action: RetrievalActionType; -}; - -export type RetrievalErrorEvent = { - type: "retrieval_error"; - created: number; - configurationId: string; - messageId: string; - error: { - code: string; - message: string; - }; -}; - -export type RetrievalSuccessEvent = { - type: "retrieval_success"; - created: number; - configurationId: string; - messageId: string; - action: RetrievalActionType; -}; diff --git a/types/src/front/lib/api/assistant/actions/tables_query.ts b/types/src/front/lib/api/assistant/actions/tables_query.ts deleted file mode 100644 index 941507ed054a..000000000000 --- a/types/src/front/lib/api/assistant/actions/tables_query.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { TablesQueryActionType } from "../../../../../front/assistant/actions/tables_query"; - -export type TablesQueryErrorEvent = { - type: "tables_query_error"; - created: number; - configurationId: string; - messageId: string; - error: { - code: "tables_query_error" | "too_many_result_rows"; - message: string; - }; -}; - -export type TablesQueryStartedEvent = { - type: "tables_query_started"; - created: number; - configurationId: string; - messageId: string; - action: TablesQueryActionType; -}; - -export type TablesQueryModelOutputEvent = { - type: "tables_query_model_output"; - created: number; - configurationId: string; - messageId: string; - action: TablesQueryActionType; -}; - -export type TablesQueryOutputEvent = { - type: "tables_query_output"; - created: number; - configurationId: string; - messageId: string; - action: TablesQueryActionType; -}; diff --git a/types/src/front/lib/api/assistant/actions/websearch.ts b/types/src/front/lib/api/assistant/actions/websearch.ts deleted file mode 100644 index 648ca7099dbd..000000000000 --- a/types/src/front/lib/api/assistant/actions/websearch.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Action execution. - */ - -import { WebsearchActionType } from "../../../../assistant/actions/websearch"; - -// Event sent before the execution with the finalized params to be used. -export type WebsearchParamsEvent = { - type: "websearch_params"; - created: number; - configurationId: string; - messageId: string; - action: WebsearchActionType; -}; - -export type WebsearchErrorEvent = { - type: "websearch_error"; - created: number; - configurationId: string; - messageId: string; - error: { - code: string; - message: string; - }; -}; - -export type WebsearchSuccessEvent = { - type: "websearch_success"; - created: number; - configurationId: string; - messageId: string; - action: WebsearchActionType; -}; diff --git a/types/src/front/lib/api/assistant/agent.ts b/types/src/front/lib/api/assistant/agent.ts deleted file mode 100644 index 77db9eec8ff9..000000000000 --- a/types/src/front/lib/api/assistant/agent.ts +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Agent execution. - */ - -import { - AgentActionType, - AgentMessageType, -} from "../../../../front/assistant/conversation"; -import { - DustAppRunBlockEvent, - DustAppRunParamsEvent, -} from "../../../../front/lib/api/assistant/actions/dust_app_run"; -import { RetrievalParamsEvent } from "../../../../front/lib/api/assistant/actions/retrieval"; -import { - TablesQueryModelOutputEvent, - TablesQueryOutputEvent, - TablesQueryStartedEvent, -} from "../../../../front/lib/api/assistant/actions/tables_query"; -import { - AgentActionConfigurationType, - AgentActionSpecification, -} from "../../../assistant/agent"; -import { BrowseParamsEvent } from "./actions/browse"; -import { ProcessParamsEvent } from "./actions/process"; -import { WebsearchParamsEvent } from "./actions/websearch"; - -// Event sent when an agent error occured before we have a agent message in the database. -export type AgentMessageErrorEvent = { - type: "agent_message_error"; - created: number; - configurationId: string; - error: { - code: string; - message: string; - }; -}; - -// Generic event sent when an error occured (whether it's during the action or the message generation). -export type AgentErrorEvent = { - type: "agent_error"; - created: number; - configurationId: string; - messageId: string; - error: { - code: string; - message: string; - }; -}; - -export type AgentDisabledErrorEvent = { - type: "agent_disabled_error"; - created: number; - configurationId: string; - error: { - code: string; - message: string; - }; -}; - -// Event sent during the execution of an action. These are action specific. -export type AgentActionSpecificEvent = - | RetrievalParamsEvent - | DustAppRunParamsEvent - | DustAppRunBlockEvent - | TablesQueryStartedEvent - | TablesQueryModelOutputEvent - | TablesQueryOutputEvent - | ProcessParamsEvent - | WebsearchParamsEvent - | BrowseParamsEvent; - -// Event sent once the action is completed, we're moving to generating a message if applicable. -export type AgentActionSuccessEvent = { - type: "agent_action_success"; - created: number; - configurationId: string; - messageId: string; - action: AgentActionType; -}; - -// Event sent to stop the generation. -export type AgentGenerationCancelledEvent = { - type: "agent_generation_cancelled"; - created: number; - configurationId: string; - messageId: string; -}; - -// Event sent once the message is completed and successful. -export type AgentMessageSuccessEvent = { - type: "agent_message_success"; - created: number; - configurationId: string; - messageId: string; - message: AgentMessageType; - runIds: string[]; -}; - -export type AgentActionsEvent = { - type: "agent_actions"; - created: number; - runId: string; - actions: Array<{ - action: AgentActionConfigurationType; - inputs: Record; - specification: AgentActionSpecification | null; - functionCallId: string | null; - }>; -}; - -export type AgentChainOfThoughtEvent = { - type: "agent_chain_of_thought"; - created: number; - configurationId: string; - messageId: string; - message: AgentMessageType; - chainOfThought: string; -}; - -export type AgentContentEvent = { - type: "agent_message_content"; - created: number; - configurationId: string; - messageId: string; - content: string; - processedContent: string; -}; diff --git a/types/src/front/lib/api/assistant/conversation.ts b/types/src/front/lib/api/assistant/conversation.ts deleted file mode 100644 index 88d3e6bd98ef..000000000000 --- a/types/src/front/lib/api/assistant/conversation.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { - AgentMessageWithRankType, - UserMessageWithRankType, -} from "../../../../front/assistant/conversation"; - -// Event sent when the user message is created. -export type UserMessageNewEvent = { - type: "user_message_new"; - created: number; - messageId: string; - message: UserMessageWithRankType; -}; - -// Event sent when the user message is created. -export type UserMessageErrorEvent = { - type: "user_message_error"; - created: number; - error: { - code: string; - message: string; - }; -}; - -// Event sent when a new message is created (empty) and the agent is about to be executed. -export type AgentMessageNewEvent = { - type: "agent_message_new"; - created: number; - configurationId: string; - messageId: string; - message: AgentMessageWithRankType; -}; - -// Event sent when the conversation title is updated. -export type ConversationTitleEvent = { - type: "conversation_title"; - created: number; - title: string; -}; diff --git a/types/src/front/lib/api/assistant/pubsub.ts b/types/src/front/lib/api/assistant/pubsub.ts deleted file mode 100644 index 5c4740e9d099..000000000000 --- a/types/src/front/lib/api/assistant/pubsub.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { APIErrorWithStatusCode } from "../../../../front/lib/error"; - -export type PubSubError = APIErrorWithStatusCode; diff --git a/types/src/front/lib/assistant.ts b/types/src/front/lib/assistant.ts index 73844a35669f..c037efaeba7d 100644 --- a/types/src/front/lib/assistant.ts +++ b/types/src/front/lib/assistant.ts @@ -1,8 +1,8 @@ +import { LightAgentConfigurationType } from "../../front/assistant/agent"; +import { GenerationTokensEvent } from "../../front/assistant/generation"; import { WorkspaceType } from "../../front/user"; import { ExtractSpecificKeys } from "../../shared/typescipt_utils"; import { ioTsEnum } from "../../shared/utils/iots_utils"; -import { LightAgentConfigurationType } from "../assistant/agent"; -import { GenerationTokensEvent } from "./api/assistant/generation"; /** * PROVIDER IDS diff --git a/types/src/front/lib/core_api.ts b/types/src/front/lib/core_api.ts index 956494e8a9a1..342afc512c52 100644 --- a/types/src/front/lib/core_api.ts +++ b/types/src/front/lib/core_api.ts @@ -10,6 +10,7 @@ import { EmbedderType, } from "../../core/data_source"; import { DustAppSecretType } from "../../front/dust_app_secret"; +import { GroupType } from "../../front/groups"; import { dustManagedCredentials } from "../../front/lib/api/credentials"; import { EmbeddingProviderIdType } from "../../front/lib/assistant"; import { Project } from "../../front/project"; @@ -21,10 +22,9 @@ import { RunStatus, TraceType, } from "../../front/run"; +import { LightWorkspaceType } from "../../front/user"; import { LoggerInterface } from "../../shared/logger"; import { Err, Ok, Result } from "../../shared/result"; -import { GroupType } from "../groups"; -import { LightWorkspaceType } from "../user"; export const MAX_CHUNK_SIZE = 512; diff --git a/types/src/index.ts b/types/src/index.ts index 57c97ba80867..d8523baf9991 100644 --- a/types/src/index.ts +++ b/types/src/index.ts @@ -24,6 +24,7 @@ export * from "./front/assistant/actions/browse"; export * from "./front/assistant/actions/conversation/list_files"; export * from "./front/assistant/actions/dust_app_run"; export * from "./front/assistant/actions/guards"; +export * from "./front/assistant/actions/index"; export * from "./front/assistant/actions/process"; export * from "./front/assistant/actions/retrieval"; export * from "./front/assistant/actions/tables_query"; @@ -32,6 +33,8 @@ export * from "./front/assistant/agent"; export * from "./front/assistant/avatar"; export * from "./front/assistant/builder"; export * from "./front/assistant/conversation"; +export * from "./front/assistant/generation"; +export * from "./front/assistant/pubsub"; export * from "./front/assistant/templates"; export * from "./front/assistant/visualization"; export * from "./front/content_fragment"; @@ -44,17 +47,6 @@ export * from "./front/files"; export * from "./front/groups"; export * from "./front/key"; export * from "./front/lib/actions/types"; -export * from "./front/lib/api/assistant/actions/browse"; -export * from "./front/lib/api/assistant/actions/dust_app_run"; -export * from "./front/lib/api/assistant/actions/index"; -export * from "./front/lib/api/assistant/actions/process"; -export * from "./front/lib/api/assistant/actions/retrieval"; -export * from "./front/lib/api/assistant/actions/tables_query"; -export * from "./front/lib/api/assistant/actions/websearch"; -export * from "./front/lib/api/assistant/agent"; -export * from "./front/lib/api/assistant/conversation"; -export * from "./front/lib/api/assistant/generation"; -export * from "./front/lib/api/assistant/pubsub"; export * from "./front/lib/api/credentials"; export * from "./front/lib/assistant"; export * from "./front/lib/connectors_api";