大语言模型#

Homebrew Homebrew Homebrew Homebrew Homebrew Homebrew Homebrew

一个CLI工具和Python库,用于与大型语言模型进行交互,既可以通过远程API,也可以通过可以安装并在您自己的机器上运行的模型。

从命令行运行提示将结果存储在SQLite中生成嵌入等等。

这里有一个YouTube视频演示附带的详细笔记

项目背景:

更多内容请查看我博客上的llm标签

快速开始#

首先,使用 pip 或 Homebrew 或 pipx 安装 LLM:

pip install llm

或者使用 Homebrew(请参阅警告说明):

brew install llm

或者使用 pipx

pipx install llm

或者使用 uv

uv tool install llm

如果你有一个OpenAI API key密钥,你可以运行这个:

# Paste your OpenAI API key into this
llm keys set openai

# Run a prompt (with the default gpt-4o-mini model)
llm "Ten fun names for a pet pelican"

# Extract text from an image
llm "extract text" -a scanned-document.jpg

# Use a system prompt against a file
cat myfile.py | llm -s "Explain this code"

或者你可以安装一个插件并使用可以在本地设备上运行的模型:

# Install the plugin
llm install llm-gpt4all

# Download and run a prompt against the Orca Mini 7B model
llm -m orca-mini-3b-gguf2-q4_0 'What is the capital of France?'

要开始与模型进行交互式聊天,请使用llm chat

llm chat -m gpt-4o
Chatting with gpt-4o
Type 'exit' or 'quit' to exit
Type '!multi' to enter multiple lines, then '!end' to finish
> Tell me a joke about a pelican
Why don't pelicans like to tip waiters?

Because they always have a big bill!
>

目录#