You can use the %ai
cell magic to run special commands. If a model has the same name as a command, you will need to refer to the model using the provider:model
format only; the model
shortcut will not work.
%reload_ext jupyter_ai
%ai help
will show you a list of all supported commands.
%ai help
Usage: %%ai [OPTIONS] MODEL_ID Invokes a language model identified by MODEL_ID, with the prompt being contained in all lines after the first. Both local model IDs and global model IDs (with the provider ID explicitly prefixed, followed by a colon) are accepted. To view available language models, please run `%ai list`. Options: -f, --format [code|html|image|json|markdown|math|md|text] IPython display to use when rendering output. [default="markdown"] -r, --reset Clears the conversation transcript used when interacting with an OpenAI chat model provider. Does nothing with other providers. -n, --region-name TEXT AWS region name, e.g. 'us-east-1'. Required for SageMaker provider; does nothing with other providers. -q, --request-schema TEXT The JSON object the endpoint expects, with the prompt being substituted into any value that matches the string literal '<prompt>'. Required for SageMaker provider; does nothing with other providers. -p, --response-path TEXT A JSONPath string that retrieves the language model's output from the endpoint's JSON response. Required for SageMaker provider; does nothing with other providers. --help Show this message and exit. ------------------------------------------------------------------------------ Usage: %ai [OPTIONS] COMMAND [ARGS]... Invokes a subcommand. Options: --help Show this message and exit. Commands: delete Delete an alias. See `%ai delete --help` for options. error Explains the most recent error. help Show this message and exit. list List language models. See `%ai list --help` for options. register Register a new alias. See `%ai register --help` for options. update Update the target of an alias. See `%ai update --help` for options.
%ai register --help
Usage: %ai register [OPTIONS] NAME TARGET Register a new alias called NAME for the model or chain named TARGET. Options: --help Show this message and exit.
%ai list
Provider | Environment variable | Set? | Models |
---|---|---|---|
ai21 |
AI21_API_KEY |
✅ | ai21:j1-large , ai21:j1-grande , ai21:j1-jumbo , ai21:j1-grande-instruct , ai21:j2-large , ai21:j2-grande , ai21:j2-jumbo , ai21:j2-grande-instruct , ai21:j2-jumbo-instruct |
anthropic |
ANTHROPIC_API_KEY |
✅ | anthropic:claude-v1 , anthropic:claude-v1.0 , anthropic:claude-v1.2 , anthropic:claude-instant-v1 , anthropic:claude-instant-v1.0 |
cohere |
COHERE_API_KEY |
✅ | cohere:medium , cohere:xlarge |
huggingface_hub |
HUGGINGFACEHUB_API_TOKEN |
✅ | This provider does not define a list of models. |
openai |
OPENAI_API_KEY |
✅ | openai:text-davinci-003 , openai:text-davinci-002 , openai:text-curie-001 , openai:text-babbage-001 , openai:text-ada-001 , openai:davinci , openai:curie , openai:babbage , openai:ada |
openai-chat |
OPENAI_API_KEY |
✅ | openai-chat:gpt-4 , openai-chat:gpt-4-0314 , openai-chat:gpt-4-32k , openai-chat:gpt-4-32k-0314 , openai-chat:gpt-3.5-turbo , openai-chat:gpt-3.5-turbo-0301 |
openai-chat-new |
OPENAI_API_KEY |
✅ | openai-chat-new:gpt-4 , openai-chat-new:gpt-4-0314 , openai-chat-new:gpt-4-32k , openai-chat-new:gpt-4-32k-0314 , openai-chat-new:gpt-3.5-turbo , openai-chat-new:gpt-3.5-turbo-0301 |
sagemaker-endpoint |
Not applicable. | N/A | This provider does not define a list of models. |
Aliases and custom commands:
Name | Target |
---|---|
gpt2 |
huggingface_hub:gpt2 |
gpt3 |
openai:text-davinci-003 |
chatgpt |
openai-chat:gpt-3.5-turbo |
gpt4 |
openai-chat:gpt-4 |
%ai list openai
Provider | Environment variable | Set? | Models |
---|---|---|---|
openai |
OPENAI_API_KEY |
✅ | openai:text-davinci-003 , openai:text-davinci-002 , openai:text-curie-001 , openai:text-babbage-001 , openai:text-ada-001 , openai:davinci , openai:curie , openai:babbage , openai:ada |
Using the syntax %ai register NAME TARGET
, you can create a new alias to an existing alias's target. The target must be specified using the full provider:model
syntax. You cannot create an alias to another alias.
%ai register mychat openai-chat:gpt-4
Registered new alias mychat
%ai list
Provider | Environment variable | Set? | Models |
---|---|---|---|
ai21 |
AI21_API_KEY |
✅ | ai21:j1-large , ai21:j1-grande , ai21:j1-jumbo , ai21:j1-grande-instruct , ai21:j2-large , ai21:j2-grande , ai21:j2-jumbo , ai21:j2-grande-instruct , ai21:j2-jumbo-instruct |
anthropic |
ANTHROPIC_API_KEY |
✅ | anthropic:claude-v1 , anthropic:claude-v1.0 , anthropic:claude-v1.2 , anthropic:claude-instant-v1 , anthropic:claude-instant-v1.0 |
cohere |
COHERE_API_KEY |
✅ | cohere:medium , cohere:xlarge |
huggingface_hub |
HUGGINGFACEHUB_API_TOKEN |
✅ | This provider does not define a list of models. |
openai |
OPENAI_API_KEY |
✅ | openai:text-davinci-003 , openai:text-davinci-002 , openai:text-curie-001 , openai:text-babbage-001 , openai:text-ada-001 , openai:davinci , openai:curie , openai:babbage , openai:ada |
openai-chat |
OPENAI_API_KEY |
✅ | openai-chat:gpt-4 , openai-chat:gpt-4-0314 , openai-chat:gpt-4-32k , openai-chat:gpt-4-32k-0314 , openai-chat:gpt-3.5-turbo , openai-chat:gpt-3.5-turbo-0301 |
openai-chat-new |
OPENAI_API_KEY |
✅ | openai-chat-new:gpt-4 , openai-chat-new:gpt-4-0314 , openai-chat-new:gpt-4-32k , openai-chat-new:gpt-4-32k-0314 , openai-chat-new:gpt-3.5-turbo , openai-chat-new:gpt-3.5-turbo-0301 |
sagemaker-endpoint |
Not applicable. | N/A | This provider does not define a list of models. |
Aliases and custom commands:
Name | Target |
---|---|
gpt2 |
huggingface_hub:gpt2 |
gpt3 |
openai:text-davinci-003 |
chatgpt |
openai-chat:gpt-3.5-turbo |
gpt4 |
openai-chat:gpt-4 |
mychat |
openai-chat:gpt-4 |
%%ai gpt3
What model is this?
This is an example of a Model X.
%ai update mychat openai:text-davinci-003
Updated target of alias mychat
%%ai mychat
What model is this?
This model is not specified.
%ai list
Provider | Environment variable | Set? | Models |
---|---|---|---|
ai21 |
AI21_API_KEY |
✅ | ai21:j1-large , ai21:j1-grande , ai21:j1-jumbo , ai21:j1-grande-instruct , ai21:j2-large , ai21:j2-grande , ai21:j2-jumbo , ai21:j2-grande-instruct , ai21:j2-jumbo-instruct |
anthropic |
ANTHROPIC_API_KEY |
✅ | anthropic:claude-v1 , anthropic:claude-v1.0 , anthropic:claude-v1.2 , anthropic:claude-instant-v1 , anthropic:claude-instant-v1.0 |
cohere |
COHERE_API_KEY |
✅ | cohere:medium , cohere:xlarge |
huggingface_hub |
HUGGINGFACEHUB_API_TOKEN |
✅ | This provider does not define a list of models. |
openai |
OPENAI_API_KEY |
✅ | openai:text-davinci-003 , openai:text-davinci-002 , openai:text-curie-001 , openai:text-babbage-001 , openai:text-ada-001 , openai:davinci , openai:curie , openai:babbage , openai:ada |
openai-chat |
OPENAI_API_KEY |
✅ | openai-chat:gpt-4 , openai-chat:gpt-4-0314 , openai-chat:gpt-4-32k , openai-chat:gpt-4-32k-0314 , openai-chat:gpt-3.5-turbo , openai-chat:gpt-3.5-turbo-0301 |
openai-chat-new |
OPENAI_API_KEY |
✅ | openai-chat-new:gpt-4 , openai-chat-new:gpt-4-0314 , openai-chat-new:gpt-4-32k , openai-chat-new:gpt-4-32k-0314 , openai-chat-new:gpt-3.5-turbo , openai-chat-new:gpt-3.5-turbo-0301 |
sagemaker-endpoint |
Not applicable. | N/A | This provider does not define a list of models. |
Aliases and custom commands:
Name | Target |
---|---|
gpt2 |
huggingface_hub:gpt2 |
gpt3 |
openai:text-davinci-003 |
chatgpt |
openai-chat:gpt-3.5-turbo |
gpt4 |
openai-chat:gpt-4 |
mychat |
openai:text-davinci-003 |
%ai delete mychat
Deleted alias mychat
%ai list
Provider | Environment variable | Set? | Models |
---|---|---|---|
ai21 |
AI21_API_KEY |
✅ | ai21:j1-large , ai21:j1-grande , ai21:j1-jumbo , ai21:j1-grande-instruct , ai21:j2-large , ai21:j2-grande , ai21:j2-jumbo , ai21:j2-grande-instruct , ai21:j2-jumbo-instruct |
anthropic |
ANTHROPIC_API_KEY |
✅ | anthropic:claude-v1 , anthropic:claude-v1.0 , anthropic:claude-v1.2 , anthropic:claude-instant-v1 , anthropic:claude-instant-v1.0 |
cohere |
COHERE_API_KEY |
✅ | cohere:medium , cohere:xlarge |
huggingface_hub |
HUGGINGFACEHUB_API_TOKEN |
✅ | This provider does not define a list of models. |
openai |
OPENAI_API_KEY |
✅ | openai:text-davinci-003 , openai:text-davinci-002 , openai:text-curie-001 , openai:text-babbage-001 , openai:text-ada-001 , openai:davinci , openai:curie , openai:babbage , openai:ada |
openai-chat |
OPENAI_API_KEY |
✅ | openai-chat:gpt-4 , openai-chat:gpt-4-0314 , openai-chat:gpt-4-32k , openai-chat:gpt-4-32k-0314 , openai-chat:gpt-3.5-turbo , openai-chat:gpt-3.5-turbo-0301 |
openai-chat-new |
OPENAI_API_KEY |
✅ | openai-chat-new:gpt-4 , openai-chat-new:gpt-4-0314 , openai-chat-new:gpt-4-32k , openai-chat-new:gpt-4-32k-0314 , openai-chat-new:gpt-3.5-turbo , openai-chat-new:gpt-3.5-turbo-0301 |
sagemaker-endpoint |
Not applicable. | N/A | This provider does not define a list of models. |
Aliases and custom commands:
Name | Target |
---|---|
gpt2 |
huggingface_hub:gpt2 |
gpt3 |
openai:text-davinci-003 |
chatgpt |
openai-chat:gpt-3.5-turbo |
gpt4 |
openai-chat:gpt-4 |
You can define a LangChain chain in a local variable and use that as the target in a magic %ai register
command.
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
from langchain.llms import OpenAI
llm = OpenAI(temperature=0.9)
prompt = PromptTemplate(
input_variables=["product"],
template="What is a good name for a company that makes {product}?",
)
chain = LLMChain(llm=llm, prompt=prompt)
from langchain.chains import LLMChain
chain = LLMChain(llm=llm, prompt=prompt)
# Run the chain only specifying the input variable.
print(chain.run("colorful socks"))
Bright Feet Socks
%ai register company chain
Registered new alias company
%ai list
Provider | Environment variable | Set? | Models |
---|---|---|---|
ai21 |
AI21_API_KEY |
✅ | ai21:j1-large , ai21:j1-grande , ai21:j1-jumbo , ai21:j1-grande-instruct , ai21:j2-large , ai21:j2-grande , ai21:j2-jumbo , ai21:j2-grande-instruct , ai21:j2-jumbo-instruct |
anthropic |
ANTHROPIC_API_KEY |
✅ | anthropic:claude-v1 , anthropic:claude-v1.0 , anthropic:claude-v1.2 , anthropic:claude-instant-v1 , anthropic:claude-instant-v1.0 |
cohere |
COHERE_API_KEY |
✅ | cohere:medium , cohere:xlarge |
huggingface_hub |
HUGGINGFACEHUB_API_TOKEN |
✅ | This provider does not define a list of models. |
openai |
OPENAI_API_KEY |
✅ | openai:text-davinci-003 , openai:text-davinci-002 , openai:text-curie-001 , openai:text-babbage-001 , openai:text-ada-001 , openai:davinci , openai:curie , openai:babbage , openai:ada |
openai-chat |
OPENAI_API_KEY |
✅ | openai-chat:gpt-4 , openai-chat:gpt-4-0314 , openai-chat:gpt-4-32k , openai-chat:gpt-4-32k-0314 , openai-chat:gpt-3.5-turbo , openai-chat:gpt-3.5-turbo-0301 |
openai-chat-new |
OPENAI_API_KEY |
✅ | openai-chat-new:gpt-4 , openai-chat-new:gpt-4-0314 , openai-chat-new:gpt-4-32k , openai-chat-new:gpt-4-32k-0314 , openai-chat-new:gpt-3.5-turbo , openai-chat-new:gpt-3.5-turbo-0301 |
sagemaker-endpoint |
Not applicable. | N/A | This provider does not define a list of models. |
Aliases and custom commands:
Name | Target |
---|---|
gpt2 |
huggingface_hub:gpt2 |
gpt3 |
openai:text-davinci-003 |
chatgpt |
openai-chat:gpt-3.5-turbo |
gpt4 |
openai-chat:gpt-4 |
company |
custom chain |
%%ai company
colorful socks
Funky Toes
%%ai company --format text
colorful socks
Rainbow Toe Socks.