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

Make existing thread messages compatible with append method #1128

Open
igo opened this issue Nov 1, 2024 · 1 comment
Open

Make existing thread messages compatible with append method #1128

igo opened this issue Nov 1, 2024 · 1 comment

Comments

@igo
Copy link
Contributor

igo commented Nov 1, 2024

Would be great if messages are compatible with all methods that deal with messages. For example if I want to restart conversation with the first message:

  const firstUserMsg = runtime.thread.getState().messages.find(m => m.role === 'user');
  runtime.switchToNewThread();
  runtime.thread.append({
    role: 'system',
    content: [{ type: 'text', text: 'new system message' }],
  });
  if (firstUserMsg) {
    runtime.thread.append(firstUserMsg);
                          ^^^^^^^^^^^^
  }
Argument of type 'BaseThreadMessage & MessageCommonProps & { role: "user"; content: ThreadUserContentPart[]; attachments: readonly CompleteAttachment[]; }' is not assignable to parameter of type 'CreateAppendMessage'.
  Type 'BaseThreadMessage & MessageCommonProps & { role: "user"; content: ThreadUserContentPart[]; attachments: readonly CompleteAttachment[]; }' is not assignable to type '{ parentId?: string | null | undefined; role?: "system" | "user" | "assistant" | undefined; content: [TextContentPart] | CoreUserContentPart[] | CoreAssistantContentPart[]; attachments?: readonly CompleteAttachment[] | undefined; }'.
    Types of property 'content' are incompatible.
      Type 'ThreadUserContentPart[]' is not assignable to type '[TextContentPart] | CoreUserContentPart[] | CoreAssistantContentPart[]'.
        Type 'ThreadUserContentPart[]' is not assignable to type 'CoreUserContentPart[] | CoreAssistantContentPart[]'.
          Type 'ThreadUserContentPart[]' is not assignable to type 'CoreUserContentPart[]'.
            Type 'ThreadUserContentPart' is not assignable to type 'CoreUserContentPart'.
              Type 'UIContentPart' is not assignable to type 'CoreUserContentPart'.
                Property 'audio' is missing in type 'UIContentPart' but required in type 'Unstable_AudioContentPart'.ts(2345)
AssistantTypes.d.ts(14, 5): 'audio' is declared here.
@Yonom
Copy link
Owner

Yonom commented Nov 2, 2024

Thanks for reporting this! its mianly a typescript bug, you can force cast it via

runtime.thread.append(firstUserMsg as AppendMessage);

I'll fix this soon on the library's side as well

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

No branches or pull requests

2 participants