-
-
Notifications
You must be signed in to change notification settings - Fork 325
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
Allow configuring a default model for cell magics (and line error magic) #962
Conversation
b3299db
to
ebf6a04
Compare
ebf6a04
to
5bd035a
Compare
Awesome @krassowski! Fantastic to see this happening. Just out of curiosity: Would it be possible to make the syntax more intuitive, e.g. instead of this:
One could also say
That's human readable and easy to memorize, even though could be even shorter... |
I would argue that
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krassowski - Looks great! Have wanted this for some time - TY. I tried various things to break it - but it's all good.
Note: Why not default to the Text Completion LLM set in Chat always (if there is one set), and only use the %config
magic if you want to override and use a different default LLM for the magics?
The documentation add-ons are also good.
Code to correct cell magic use of shell looks good.
Maybe in a future PR. It is rather complex quest because the chat and ai magics do not necessarily live in the same environment (may be physically different computers). While chat imports a copy of the magics package, it is potentially a different copy than the one used in the kernel. There are ways to solve this, I explored some of the ideas in the linked issue. |
@@ -257,7 +265,7 @@ def _is_langchain_chain(self, name): | |||
if not acceptable_name.match(name): | |||
return False | |||
|
|||
ipython = get_ipython() | |||
ipython = self.shell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krassowski
I am not deeply familiar with magics, curious if this change has any implications or is a drop-in replacement for the existing statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is drop-in replacement, except that it now can be properly tested and used outside of IPython interpreter. There is a reason why Magics
constructor receives the shell
argument. get_ipython()
should never be used in magics.
…ic) (jupyterlab#962) * Allow configuring a default model for cell magics (and line error magic) * Add documentation
The name and help for
default_language_model
is copied over from the one used in equivalentjupyter-ai
traitlet.