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

Error running an LLMChain object as a model alias #541

Closed
jamesjun opened this issue Dec 22, 2023 · 3 comments · Fixed by #560
Closed

Error running an LLMChain object as a model alias #541

jamesjun opened this issue Dec 22, 2023 · 3 comments · Fixed by #560
Labels
bug Something isn't working

Comments

@jamesjun
Copy link
Contributor

Running cell #19 produces the following error:

Input:

%%ai company
colorful socks

Output:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[20], line 1
----> 1 get_ipython().run_cell_magic('ai', 'company', 'colorful socks\n')

File ~/miniconda3/envs/mbox/lib/python3.11/site-packages/IPython/core/interactiveshell.py:2478, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
   2476 with self.builtin_trap:
   2477     args = (magic_arg_s, cell)
-> 2478     result = fn(*args, **kwargs)
   2480 # The code below prevents the output from being displayed
   2481 # when using magics with decodator @output_can_be_silenced
   2482 # when the last Python token in the expression is a ';'.
   2483 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File ~/miniconda3/envs/mbox/lib/python3.11/site-packages/jupyter_ai_magics/magics.py:597, in AiMagics.ai(self, line, cell)
    594 ip = get_ipython()
    595 prompt = prompt.format_map(FormatDict(ip.user_ns))
--> 597 return self.run_ai_cell(args, prompt)

File ~/miniconda3/envs/mbox/lib/python3.11/site-packages/jupyter_ai_magics/magics.py:465, in AiMagics.run_ai_cell(self, args, prompt)
    464 def run_ai_cell(self, args: CellArgs, prompt: str):
--> 465     provider_id, local_model_id = self._decompose_model_id(args.model_id)
    466     Provider = self._get_provider(provider_id)
    467     if Provider is None:
...
     87 
     88         # naively search through the dictionary and return the first provider
     89         # that provides a model of the same ID.

TypeError: unhashable type: 'LLMChain'
@jamesjun jamesjun added the bug Something isn't working label Dec 22, 2023
Copy link

welcome bot commented Dec 22, 2023

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! 🎉

@JasonWeill
Copy link
Collaborator

@jamesjun Thank you for reporting this! I can also reproduce this.

@JasonWeill JasonWeill changed the title Error running examples/commands.ipynb cell #19 Error running an LLMChain object as a model alias Jan 3, 2024
@JasonWeill
Copy link
Collaborator

The error seems to be in decompose_model_id, which puts the LLMChain object in a tuple of two items, normally "Provider ID" and "Local model ID". The error "unhashable type" suggests that we're using this object where only a hashable type, like a string, can be used. (Shout out to %ai error for explaining this!)

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

Successfully merging a pull request may close this issue.

2 participants