LLM#

GitHub repo PyPI Changelog Tests License Discord Homebrew

一个用于与大型语言模型交互的命令行工具和 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 密钥,您可以运行此命令

# 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!
>

目录#