Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assistant v2: conversations types #1227

Merged
merged 6 commits into from
Sep 1, 2023
Merged

Conversation

spolu
Copy link
Contributor

@spolu spolu commented Sep 1, 2023

Introduces conversations types for Assistant v2.

See https://www.notion.so/dust-tt/DesignDoc-Assistant-V2-Architecture-acb11f35708c49b1bba4f0294d98daf5 for context

@dust-tt/engineering-team please review thoroughly

@spolu spolu requested a review from fontanierh September 1, 2023 13:01
Copy link
Contributor

@fontanierh fontanierh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -0,0 +1,119 @@
import { ModelId } from "@app/lib/models";

import { UserProviderType, UserType } from "../user";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit relative import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing in another PR 👍

id: ModelId;
sId: string;
status: "visible" | "deleted";
parentMessageId: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't parentId be enough here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a Message sId so that's my motivation for having messageId visible to follow convention... will leave it as is for now

@spolu spolu merged commit db0d063 into main Sep 1, 2023
@spolu spolu deleted the spolu-assistant_v2_conversation_types branch September 1, 2023 14:14
Copy link
Contributor

@lasryaric lasryaric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left 2 comments.

};

export type AssistantUserMention = {
provider: UserProviderType;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we point to a front.users.id field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far ModelId is only used as a convenience on some object for us, and the invariant is that we should be able to switch data store transparently. The real business logic pointer to a user is its provider and providerId, we could add a shortId to circumvent that, but I'm quite bearish on relying entirely on the SQL ID.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok - I would be curious to know why you don't want to rely on this SQL id but we can have that conversation later.
I am fine with this rational.

sId: string;
title?: string;
participants: UserType[];
content: (AssistantUserMessageType[] | AssistantAgentMessageType[])[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are going to need some magic flag to know what type it is here at runtime.
Otherwise we would need a class if we want to do it without any magic flag.
Just mentioning it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we'll likely iterate on that if this is too much of an issue. I presume here that we can use a isAssistantUserMessage and isAssistantAgentMessage functions similar to Result, but maybe I'm wrong?

Copy link
Contributor

@lasryaric lasryaric Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use functions like this to do type assertion, but we'll need to rely on some known properties of the type and set it for each object of these types we instantiate. Exactly the same way we do it with __is_dust_error here:

 const workflowError: WorkflowError = {
      type: "transient_upstream_activity_error",
      message:
        "Received unexpected undefined replies from Slack API in getMessagesForChannel (generally transient)",
      __is_dust_error: true,
    };

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I thiiiink this should be easy-ish we'll have clear invariants that separate the two (we can add a string to the type to name it and use that as a flag also)?

Sounds good to you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants