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

/generate throws KeyError: 'description' #736

Closed
labarba opened this issue Apr 18, 2024 · 8 comments
Closed

/generate throws KeyError: 'description' #736

labarba opened this issue Apr 18, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@labarba
Copy link

labarba commented Apr 18, 2024

Description

Trying /generate for the first time in our JupyterHub, so I don't know if this is a bug or an installation issue on our side. The command gives an error: "Sorry, something went wrong and I wasn't able to index that path." with:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.11/site-packages/jupyter_ai/chat_handlers/base.py", line 39, in process_message
    await self._process_message(message)
  File "/opt/conda/lib/python3.11/site-packages/jupyter_ai/chat_handlers/generate.py", line 241, in _process_message
    await fill_outline(outline, llm=self.llm, verbose=True)
  File "/opt/conda/lib/python3.11/site-packages/jupyter_ai/chat_handlers/generate.py", line 190, in fill_outline
    generate_code(section, outline["description"], llm=llm, verbose=verbose)
                           ~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'description'

Reproduce

Any call to \generate in the chat interface produces the same error.

Expected behavior

Expected a new generated notebook to be created.

Context

jupyter-ai                2.3.0                    pypi_0    pypi
jupyter-ai-magics         2.3.0                    pypi_0    pypi
jupyterlab                4.0.6              pyhd8ed1ab_0    conda-forge
@labarba labarba added the bug Something isn't working label Apr 18, 2024
Copy link

welcome bot commented Apr 18, 2024

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@labarba
Copy link
Author

labarba commented Apr 19, 2024

I've been staring at code for hours, but could not find a clue to this mystery—the function generate_outline() receives a description as input, but when called by _generate_notebook() it gets the input variable prompt instead, which it looks like is created by PromptTemplate() from langchain.prompts. That has input_variables=["description"], but I cannot find where this may come from.

@srdas
Copy link
Collaborator

srdas commented Apr 20, 2024

@labarba Are you using just /generate or the slash command followed by a prompt for what you want to generate. I tried using /generate <prompt> and it works well, as shown below.
image

I have also tried simply using /generate and it generates a random notebook but does not throw an error. And if the slash is a forward slash, it replies that it cannot process it. Maybe a reinstall will fix the problem? Hope this helps.

@labarba
Copy link
Author

labarba commented Apr 20, 2024

My exact input was:

/generate a lesson to teach beginners the essence of Pandas groupby(), including how to loop over grouped dataframes.

In the next input, I tried without the /generate command, as follows:

Give me an outline for a lesson to teach beginners the essence of Pandas groupby(), including how to loop over grouped dataframes.

… and it gave me a response as expected (indicating my connection to the LLM is good via API).

This is my uni JupyterHub installation, so not under my direct control. The admins are not keen on rebuilding the image, so I have to give them a good reason.

@srdas
Copy link
Collaborator

srdas commented Apr 20, 2024

@labarba It's good that your LLM API seems to be working just fine.
I tried your exact inputs (see below) and I suspect using /generate does a better job, if you look at the results with and without the slash command (but that's a judgment call). The left hand side panel below does not use /generate and the right hand side is the notebook generated by the /generate command.
image
It sounds like a fresh install will solve this issue for you. Hope this helps.

@srdas
Copy link
Collaborator

srdas commented Apr 22, 2024

@labarba I went ahead and reinstalled everything (including jupyterhub) in a new environment on a linux machine and tested if jupyter-ai works as expected after connecting remotely to jupyterhub on that machine. I can confirm it all works well. (I am using JLab v4.1.6.) and the latest version of jupyter-ai.

@labarba
Copy link
Author

labarba commented Apr 22, 2024

ha ha, meanwhile, I went ahead and installed jupyter-ai and dependencies on my local machine and it worked well with the /generate command, so while I convince the admin of our JupyterHub to reinstall I can do what I wanted to do on localhost!

@srdas
Copy link
Collaborator

srdas commented Apr 22, 2024

That's good to hear, and confirms that it is easier to solve a bug than bureaucracy! I'll go ahead and close the issue.

@srdas srdas closed this as completed Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants