3db29810ba
Test / test (macos-latest, 3.11, ) (push) Has been cancelled
Test / test (macos-latest, 3.12, ) (push) Has been cancelled
Test / test (macos-latest, 3.13, ) (push) Has been cancelled
Update Stable Docs / update_stable_docs (push) Has been cancelled
Test / test (macos-latest, 3.10, ) (push) Has been cancelled
Test / test (macos-latest, 3.14, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14, 4.0rc4) (push) Has been cancelled
Test / test (windows-latest, 3.10, ) (push) Has been cancelled
Test / test (windows-latest, 3.11, ) (push) Has been cancelled
Test / test (windows-latest, 3.12, ) (push) Has been cancelled
Test / test (windows-latest, 3.13, ) (push) Has been cancelled
Test / test (windows-latest, 3.14, ) (push) Has been cancelled
28 KiB
28 KiB
Note
本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
English · 原始项目 · 上游 README
原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
LLM
一款 CLI 工具和 Python 库,用于与 OpenAI、Anthropic 的 Claude、Google 的 Gemini、Meta 的 Llama 以及数十种其他大语言模型(Large Language Model,LLM)交互,既可通过远程 API,也可使用可在你本机安装和运行的模型。
在 YouTube 上观看 命令行上的语言模型 演示,或阅读配套的详细笔记.
使用 LLM,你可以:
快速入门
首先,使用 pip 或 Homebrew 或 pipx 或 uv 安装 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"
使用各自插件对 Gemini 或 Anthropic 运行提示词:
llm install llm-gemini
llm keys set gemini
# Paste Gemini API key here
llm -m gemini-2.0-flash 'Tell me fun facts about Mountain View'
llm install llm-anthropic
llm keys set anthropic
# Paste Anthropic API key here
llm -m claude-4-opus 'Impress me with wild facts about turnips'
你还可以安装插件 以访问可在本地设备上运行的模型。如果你使用 Ollama:
# Install the plugin
llm install llm-ollama
# Download and run a prompt against the Orca Mini 7B model
ollama pull llama3.2:latest
llm -m llama3.2:latest 'What is the capital of France?'
要启动与模型的交互式聊天,请使用 llm chat:
llm chat -m gpt-4.1
Chatting with gpt-4.1
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.
Type '!fragment <my_fragment> [<another_fragment> ...]' to insert one or more fragments
> Tell me a joke about a pelican
Why don't pelicans like to tip waiters?
Because they always have a big bill!
关于本项目的更多背景:
- llm、ttok 和 strip-tags——用于 ChatGPT 及其他 LLM 的 CLI 工具
- LLM CLI 工具现已通过插件支持自托管语言模型
- LLM 现已提供用于处理嵌入向量的工具
- 使用 llm-clip 构建图像搜索引擎,使用 llm chat 与模型对话
- 你现在可以在终端中使用 LLM 对图像、音频和视频运行提示词
- 使用 LLM 模式(schema)从非结构化内容中提取结构化数据
- LLM 0.24 通过片段(fragment)和模板插件支持长上下文
另请参阅我博客上的 llm 标签。
目录
-
- llm –help
- llm prompt –help
- llm chat –help
- llm keys –help
- llm logs –help
- llm models –help
- llm templates –help
- llm schemas –help
- llm tools –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