From 23fe34c8b419f63517749e672c9031600b3e2b37 Mon Sep 17 00:00:00 2001 From: Flavien David Date: Wed, 6 Nov 2024 11:03:46 +0100 Subject: [PATCH] Flav/fix sdks actions type (#8468) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix conversation actions type * Use public types in connectors * Use new assistant picker in the extension (#8462) * Use new assistant picker in the extension * Use nex tooltip props in button to get rid of js error * Fix * Fix unused import extension (#8463) * Editing modal styles (#8455) * [connectors] Implement upsertion for the articles (Help Center) (#8450) * turn the IDs from integers to bigints (example value: 24132475402897) * implement upsertion for articles * run a full sync on sync workflows without signals * pass the description when creating a category * correctly pass the categoryId when creating an article * add logs on empty articles * put the correct URL in the datasource * add a method getParentInternalIds to the ZendeskArticleResource * add the migration file * remove an unnecessary fetch * remove redundant mentions of the model and resource in use * fix a confusion between category.id and category.categoryId * make category content nodes expandable in read mode * implement batch content retrieval for articles and tickets * prevent articles from being upserted when already up to date * lint * add getParentInternalIds for categories and tickets * [sparkle] Supports ref in LinkWrapper and forward to (#8466) --------- Co-authored-by: Daphné Popin Co-authored-by: Edouard Wautier <4435185+Duncid@users.noreply.github.com> Co-authored-by: Aubin <60398825+aubin-tchoi@users.noreply.github.com> Co-authored-by: Thomas Draier --- connectors/src/connectors/slack/bot.ts | 8 +++++--- .../src/connectors/slack/chat/citations.ts | 4 ++-- .../slack/chat/stream_conversation_handler.ts | 16 +++++++++------- sdks/js/src/index.ts | 4 ++-- sdks/js/src/types.ts | 5 +++-- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/connectors/src/connectors/slack/bot.ts b/connectors/src/connectors/slack/bot.ts index 353b283e19be..54d0b23c3594 100644 --- a/connectors/src/connectors/slack/bot.ts +++ b/connectors/src/connectors/slack/bot.ts @@ -1,9 +1,11 @@ -import type { PublicPostContentFragmentRequestBody } from "@dust-tt/client"; +import type { + ConversationPublicType, + PublicPostContentFragmentRequestBody, +} from "@dust-tt/client"; import { DustAPI } from "@dust-tt/client"; import type { AgentMessageSuccessEvent, APIError, - ConversationType, LightAgentConfigurationType, ModelId, Result, @@ -588,7 +590,7 @@ async function answerMessage( return buildSlackMessageError(buildContentFragmentRes); } - let conversation: ConversationType | undefined = undefined; + let conversation: ConversationPublicType | undefined = undefined; let userMessage: UserMessageType | undefined = undefined; if (lastSlackChatBotMessage?.conversationId) { diff --git a/connectors/src/connectors/slack/chat/citations.ts b/connectors/src/connectors/slack/chat/citations.ts index c3de21be8ccd..fb02025a5c52 100644 --- a/connectors/src/connectors/slack/chat/citations.ts +++ b/connectors/src/connectors/slack/chat/citations.ts @@ -1,4 +1,4 @@ -import type { AgentActionType } from "@dust-tt/types"; +import type { AgentActionPublicType } from "@dust-tt/client"; import { getTitleFromRetrievedDocument, isRetrievalActionType, @@ -15,7 +15,7 @@ export type SlackMessageFootnotes = SlackMessageFootnote[]; export function annotateCitations( content: string, - actions: AgentActionType[] + actions: AgentActionPublicType[] ): { formattedContent: string; footnotes: SlackMessageFootnotes } { const references: { [key: string]: { diff --git a/connectors/src/connectors/slack/chat/stream_conversation_handler.ts b/connectors/src/connectors/slack/chat/stream_conversation_handler.ts index 62c3a2cec71f..3ef2dc8f9296 100644 --- a/connectors/src/connectors/slack/chat/stream_conversation_handler.ts +++ b/connectors/src/connectors/slack/chat/stream_conversation_handler.ts @@ -1,8 +1,10 @@ -import type { DustAPI } from "@dust-tt/client"; import type { - AgentActionType, - AgentMessageType, - ConversationType, + AgentActionPublicType, + AgentMessagePublicType, + ConversationPublicType, + DustAPI, +} from "@dust-tt/client"; +import type { LightAgentConfigurationType, Result, UserMessageType, @@ -27,7 +29,7 @@ import type { ConnectorResource } from "@connectors/resources/connector_resource interface StreamConversationToSlackParams { assistantName: string; connector: ConnectorResource; - conversation: ConversationType; + conversation: ConversationPublicType; mainMessage: ChatPostMessageResponse; slack: { slackChannelId: string; @@ -137,7 +139,7 @@ export async function streamConversationToSlack( if (agentMessages.length === 0) { return new Err(new Error("Failed to retrieve agent message")); } - const agentMessage = agentMessages[0] as AgentMessageType; + const agentMessage = agentMessages[0] as AgentMessagePublicType; const streamRes = await dustAPI.streamAgentMessageEvents({ conversation, @@ -149,7 +151,7 @@ export async function streamConversationToSlack( } let answer = ""; - const actions: AgentActionType[] = []; + const actions: AgentActionPublicType[] = []; for await (const event of streamRes.value.eventStream) { switch (event.type) { case "retrieval_params": diff --git a/sdks/js/src/index.ts b/sdks/js/src/index.ts index 0fb72851c3b7..709abb544ac0 100644 --- a/sdks/js/src/index.ts +++ b/sdks/js/src/index.ts @@ -4,8 +4,8 @@ import type { AgentActionSpecificEvent, AgentActionSuccessEvent, AgentErrorEvent, + AgentMessagePublicType, AgentMessageSuccessEvent, - AgentMessageType, APIError, ConversationPublicType, DataSourceViewType, @@ -530,7 +530,7 @@ export class DustAPI { message, }: { conversation: ConversationPublicType; - message: AgentMessageType; + message: AgentMessagePublicType; }) { const res = await this.request({ method: "GET", diff --git a/sdks/js/src/types.ts b/sdks/js/src/types.ts index ab1a292c30da..8215e579493f 100644 --- a/sdks/js/src/types.ts +++ b/sdks/js/src/types.ts @@ -737,6 +737,7 @@ const AgentActionTypeSchema = z.union([ WebsearchActionTypeSchema, BrowseActionTypeSchema, ]); +export type AgentActionPublicType = z.infer; const AgentMessageStatusSchema = FlexibleEnumSchema([ "created", @@ -772,7 +773,7 @@ const AgentMessageTypeSchema = z.object({ }) .nullable(), }); -export type AgentMessageType = z.infer; +export type AgentMessagePublicType = z.infer; const ConversationVisibilitySchema = FlexibleEnumSchema([ "unlisted", @@ -1390,7 +1391,7 @@ export type PublicPostMessagesRequestBody = z.infer< export type PostMessagesResponseBody = { message: UserMessageType; - agentMessages?: AgentMessageType[]; + agentMessages?: AgentMessagePublicType[]; }; export const PublicPostContentFragmentRequestBodySchema = z.object({