大语言模型#
一个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!
>
目录#
- Setup
- Usage
- OpenAI models
- Other models
- Embeddings
- Plugins
- Model aliases
- Python API
- Prompt templates
- Logging to SQLite
- Related tools
- CLI reference
- Contributing
- Changelog
- 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)