PrefectHQ / marvin

✨ Build AI interfaces that spark joy
https://askmarvin.ai
Apache License 2.0
4.99k stars 322 forks source link

NoMatches: No nodes match #190

Closed mrpg closed 1 year ago

mrpg commented 1 year ago

Hi, thanks for this project. I ran marvin chat and entered my API key. However, subsequent requests seem to error out.

Here is an example:

Prompt = "What is something only a bot would say?"

I get the exception NoMatches: No nodes match. Here is a fuller view:

│ ╭───────────────────────────────────────────────────────── locals ──────────────────────────────────────────────────────────╮                                            │
│ │           bot = Bot(                                                                                                      │                                            │
│ │                 │   id='bot_01GXJJX4DND5CZWTN1G10NDB22',                                                                  │                                            │
│ │                 │   name='Marvin',                                                                                        │                                            │
│ │                 │   description='The Genuine People Personality you know and love.\n\nMarvin can also help you crea'+34,  │                                            │
│ │                 │   plugins=[                                                                                             │                                            │
│ │                 │   │   list_all_bots(name='list_all_bots', discriminator='list_all_bots'),                               │                                            │
│ │                 │   │   get_bot_details(name='get_bot_details', discriminator='get_bot_details'),                         │                                            │
│ │                 │   │   create_bot(name='create_bot', discriminator='create_bot'),                                        │                                            │
│ │                 │   │   update_bot(name='update_bot', discriminator='update_bot'),                                        │                                            │
│ │                 │   │   delete_bot(name='delete_bot', discriminator='delete_bot')                                         │                                            │
│ │                 │   ]                                                                                                     │                                            │
│ │                 )                                                                                                         │                                            │
│ │  bot_response = BotResponse(classes={'response', 'bot-response'}, pseudo_classes={'enabled'})                             │                                            │
│ │ bot_responses = <DOMQuery MainScreen(pseudo_classes={'focus-within', 'enabled'}) filter='BotResponse'>                    │                                            │
│ │         event = Submitted()                                                                                               │                                            │
│ │      response = BotResponse(                                                                                              │                                            │
│ │                 │   id='msg_01GXJK6ZJSE5VQFXEETABGWP2F',                                                                  │                                            │
│ │                 │   role='bot',                                                                                           │                                            │
│ │                 │   content="Well, that's an interesting question. As an AI language model, I can tell you th"+240,       │                                            │
│ │                 │   name='Marvin',                                                                                        │                                            │
│ │                 │   timestamp=DateTime(2023, 4, 9, 8, 48, 6, 233439, tzinfo=Timezone('UTC')),                             │                                            │
│ │                 │   bot_id='bot_01GXJJX4DND5CZWTN1G10NDB22',                                                              │                                            │
│ │                 │   data={},                                                                                              │                                            │
│ │                 │   parsed_content="Well, that's an interesting question. As an AI language model, I can tell you th"+240 │                                            │
│ │                 )                                                                                                         │                                            │
│ │          self = MainScreen(pseudo_classes={'focus-within', 'enabled'})                                                    │                                            │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                            │
│                                                                                                                                                                          │
│ /home/lab/env/lib/python3.9/site-packages/textual/css/query.py:285 in last                                                                                               │
│                                                                                                                                                                          │
│   282 │   │   │   The matching Widget.                                                                                                                                   │
│   283 │   │   """                                                                                                                                                        │
│   284 │   │   if not self.nodes:                                                                                                                                         │
│ ❱ 285 │   │   │   raise NoMatches(f"No nodes match {self!r}")                                                                                                            │
│   286 │   │   last = self.nodes[-1]                                                                                                                                      │
│   287 │   │   if expect_type is not None and not isinstance(last, expect_type):                                                                                          │
│   288 │   │   │   raise WrongType(                                                                                                                                       │
│                                                                                                                                                                          │
│ ╭─────────────────────────────────────────────── locals ───────────────────────────────────────────────╮                                                                 │
│ │ expect_type = None                                                                                   │                                                                 │
│ │        self = <DOMQuery MainScreen(pseudo_classes={'focus-within', 'enabled'}) filter='BotResponse'> │                                                                 │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
NoMatches: No nodes match <DOMQuery MainScreen(pseudo_classes={'focus-within', 'enabled'}) filter='BotResponse'>

So I guess the API connection and almost everything works, but there might be a small bug in the rendering?!

Running this on Debian 11, Python 3.9.2, and using the latest marvin version from pip.

Thanks.

mrpg commented 1 year ago

I can confirm that everything works as expected on Arch Linux with Python 3.10.10. This is despite both machines running textual 0.19.0. So this might actually be a bug in textual.

jlowin commented 1 year ago

Hi @mrpg, thanks for the report! There's only one place we make that specific call and it's actually not needed anymore, so I've removed it in #191. I'm a little surprised you hit it because there should always be a BotResponse available, but I can't see any other place it could have happened. Hopefully this helps - I'll try to push a bugfix release this morning

jlowin commented 1 year ago

0.7.3 is out with a fix for this!

mrpg commented 1 year ago

Thanks for your quick reply and the fix. I can confirm that there is no exception raised under 0.7.3, but no response appears now. I'd be happy to help with debugging, but don't worry, I'll just keep using the Arch Linux machine for this.

jlowin commented 1 year ago

Hmm I'm sorry to hear that. I'll keep trying to replicate.

jlowin commented 1 year ago

@mrpg I think I found the issue which may be that on Python 3.9, calling functools.partial masks the fact that a function generates coroutines. I'm releasing 0.7.4 which has a fix for that situation. Please give it a try, and we'll make sure this works as expected!

youens commented 1 year ago

Whatever you did, 0.7.4 fixed this problem for me on MacOS with Python 3.10.3. Thanks!

mrpg commented 1 year ago

@jlowin Thank you so much, I can now confirm that version 0.7.4 works as expected under Debian 11 (and continues to work under Arch Linux). I am impressed by marvin and your incredible speed! Thanks again.