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

Interpolating Out[] puts an object, not text, into a text prompt #241

Closed
JasonWeill opened this issue Jun 23, 2023 · 1 comment · Fixed by #250
Closed

Interpolating Out[] puts an object, not text, into a text prompt #241

JasonWeill opened this issue Jun 23, 2023 · 1 comment · Fixed by #250
Assignees
Labels
bug Something isn't working @jupyter-ai/magics
Milestone

Comments

@JasonWeill
Copy link
Collaborator

Description

Interpolating the special Out[] array into a text prompt causes an object to be inserted into the prompt:

Screen Shot 2023-06-23 at 2 16 55 PM

Out[9] should contain only the text A new moon has no illuminated portion visible, while a full moon has its entire disk fully illuminated by the sun. Instead, it is a TextWithMetadata object, not serialized as text when I interpolate it in In[10], so what gets translated into Spanish is a Python descriptor of an object.

One can work around this by calling .text on the Out[n] object:

Screen Shot 2023-06-23 at 2 25 35 PM
%%ai chatgpt
Translate this sentence into Spanish: {Out[12].text}

Reproduce

  1. Run an %%ai command with -f text specified as an option. The output appears as Out[9] in the above example.
  2. Run another %%ai command with {Out[9]} as part of the prompt.
  3. The prompt is interpreted to have jupyter_ai_magics.magics.TextWithMetadata, not str, as the type of Out[9].

Expected behavior

When interpolating a TextWithMetadata object, like Out[n], into a text prompt, the text portion should be used.

Context

  • JupyterLab version: 3.5.3, with Jupyter AI 0.8.0
@JasonWeill JasonWeill added bug Something isn't working @jupyter-ai/magics labels Jun 23, 2023
@dlqqq dlqqq added this to the 0.9.0 Release milestone Jun 23, 2023
@JasonWeill
Copy link
Collaborator Author

The treatment of text as TextWithMetadata, not a TextDisplayObject, was introduced in #69 by @ellisonbg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working @jupyter-ai/magics
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants