Skip to content

ChatMessageInput does not allow "tool" role #486

@furzona-app

Description

@furzona-app

The ChatMessageInput interface does not allow the tool role, even though this role is allowed in other parts of the SDK.

ChatMessageInput:

export declare interface ChatMessageInput {
    /**
     * The sender of this message. Only "user", "assistant", and "system" is allowed. Defaults to
     * "user" if not specified.
     */
    role?: "user" | "assistant" | "system";
    ...

This issue becomes apparent when trying to create messages using Chat.from, where the tool role is not allowed because of the above TypeScript declaration. This is, however, still able to be done using a less straightforward way, as ChatMessageRoleData does seem to allow the tool role. It seems strange that the shorthand version of the same API does not allow this role, while the workaround does, which is why I am reporting it here.

ChatMessageRoleData:

/**
 * @public
 */
export declare type ChatMessageRoleData = "assistant" | "user" | "system" | "tool";

This is the less straightforward way, which would be equivalent to Chat.from if the tool role was allowed:

          const chat = Chat.empty();
          for (let i = 0; i < messages.length; i++) {
            const message = messages[i];
            chat.append(message.role, message.content);
          }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions