Skip to content

Commit 4aa7ce4

Browse files
authored
Adding magics functionality to the litellm implementation (#1437)
* Adding `magics` functionality to the `litellm` implementation * updates for initializing aliases and resolving types, mypy * Update magics.py * init alias * Update test_magics.py * Update magics.py * Changed `error` to `fix` in magics * Update index.md * Update test_magics.py * Update magics.py * streamlining magics * removed update command * initial_chat_model * magics pre-commit * Update magics.py
1 parent 38d145c commit 4aa7ce4

File tree

21 files changed

+292
-260
lines changed

21 files changed

+292
-260
lines changed

docs/source/users/index.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ We currently support the following language model providers:
762762
To configure a default model you can use the IPython `%config` magic:
763763

764764
```python
765-
%config AiMagics.default_language_model = "anthropic:claude-v1.2"
765+
%config AiMagics.initial_language_model = "anthropic:claude-v1.2"
766766
```
767767

768768
Then subsequent magics can be invoked without typing in the model:
@@ -772,10 +772,10 @@ Then subsequent magics can be invoked without typing in the model:
772772
Write a poem about C++.
773773
```
774774

775-
You can configure the default model for all notebooks by specifying `c.AiMagics.default_language_model` tratilet in `ipython_config.py`, for example:
775+
You can configure the default model for all notebooks by specifying `c.AiMagics.initial_language_model` tratilet in `ipython_config.py`, for example:
776776

777777
```python
778-
c.AiMagics.default_language_model = "anthropic:claude-v1.2"
778+
c.AiMagics.initial_language_model = "anthropic:claude-v1.2"
779779
```
780780

781781
The location of `ipython_config.py` file is documented in [IPython configuration reference](https://ipython.readthedocs.io/en/stable/config/intro.html).
@@ -965,18 +965,18 @@ produced the following Python error:
965965
Write a new version of this code that does not produce that error.
966966
```
967967

968-
As a shortcut for explaining errors, you can use the `%ai error` command, which will explain the most recent error using the model of your choice.
968+
As a shortcut for explaining and fixing errors, you can use the `%ai fix` command, which will explain the most recent error using the model of your choice.
969969

970970
```
971-
%ai error anthropic:claude-v1.2
971+
%ai fix anthropic:claude-v1.2
972972
```
973973

974974
### Creating and managing aliases
975975

976-
You can create an alias for a model using the `%ai register` command. For example, the command:
976+
You can create an alias for a model using the `%ai alias` command. For example, the command:
977977

978978
```
979-
%ai register claude anthropic:claude-v1.2
979+
%ai alias claude anthropic:claude-v1.2
980980
```
981981

982982
will register the alias `claude` as pointing to the `anthropic` provider's `claude-v1.2` model. You can then use this alias as you would use any other model name:
@@ -1001,10 +1001,10 @@ prompt = PromptTemplate(
10011001
chain = LLMChain(llm=llm, prompt=prompt)
10021002
```
10031003

1004-
… and then use `%ai register` to give it a name:
1004+
… and then use `%ai alias` to give it a name:
10051005

10061006
```
1007-
%ai register companyname chain
1007+
%ai alias companyname chain
10081008
```
10091009

10101010
You can change an alias's target using the `%ai update` command:
@@ -1013,10 +1013,10 @@ You can change an alias's target using the `%ai update` command:
10131013
%ai update claude anthropic:claude-instant-v1.0
10141014
```
10151015

1016-
You can delete an alias using the `%ai delete` command:
1016+
You can delete an alias using the `%ai dealias` command:
10171017

10181018
```
1019-
%ai delete claude
1019+
%ai dealias claude
10201020
```
10211021

10221022
You can see a list of all aliases by running the `%ai list` command.
@@ -1103,7 +1103,7 @@ the selections they make in the settings panel will take precedence over these v
11031103

11041104
Specify default language model
11051105
```bash
1106-
jupyter lab --AiExtension.default_language_model=bedrock-chat:anthropic.claude-v2
1106+
jupyter lab --AiExtension.initial_language_model=bedrock-chat:anthropic.claude-v2
11071107
```
11081108

11091109
Specify default embedding model

packages/jupyter-ai-magics/jupyter_ai_magics/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from __future__ import annotations
2-
from ._version import __version__
32

43
from typing import TYPE_CHECKING
54

5+
from ._version import __version__
6+
67
if TYPE_CHECKING:
78
from IPython.core.interactiveshell import InteractiveShell
89

0 commit comments

Comments
 (0)