LLM#

GitHub repo PyPI Changelog Tests License Discord 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
Type '!edit' to open your default editor and modify the prompt.
> Tell me a joke about a pelican
Why don't pelicans like to tip waiters?

Because they always have a big bill!
>

目录#