Skip to content

Commit

Permalink
Pack together all actions related types/events in the same files (#8681)
Browse files Browse the repository at this point in the history
* Move events next to types part I

* move actions

* fix imports

* more fixes

* fix

* fix rebase
  • Loading branch information
spolu authored Nov 15, 2024
1 parent e0a8b38 commit dfa5686
Show file tree
Hide file tree
Showing 25 changed files with 419 additions and 413 deletions.
34 changes: 33 additions & 1 deletion types/src/front/assistant/actions/browse.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
};
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
42 changes: 41 additions & 1 deletion types/src/front/assistant/actions/dust_app_run.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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;
};
16 changes: 11 additions & 5 deletions types/src/front/assistant/actions/guards.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
35 changes: 34 additions & 1 deletion types/src/front/assistant/actions/process.ts
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down Expand Up @@ -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;
};
39 changes: 36 additions & 3 deletions types/src/front/assistant/actions/retrieval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
};
41 changes: 40 additions & 1 deletion types/src/front/assistant/actions/tables_query.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -67,3 +67,42 @@ export function getTablesQueryResultsFileAttachment({

return `${attachment}>\n${resultsFileSnippet}\n</file>`;
}

/**
* 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;
};
34 changes: 33 additions & 1 deletion types/src/front/assistant/actions/websearch.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
};
Loading

0 comments on commit dfa5686

Please sign in to comment.