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

fix: better chatbot input & bubble #3404

Merged
merged 8 commits into from
Jan 13, 2025

Conversation

Light2Dark
Copy link
Contributor

@Light2Dark Light2Dark commented Jan 12, 2025

📝 Summary

Screenshot 2025-01-13 at 1 24 50 AM

Fixes #3401 . Use codemirror as chatbot input, / triggers autocomplete.

🔍 Description of Changes

  • multiline input
  • multiline chat bubble
  • removed an unnecessary extension (codemirror-mentions) and implemented custom one
    note: dataset atom is not finding any tables, hence @ is not working.

📋 Checklist

  • I have read the contributor guidelines.
  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • I have added tests for the changes made.
  • I have run the code and verified that it works as expected.

📜 Reviewers

@akshayka OR @mscolnick

Copy link

vercel bot commented Jan 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 13, 2025 3:03pm

Copy link

vercel bot commented Jan 12, 2025

@Light2Dark is attempting to deploy a commit to the marimo Team on Vercel.

A member of the Team first needs to authorize it.

frontend/src/plugins/impl/chat/chat-ui.tsx Outdated Show resolved Hide resolved
@@ -277,8 +283,17 @@ export const PromptInput = ({
}),
);

// Trigger autocompletion for text that begins with @ or
// @ + additional symbols specified
const matchBeforeRegex = additionalCompletions
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do 2 separate mentions plugins? One for "@" data and one for "/" prompts; instead of appending the trigger, replace 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.

do you mean if there are additionalCompletions, we only use the "/" regex?

it's also possible to accept multiple regexes, if we want to make it extensible

export function mentions(
  matchBeforeRegexes: RegExp[],
  data: Completion[] = [],
): Extension {
  return autocompletion({
    override: [
      (context: CompletionContext) => {
        const word = matchBeforeRegexes
          .map((regex) => context.matchBefore(regex))
          .find(Boolean);

Copy link
Contributor

Choose a reason for hiding this comment

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

from the code, it looks like @ would trigger autocomplete for prompts, and I was thinking that @ only trigger autocomplete for datasets, while / triggers for prompts. you could maybe do this in a single mentions plugin, but doing two (one for datasets and one for prompts) might be easier

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, you can't do 2 autocompletion extensions, since they will overwrite and cause a conflict from codemirror. Seems a solution will be tricky if we want to have 2 mentions plugin.

return [
      mentions(/@(\w+)?/, completions),
      mentions(/\/(\w+)?/, additionalCompletions?.completions),
      ...
]

error: Config merge conflict for field override

but anyways, @ will indeed trigger autocomplete, but there are no matching prompts beginning with @, so nothing is found.

Copy link
Contributor

Choose a reason for hiding this comment

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

gotcha. i see, that makes sense.

then what you have is good to me.

@mscolnick
Copy link
Contributor

I think the mention changes are good / worth keeping. I plan to add support for MCPs so we could eventually replace this with https://github.com/marimo-team/codemirror-mcp

@Light2Dark Light2Dark changed the title [wip] fix: better chatbot input & bubble fix: better chatbot input & bubble Jan 13, 2025
Copy link
Contributor

@mscolnick mscolnick left a comment

Choose a reason for hiding this comment

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

awesome stuff!

@mscolnick mscolnick merged commit 3720183 into marimo-team:main Jan 13, 2025
18 of 19 checks passed
Copy link

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.10.13-dev4

@Light2Dark Light2Dark deleted the better-chat-ui branch January 15, 2025 00:20
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.

support multiline for mo.ui.chat input & bubble
2 participants