Skip to content

Commit

Permalink
Move types
Browse files Browse the repository at this point in the history
  • Loading branch information
PopDaph committed Sep 8, 2023
1 parent 31202d9 commit 4b0e5cd
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 56 deletions.
6 changes: 3 additions & 3 deletions front/lib/api/assistant/actions/retrieval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion front/lib/api/assistant/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "@app/lib/models";
import { generateModelSId } from "@app/lib/utils";
import {
AgentDataSourceConfigurationType,
isTemplatedQuery,
isTimeFrame,
RetrievalQuery,
Expand All @@ -21,7 +22,6 @@ import {
AgentActionConfigurationType,
AgentConfigurationStatus,
AgentConfigurationType,
AgentDataSourceConfigurationType,
} from "@app/types/assistant/configuration";

/**
Expand Down
32 changes: 31 additions & 1 deletion front/types/assistant/actions/retrieval.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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
Expand Down
21 changes: 0 additions & 21 deletions front/types/assistant/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
51 changes: 21 additions & 30 deletions front/types/assistant/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ModelId } from "@app/lib/databases";
import {
RetrievalConfigurationType,
RetrievalQuery,
RetrievalTimeframe,
} from "@app/types/assistant/actions/retrieval";
Expand Down Expand Up @@ -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;
};
};

0 comments on commit 4b0e5cd

Please sign in to comment.