From 4b0e5cd7c7737f1c8b1894f2679f54573260254f Mon Sep 17 00:00:00 2001 From: PopDaph Date: Fri, 8 Sep 2023 15:45:08 +0200 Subject: [PATCH] Move types --- front/lib/api/assistant/actions/retrieval.ts | 6 +-- front/lib/api/assistant/configuration.ts | 2 +- front/types/assistant/actions/retrieval.ts | 32 +++++++++++- front/types/assistant/agent.ts | 21 -------- front/types/assistant/configuration.ts | 51 ++++++++------------ 5 files changed, 56 insertions(+), 56 deletions(-) diff --git a/front/lib/api/assistant/actions/retrieval.ts b/front/lib/api/assistant/actions/retrieval.ts index bbe5d7762cadf..0c65fa0f468ba 100644 --- a/front/lib/api/assistant/actions/retrieval.ts +++ b/front/lib/api/assistant/actions/retrieval.ts @@ -21,13 +21,13 @@ import { RetrievalDocumentType, TimeFrame, } from "@app/types/assistant/actions/retrieval"; -import { AgentActionSpecification } from "@app/types/assistant/agent"; import { - AgentConfigurationType, AgentDataSourceConfigurationType, isRetrievalConfiguration, RetrievalConfigurationType, -} from "@app/types/assistant/configuration"; +} from "@app/types/assistant/actions/retrieval"; +import { AgentActionSpecification } from "@app/types/assistant/agent"; +import { AgentConfigurationType } from "@app/types/assistant/configuration"; import { AgentMessageType, ConversationType, diff --git a/front/lib/api/assistant/configuration.ts b/front/lib/api/assistant/configuration.ts index 1550a9d34a727..5805146e381b5 100644 --- a/front/lib/api/assistant/configuration.ts +++ b/front/lib/api/assistant/configuration.ts @@ -12,6 +12,7 @@ import { } from "@app/lib/models"; import { generateModelSId } from "@app/lib/utils"; import { + AgentDataSourceConfigurationType, isTemplatedQuery, isTimeFrame, RetrievalQuery, @@ -21,7 +22,6 @@ import { AgentActionConfigurationType, AgentConfigurationStatus, AgentConfigurationType, - AgentDataSourceConfigurationType, } from "@app/types/assistant/configuration"; /** diff --git a/front/types/assistant/actions/retrieval.ts b/front/types/assistant/actions/retrieval.ts index 47a8138a6120e..42d0935d920dd 100644 --- a/front/types/assistant/actions/retrieval.ts +++ b/front/types/assistant/actions/retrieval.ts @@ -1,5 +1,5 @@ import { ModelId } from "@app/lib/databases"; -import { AgentDataSourceConfigurationType } from "@app/types/assistant/configuration"; +import { AgentActionConfigurationType } from "@app/types/assistant/configuration"; import { AgentActionType } from "@app/types/assistant/conversation"; export type TimeframeUnit = "hour" | "day" | "week" | "month" | "year"; @@ -21,6 +21,36 @@ export function isTimeFrame(arg: RetrievalTimeframe): arg is TimeFrame { ); } +/** + * Retrieval Action config + */ +export type RetrievalConfigurationType = { + id: ModelId; + + type: "retrieval_configuration"; + dataSources: AgentDataSourceConfigurationType[]; + query: RetrievalQuery; + relativeTimeFrame: RetrievalTimeframe; + topK: number; +}; +export function isRetrievalConfiguration( + arg: AgentActionConfigurationType | null +): arg is RetrievalConfigurationType { + return arg !== null && arg.type && arg.type === "retrieval_configuration"; +} + +/** + * Datasources config for Retrieval Action + */ +export type AgentDataSourceConfigurationType = { + workspaceId: string; // need sId to talk with Core (external id) + dataSourceId: string; // need Datasource.name to talk with Core (external id) + filter: { + tags: { in: string[]; not: string[] } | null; + parents: { in: string[]; not: string[] } | null; + }; +}; + // Retrieval specifies a list of data sources (with possible parent / tags filtering, possible "all" // data sources), a query ("auto" generated by the model "none", no query, `TemplatedQuery`, fixed // query), a relative time frame ("auto" generated by the model, "none" no time filtering diff --git a/front/types/assistant/agent.ts b/front/types/assistant/agent.ts index 4eb7cd6c00404..0ea0e00968217 100644 --- a/front/types/assistant/agent.ts +++ b/front/types/assistant/agent.ts @@ -2,27 +2,6 @@ * Agent Action */ -// Each AgentActionConfigurationType is capable of generating this type at runtime to specify which -// inputs should be generated by the model. As an example, to run the retrieval action for which the -// `relativeTimeFrame` has been specified in the configuration but for which the `query` is "auto", -// it would generate: -// -// ``` -// { inputs: [{ name: "query", description: "...", type: "string" }] -// ``` -// -// The params generator model for this action would be tasked to generate that query. If the -// retrieval configuration sets `relativeTimeFrame` to "auto" as well we would get: -// -// ``` -// { -// inputs: [ -// { name: "query", description: "...", type: "string" }, -// { name: "relativeTimeFrame", description: "...", type: "string" }, -// ] -// } -// ``` - export type AgentActionSpecification = { name: string; description: string; diff --git a/front/types/assistant/configuration.ts b/front/types/assistant/configuration.ts index 33c925671fc34..002bc69371cdc 100644 --- a/front/types/assistant/configuration.ts +++ b/front/types/assistant/configuration.ts @@ -1,5 +1,6 @@ import { ModelId } from "@app/lib/databases"; import { + RetrievalConfigurationType, RetrievalQuery, RetrievalTimeframe, } from "@app/types/assistant/actions/retrieval"; @@ -33,34 +34,24 @@ export type AgentGenerationConfigurationType = { /** * Action > Retrieval */ +// Each AgentActionConfigurationType is capable of generating this type at runtime to specify which +// inputs should be generated by the model. As an example, to run the retrieval action for which the +// `relativeTimeFrame` has been specified in the configuration but for which the `query` is "auto", +// it would generate: +// +// ``` +// { inputs: [{ name: "query", description: "...", type: "string" }] +// ``` +// +// The params generator model for this action would be tasked to generate that query. If the +// retrieval configuration sets `relativeTimeFrame` to "auto" as well we would get: +// +// ``` +// { +// inputs: [ +// { name: "query", description: "...", type: "string" }, +// { name: "relativeTimeFrame", description: "...", type: "string" }, +// ] +// } +// ``` export type AgentActionConfigurationType = RetrievalConfigurationType; - -/** - * Retrieval Action config - */ -export type RetrievalConfigurationType = { - id: ModelId; - - type: "retrieval_configuration"; - dataSources: AgentDataSourceConfigurationType[]; - query: RetrievalQuery; - relativeTimeFrame: RetrievalTimeframe; - topK: number; -}; -export function isRetrievalConfiguration( - arg: AgentActionConfigurationType | null -): arg is RetrievalConfigurationType { - return arg !== null && arg.type && arg.type === "retrieval_configuration"; -} - -/** - * Datasources config for Retrieval Action - */ -export type AgentDataSourceConfigurationType = { - workspaceId: string; // need sId to talk with Core (external id) - dataSourceId: string; // need Datasource.name to talk with Core (external id) - filter: { - tags: { in: string[]; not: string[] } | null; - parents: { in: string[]; not: string[] } | null; - }; -};