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

Support vscode details tags #18

Closed
civvic opened this issue Aug 21, 2024 · 0 comments
Closed

Support vscode details tags #18

civvic opened this issue Aug 21, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@civvic
Copy link

civvic commented Aug 21, 2024

Running this in GitHub or any Jupyter flavor with the usual frontends:

<details open>

- id: 'msg_01J9h95kubV9fAA66i6q9kzD'
- content: [{'text': "Hello Vic, it's nice to meet you. How can I assist you today?", 'type': 'text'}]
- model: 'claude-3-5-sonnet-20240620'
- role: 'assistant'
- stop_reason: 'end_turn'
- stop_sequence: None
- type: 'message'
- usage: {'input_tokens': 19, 'output_tokens': 21}

</details>

you get:

  • id: 'msg_01J9h95kubV9fAA66i6q9kzD'
  • content: [{'text': "Hello Vic, it's nice to meet you. How can I assist you today?", 'type': 'text'}]
  • model: 'claude-3-5-sonnet-20240620'
  • role: 'assistant'
  • stop_reason: 'end_turn'
  • stop_sequence: None
  • type: 'message'
  • usage: {'input_tokens': 19, 'output_tokens': 21}

As expected. But running the same cell in VSCode 1.91.1 we get an empty usage field:

  • id: 'msg_01J9h95kubV9fAA66i6q9kzD'
  • content: [{'text': "Hello Vic, it's nice to meet you. How can I assist you today?", 'type': 'text'}]
  • model: 'claude-3-5-sonnet-20240620'
  • role: 'assistant'
  • stop_reason: 'end_turn'
  • stop_sequence: None
  • type: 'message'
  • usage:

with this generated HTML:

<details open="">
<ul>
...
<li>content: [{'text': "Hello Vic, it's nice to meet you. How can I assist you today?", 'type': 'text'}]</li>
...
<li>type: 'message'</li>
<li input_tokens:="" 19,="" output_tokens:="" 21="">usage:</li>
</ul>
</details>

This is VSCode frontend being really weird (a bug, really), The <detail> Details disclosure widget seems well supported by all browsers except VSCode notebooks.

I can open an issue with VSCode, or just add two characters to 00_core.ipnb Message._repr_markdown:

def _repr_markdown_(self:(Message)):
    det = '\n- '.join(f'{k}: `{v}`' for k,v in self.model_dump().items())
    return f"""{contents(self)}

<details>

- {det}

</details>"""

to get this:

  • id: 'msg_01J9h95kubV9fAA66i6q9kzD'
  • content: [{'text': "Hello Vic, it's nice to meet you. How can I assist you today?", 'type': 'text'}]
  • model: 'claude-3-5-sonnet-20240620'
  • role: 'assistant'
  • stop_reason: 'end_turn'
  • stop_sequence: None
  • type: 'message'
  • usage: {'input_tokens': 19, 'output_tokens': 21}

that IMHO is more legible, equally robust and compatible with this and future versions of VSCode.

@jph00 jph00 changed the title VSCode weird Details disclosure rendering Support vscode details tags Aug 27, 2024
@jph00 jph00 added the enhancement New feature or request label Aug 27, 2024
@jph00 jph00 closed this as completed in e06d5ef Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants