LLM#
一个 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!
>
目录#
- 设置
- 用法
- OpenAI 模型
- 其他模型
- 模式
- 模板
- 片段
- 模型别名
- 嵌入
- 插件
- Python API
- 记录到 SQLite
- 相关工具
- CLI 参考
- llm –help
- llm prompt –help
- llm chat –help
- llm keys –help
- llm logs –help
- llm models –help
- llm templates –help
- llm schemas –help
- llm aliases –help
- llm fragments –help
- llm plugins –help
- llm install –help
- llm uninstall –help
- llm embed –help
- llm embed-multi –help
- llm similar –help
- llm embed-models –help
- llm collections –help
- llm openai –help
- llm –help
- 贡献
- 更新日志
- 0.25 (2025-05-04)
- 0.25a0 (2025-04-10)
- 0.24.2 (2025-04-08)
- 0.24.1 (2025-04-08)
- 0.24 (2025-04-07)
- 0.24a1 (2025-04-06)
- 0.24a0 (2025-02-28)
- 0.23 (2025-02-28)
- 0.22 (2025-02-16)
- 0.21 (2025-01-31)
- 0.20 (2025-01-22)
- 0.19.1 (2024-12-05)
- 0.19 (2024-12-01)
- 0.19a2 (2024-11-20)
- 0.19a1 (2024-11-19)
- 0.19a0 (2024-11-19)
- 0.18 (2024-11-17)
- 0.18a1 (2024-11-14)
- 0.18a0 (2024-11-13)
- 0.17 (2024-10-29)
- 0.17a0 (2024-10-28)
- 0.16 (2024-09-12)
- 0.15 (2024-07-18)
- 0.14 (2024-05-13)
- 0.13.1 (2024-01-26)
- 0.13 (2024-01-26)
- 0.12 (2023-11-06)
- 0.11.2 (2023-11-06)
- 0.11.1 (2023-10-31)
- 0.11 (2023-09-18)
- 0.10 (2023-09-12)
- 0.10a1 (2023-09-11)
- 0.10a0 (2023-09-04)
- 0.9 (2023-09-03)
- 0.8.1 (2023-08-31)
- 0.8 (2023-08-20)
- 0.7.1 (2023-08-19)
- 0.7 (2023-08-12)
- 0.6.1 (2023-07-24)
- 0.6 (2023-07-18)
- 0.5 (2023-07-12)
- 0.4.1 (2023-06-17)
- 0.4 (2023-06-17)
- 0.3 (2023-05-17)
- 0.2 (2023-04-01)
- 0.1 (2023-04-01)