Skip to content

Commit

Permalink
typing work
Browse files Browse the repository at this point in the history
  • Loading branch information
spolu committed Nov 15, 2024
1 parent 3cb05ff commit cf97767
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 21 deletions.
17 changes: 11 additions & 6 deletions front/components/actions/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type { AgentActionType, LightWorkspaceType } from "@dust-tt/types";
import type {
ConfigurableAgentActionType,
LightWorkspaceType,
} from "@dust-tt/types";
import { ACTION_RUNNING_LABELS } from "@dust-tt/types";

import { BrowseActionDetails } from "@app/components/actions/browse/BrowseActionDetails";
Expand All @@ -9,22 +12,24 @@ import { TablesQueryActionDetails } from "@app/components/actions/tables_query/T
import { WebsearchActionDetails } from "@app/components/actions/websearch/WebsearchActionDetails";

export interface ActionDetailsComponentBaseProps<
T extends AgentActionType = AgentActionType,
T extends ConfigurableAgentActionType = ConfigurableAgentActionType,
> {
action: T;
owner: LightWorkspaceType;
defaultOpen: boolean;
}

interface ActionSpecification<T extends AgentActionType> {
interface ActionSpecification<T extends ConfigurableAgentActionType> {
runningLabel: string;
detailsComponent: React.ComponentType<ActionDetailsComponentBaseProps<T>>;
}

type ActionType = AgentActionType["type"];
type ActionType = ConfigurableAgentActionType["type"];

type ActionSpecifications = {
[K in ActionType]: ActionSpecification<Extract<AgentActionType, { type: K }>>;
[K in ActionType]: ActionSpecification<
Extract<ConfigurableAgentActionType, { type: K }>
>;
};

const actionsSpecification: ActionSpecifications = {
Expand Down Expand Up @@ -56,6 +61,6 @@ const actionsSpecification: ActionSpecifications = {

export function getActionSpecification<T extends ActionType>(
actionType: T
): ActionSpecification<Extract<AgentActionType, { type: T }>> {
): ActionSpecification<Extract<ConfigurableAgentActionType, { type: T }>> {
return actionsSpecification[actionType];
}
11 changes: 0 additions & 11 deletions front/lib/api/assistant/actions/jit/list_files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,3 @@ export function makeJITListFilesAction(
step: step,
});
}

/**
* Action rendering.
*/

// JITListFilesAction are never stored in DB so they are never rendered to the user.
export async function jitListFilesTypesFromAgentMessageIds(): Promise<
JITListFilesAction[]
> {
return [];
}
19 changes: 19 additions & 0 deletions sdks/js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,24 @@ const TablesQueryActionTypeSchema = BaseActionSchema.extend({
});
type TablesQueryActionPublicType = z.infer<typeof TablesQueryActionTypeSchema>;

const JITFileTypeSchema = z.object({
fileId: z.string(),
title: z.string(),
contentType: SupportedContentFragmentTypeSchema,
});

const JITListFilesActionTypeSchema = BaseActionSchema.extend({
files: z.array(JITFileTypeSchema).nullable(),
functionCallId: z.string().nullable(),
functionCallName: z.string().nullable(),
agentMessageId: ModelIdSchema,
step: z.number(),
type: z.literal("tables_query_action"),
});
type JITListFIlesActionPublicType = z.infer<
typeof JITListFilesActionTypeSchema
>;

const WhitelistableFeaturesSchema = FlexibleEnumSchema([
"usage_data_api",
"okta_enterprise_connection",
Expand Down Expand Up @@ -839,6 +857,7 @@ const AgentActionTypeSchema = z.union([
ProcessActionTypeSchema,
WebsearchActionTypeSchema,
BrowseActionTypeSchema,
JITListFilesActionTypeSchema,
]);
export type AgentActionPublicType = z.infer<typeof AgentActionTypeSchema>;

Expand Down
10 changes: 6 additions & 4 deletions types/src/front/assistant/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,17 @@ export function isUserMessageType(arg: MessageType): arg is UserMessageType {
/**
* Agent messages
*/

export type AgentActionType =
export type ConfigurableAgentActionType =
| RetrievalActionType
| DustAppRunActionType
| TablesQueryActionType
| ProcessActionType
| WebsearchActionType
| BrowseActionType
| JITListFilesActionType;
| BrowseActionType;

export type JITAgentActionType = JITListFilesActionType;

export type AgentActionType = ConfigurableAgentActionType | JITAgentActionType;

export type AgentMessageStatus =
| "created"
Expand Down

0 comments on commit cf97767

Please sign in to comment.