Files
wehub-resource-sync 3db29810ba
Update Stable Docs / update_stable_docs (push) Waiting to run
Test / test (macos-latest, 3.11, ) (push) Waiting to run
Test / test (macos-latest, 3.12, ) (push) Waiting to run
Test / test (macos-latest, 3.13, ) (push) Waiting to run
Test / test (ubuntu-latest, 3.10, ) (push) Waiting to run
Test / test (ubuntu-latest, 3.11, ) (push) Waiting to run
Test / test (ubuntu-latest, 3.12, ) (push) Waiting to run
Test / test (ubuntu-latest, 3.13, ) (push) Waiting to run
Test / test (ubuntu-latest, 3.14, ) (push) Waiting to run
Test / test (ubuntu-latest, 3.14, 4.0rc4) (push) Waiting to run
Test / test (windows-latest, 3.10, ) (push) Waiting to run
Test / test (windows-latest, 3.11, ) (push) Waiting to run
Test / test (windows-latest, 3.12, ) (push) Waiting to run
Test / test (macos-latest, 3.10, ) (push) Waiting to run
Test / test (macos-latest, 3.14, ) (push) Waiting to run
Test / test (windows-latest, 3.13, ) (push) Waiting to run
Test / test (windows-latest, 3.14, ) (push) Waiting to run
docs: make Chinese README the default
2026-07-13 10:48:35 +00:00

375 lines
28 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- WEHUB_ZH_README -->
> [!NOTE]
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
> [English](./README.en.md) · [原始项目](https://github.com/simonw/llm) · [上游 README](https://github.com/simonw/llm/blob/HEAD/README.md)
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
<!-- [[[cog
# README.md is generated from docs/index.md using sphinx_markdown_builder
import tempfile
import subprocess
from pathlib import Path
readme_markdown = ''
with tempfile.TemporaryDirectory() as tmpdir:
tmp_path = Path(tmpdir)
# Run: sphinx-build -M markdown ./docs ./tmpdir
subprocess.run([
"sphinx-build",
"-M", "markdown",
"./docs",
str(tmp_path)
], check=True)
index_file = tmp_path / "markdown" / "index.md"
readme_markdown = index_file.read_text(encoding="utf-8")
cog.out(readme_markdown)
]]] -->
# LLM
[![GitHub 仓库](https://img.shields.io/badge/github-repo-green)](https://github.com/simonw/llm)
[![PyPI](https://img.shields.io/pypi/v/llm.svg)](https://pypi.org/project/llm/)
[![更新日志](https://img.shields.io/github/v/release/simonw/llm?include_prereleases&label=changelog)](https://llm.datasette.io/en/stable/changelog.html)
[![测试](https://github.com/simonw/llm/workflows/Test/badge.svg)](https://github.com/simonw/llm/actions?query=workflow%3ATest)
[![许可证](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/llm/blob/main/LICENSE)
[![Discord](https://img.shields.io/discord/823971286308356157?label=discord)](https://datasette.io/discord-llm)
[![Homebrew](https://img.shields.io/homebrew/installs/dy/llm?color=yellow&label=homebrew&logo=homebrew)](https://formulae.brew.sh/formula/llm)
一款 CLI 工具和 Python 库,用于与 **OpenAI**、**Anthropic 的 Claude**、**Google 的 Gemini**、**Meta 的 Llama** 以及数十种其他大语言模型(Large Language ModelLLM)交互,既可通过远程 API,也可使用可在你本机安装和运行的模型。
在 YouTube 上观看 **[命令行上的语言模型](https://www.youtube.com/watch?v=QUXQNi6jQ30)** 演示,或[阅读配套的详细笔记](https://simonwillison.net/2024/Jun/17/cli-language-models/).
使用 LLM,你可以:
- [从命令行运行提示词](https://llm.datasette.io/en/stable/usage.html#usage-executing-prompts)
- [将提示词和响应存储在 SQLite 中](https://llm.datasette.io/en/stable/logging.html#logging)
- [生成并存储嵌入向量(embeddings)](https://llm.datasette.io/en/stable/embeddings/index.html#embeddings)
- [从文本和图像中提取结构化内容](https://llm.datasette.io/en/stable/schemas.html#schemas)
- [赋予模型执行工具的能力](https://llm.datasette.io/en/stable/tools.html#tools)
- … 以及更多、更多功能
## 快速入门
首先,使用 `pip` 或 Homebrew 或 `pipx``uv` 安装 LLM
```bash
pip install llm
```
或使用 Homebrew(参见[警告说明](https://llm.datasette.io/en/stable/setup.html#homebrew-warning)):
```bash
brew install llm
```
或使用 [pipx](https://pypa.github.io/pipx/):
```bash
pipx install llm
```
或使用 [uv](https://docs.astral.sh/uv/guides/tools/)
```bash
uv tool install llm
```
如果你有 [OpenAI API 密钥](https://platform.openai.com/api-keys),可以运行以下命令:
```bash
# 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](https://aistudio.google.com/apikey) 或 [Anthropic](https://console.anthropic.com/) 运行提示词:
```bash
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'
```
你还可以[安装插件](https://llm.datasette.io/en/stable/plugins/installing-plugins.html#installing-plugins) 以访问可在本地设备上运行的模型。如果你使用 [Ollama](https://ollama.com/):
```bash
# 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?'
```
要启动与模型的[交互式聊天](https://llm.datasette.io/en/stable/usage.html#usage-chat),请使用 `llm chat`
```bash
llm chat -m gpt-4.1
```
```default
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 工具](https://simonwillison.net/2023/May/18/cli-tools-for-llms/)
- [LLM CLI 工具现已通过插件支持自托管语言模型](https://simonwillison.net/2023/Jul/12/llm/)
- [LLM 现已提供用于处理嵌入向量的工具](https://simonwillison.net/2023/Sep/4/llm-embeddings/)
- [使用 llm-clip 构建图像搜索引擎,使用 llm chat 与模型对话](https://simonwillison.net/2023/Sep/12/llm-clip-and-chat/)
- [你现在可以在终端中使用 LLM 对图像、音频和视频运行提示词](https://simonwillison.net/2024/Oct/29/llm-multi-modal/)
- [使用 LLM 模式(schema)从非结构化内容中提取结构化数据](https://simonwillison.net/2025/Feb/28/llm-schemas/)
- [LLM 0.24 通过片段(fragment)和模板插件支持长上下文](https://simonwillison.net/2025/Apr/7/long-context-llm/)
另请参阅我博客上的 [llm 标签](https://simonwillison.net/tags/llm/)。
## 目录
* [设置](https://llm.datasette.io/en/stable/setup.html)
* [安装](https://llm.datasette.io/en/stable/setup.html#installation)
* [升级到最新版本](https://llm.datasette.io/en/stable/setup.html#upgrading-to-the-latest-version)
* [使用 uvx](https://llm.datasette.io/en/stable/setup.html#using-uvx)
* [关于 Homebrew 和 PyTorch 的说明](https://llm.datasette.io/en/stable/setup.html#a-note-about-homebrew-and-pytorch)
* [安装插件](https://llm.datasette.io/en/stable/setup.html#installing-plugins)
* [API 密钥管理](https://llm.datasette.io/en/stable/setup.html#api-key-management)
* [保存和使用已存储的密钥](https://llm.datasette.io/en/stable/setup.html#saving-and-using-stored-keys)
* [使用 key 选项传递密钥](https://llm.datasette.io/en/stable/setup.html#passing-keys-using-the-key-option)
* [环境变量中的密钥](https://llm.datasette.io/en/stable/setup.html#keys-in-environment-variables)
* [配置](https://llm.datasette.io/en/stable/setup.html#configuration)
* [设置自定义默认模型](https://llm.datasette.io/en/stable/setup.html#setting-a-custom-default-model)
* [设置自定义目录位置](https://llm.datasette.io/en/stable/setup.html#setting-a-custom-directory-location)
* [开启和关闭 SQLite 日志记录](https://llm.datasette.io/en/stable/setup.html#turning-sqlite-logging-on-and-off)
* [用法](https://llm.datasette.io/en/stable/usage.html)
* [执行提示词](https://llm.datasette.io/en/stable/usage.html#executing-a-prompt)
* [模型选项](https://llm.datasette.io/en/stable/usage.html#model-options)
* [附件](https://llm.datasette.io/en/stable/usage.html#attachments)
* [系统提示词](https://llm.datasette.io/en/stable/usage.html#system-prompts)
* [工具](https://llm.datasette.io/en/stable/usage.html#tools)
* [提取围栏代码块](https://llm.datasette.io/en/stable/usage.html#extracting-fenced-code-blocks)
* [模式(Schema](https://llm.datasette.io/en/stable/usage.html#schemas)
* [片段(Fragment](https://llm.datasette.io/en/stable/usage.html#fragments)
* [继续对话](https://llm.datasette.io/en/stable/usage.html#continuing-a-conversation)
* [在 Bash 或 Zsh 中使用 LLM 的技巧](https://llm.datasette.io/en/stable/usage.html#tips-for-using-llm-with-bash-or-zsh)
* [补全提示词](https://llm.datasette.io/en/stable/usage.html#completion-prompts)
* [启动交互式聊天](https://llm.datasette.io/en/stable/usage.html#starting-an-interactive-chat)
* [列出可用模型](https://llm.datasette.io/en/stable/usage.html#listing-available-models)
* [为模型设置默认选项](https://llm.datasette.io/en/stable/usage.html#setting-default-options-for-models)
* [OpenAI 模型](https://llm.datasette.io/en/stable/openai-models.html)
* [配置](https://llm.datasette.io/en/stable/openai-models.html#configuration)
* [OpenAI 语言模型](https://llm.datasette.io/en/stable/openai-models.html#openai-language-models)
* [模型特性](https://llm.datasette.io/en/stable/openai-models.html#model-features)
* [OpenAI 嵌入模型](https://llm.datasette.io/en/stable/openai-models.html#openai-embedding-models)
* [OpenAI 补全模型](https://llm.datasette.io/en/stable/openai-models.html#openai-completion-models)
* [添加更多 OpenAI 模型](https://llm.datasette.io/en/stable/openai-models.html#adding-more-openai-models)
* [其他模型](https://llm.datasette.io/en/stable/other-models.html)
* [安装和使用本地模型](https://llm.datasette.io/en/stable/other-models.html#installing-and-using-a-local-model)
* [兼容 OpenAI 的模型](https://llm.datasette.io/en/stable/other-models.html#openai-compatible-models)
* [额外的 HTTP 标头](https://llm.datasette.io/en/stable/other-models.html#extra-http-headers)
* [工具](https://llm.datasette.io/en/stable/tools.html)
* [工具的工作原理](https://llm.datasette.io/en/stable/tools.html#how-tools-work)
* [试用工具](https://llm.datasette.io/en/stable/tools.html#trying-out-tools)
* [LLM 的工具实现](https://llm.datasette.io/en/stable/tools.html#llm-s-implementation-of-tools)
* [默认工具](https://llm.datasette.io/en/stable/tools.html#default-tools)
* [实现工具的技巧](https://llm.datasette.io/en/stable/tools.html#tips-for-implementing-tools)
* [模式(Schema](https://llm.datasette.io/en/stable/schemas.html)
* [模式教程](https://llm.datasette.io/en/stable/schemas.html#schemas-tutorial)
* [从狗(dogs)示例入门](https://llm.datasette.io/en/stable/schemas.html#getting-started-with-dogs)
* [从新闻文章中提取人物](https://llm.datasette.io/en/stable/schemas.html#extracting-people-from-a-news-articles)
* [使用 JSON 模式](https://llm.datasette.io/en/stable/schemas.html#using-json-schemas)
* [指定模式的方式](https://llm.datasette.io/en/stable/schemas.html#ways-to-specify-a-schema)
* [简洁的 LLM 模式语法](https://llm.datasette.io/en/stable/schemas.html#concise-llm-schema-syntax)
* [在模板中保存可复用的模式](https://llm.datasette.io/en/stable/schemas.html#saving-reusable-schemas-in-templates)
* [浏览使用模式创建的已记录 JSON 对象](https://llm.datasette.io/en/stable/schemas.html#browsing-logged-json-objects-created-using-schemas)
* [模板](https://llm.datasette.io/en/stable/templates.html)
* [<code>save</code> 入门](https://llm.datasette.io/en/stable/templates.html#getting-started-with-save)
* [使用模板](https://llm.datasette.io/en/stable/templates.html#using-a-template)
* [列出可用模板](https://llm.datasette.io/en/stable/templates.html#listing-available-templates)
* [作为 YAML 文件的模板](https://llm.datasette.io/en/stable/templates.html#templates-as-yaml-files)
* [系统提示词](https://llm.datasette.io/en/stable/templates.html#system-prompts)
* [片段](https://llm.datasette.io/en/stable/templates.html#fragments)
* [选项](https://llm.datasette.io/en/stable/templates.html#options)
* [工具](https://llm.datasette.io/en/stable/templates.html#tools)
* [模式](https://llm.datasette.io/en/stable/templates.html#schemas)
* [额外的模板变量](https://llm.datasette.io/en/stable/templates.html#additional-template-variables)
* [指定默认参数](https://llm.datasette.io/en/stable/templates.html#specifying-default-parameters)
* [配置代码提取](https://llm.datasette.io/en/stable/templates.html#configuring-code-extraction)
* [为模板设置默认模型](https://llm.datasette.io/en/stable/templates.html#setting-a-default-model-for-a-template)
* [来自插件的模板加载器](https://llm.datasette.io/en/stable/templates.html#template-loaders-from-plugins)
* [片段](https://llm.datasette.io/en/stable/fragments.html)
* [在提示词中使用片段](https://llm.datasette.io/en/stable/fragments.html#using-fragments-in-a-prompt)
* [在聊天中使用片段](https://llm.datasette.io/en/stable/fragments.html#using-fragments-in-chat)
* [浏览片段](https://llm.datasette.io/en/stable/fragments.html#browsing-fragments)
* [为片段设置别名](https://llm.datasette.io/en/stable/fragments.html#setting-aliases-for-fragments)
* [在日志中查看片段](https://llm.datasette.io/en/stable/fragments.html#viewing-fragments-in-your-logs)
* [使用来自插件的片段](https://llm.datasette.io/en/stable/fragments.html#using-fragments-from-plugins)
* [列出可用的片段前缀](https://llm.datasette.io/en/stable/fragments.html#listing-available-fragment-prefixes)
* [模型别名](https://llm.datasette.io/en/stable/aliases.html)
* [列出别名](https://llm.datasette.io/en/stable/aliases.html#listing-aliases)
* [添加新别名](https://llm.datasette.io/en/stable/aliases.html#adding-a-new-alias)
* [删除别名](https://llm.datasette.io/en/stable/aliases.html#removing-an-alias)
* [查看别名文件](https://llm.datasette.io/en/stable/aliases.html#viewing-the-aliases-file)
* [嵌入向量(Embeddings](https://llm.datasette.io/en/stable/embeddings/index.html)
* [使用 CLI 生成嵌入](https://llm.datasette.io/en/stable/embeddings/cli.html)
* [llm embed](https://llm.datasette.io/en/stable/embeddings/cli.html#llm-embed)
* [llm embed-multi](https://llm.datasette.io/en/stable/embeddings/cli.html#llm-embed-multi)
* [llm similar](https://llm.datasette.io/en/stable/embeddings/cli.html#llm-similar)
* [llm embed-models](https://llm.datasette.io/en/stable/embeddings/cli.html#llm-embed-models)
* [llm collections list](https://llm.datasette.io/en/stable/embeddings/cli.html#llm-collections-list)
* [llm collections delete](https://llm.datasette.io/en/stable/embeddings/cli.html#llm-collections-delete)
* [从 Python 使用嵌入向量](https://llm.datasette.io/en/stable/embeddings/python-api.html)
* [使用集合](https://llm.datasette.io/en/stable/embeddings/python-api.html#working-with-collections)
* [检索相似项](https://llm.datasette.io/en/stable/embeddings/python-api.html#retrieving-similar-items)
* [SQL 模式](https://llm.datasette.io/en/stable/embeddings/python-api.html#sql-schema)
* [编写插件以添加新的嵌入模型](https://llm.datasette.io/en/stable/embeddings/writing-plugins.html)
* [`EmbeddingModel`](https://llm.datasette.io/en/stable/embeddings/writing-plugins.html#llm.EmbeddingModel)
* [嵌入二进制内容](https://llm.datasette.io/en/stable/embeddings/writing-plugins.html#embedding-binary-content)
* [嵌入存储格式](https://llm.datasette.io/en/stable/embeddings/storage.html)
* [插件](https://llm.datasette.io/en/stable/plugins/index.html)
* [安装插件](https://llm.datasette.io/en/stable/plugins/installing-plugins.html)
* [列出已安装的插件](https://llm.datasette.io/en/stable/plugins/installing-plugins.html#listing-installed-plugins)
* [使用部分插件运行](https://llm.datasette.io/en/stable/plugins/installing-plugins.html#running-with-a-subset-of-plugins)
* [插件目录](https://llm.datasette.io/en/stable/plugins/directory.html)
* [本地模型](https://llm.datasette.io/en/stable/plugins/directory.html#local-models)
* [远程 API](https://llm.datasette.io/en/stable/plugins/directory.html#remote-apis)
* [工具](https://llm.datasette.io/en/stable/plugins/directory.html#tools)
* [片段和模板加载器](https://llm.datasette.io/en/stable/plugins/directory.html#fragments-and-template-loaders)
* [嵌入模型](https://llm.datasette.io/en/stable/plugins/directory.html#embedding-models)
* [额外命令](https://llm.datasette.io/en/stable/plugins/directory.html#extra-commands)
* [仅供娱乐](https://llm.datasette.io/en/stable/plugins/directory.html#just-for-fun)
* [插件钩子](https://llm.datasette.io/en/stable/plugins/plugin-hooks.html)
* [register_commands(cli)](https://llm.datasette.io/en/stable/plugins/plugin-hooks.html#register-commands-cli)
* [register_models(register, model_aliases)](https://llm.datasette.io/en/stable/plugins/plugin-hooks.html#register-models-register-model-aliases)
* [register_embedding_models(register)](https://llm.datasette.io/en/stable/plugins/plugin-hooks.html#register-embedding-models-register)
* [register_tools(register)](https://llm.datasette.io/en/stable/plugins/plugin-hooks.html#register-tools-register)
* [register_template_loaders(register)](https://llm.datasette.io/en/stable/plugins/plugin-hooks.html#register-template-loaders-register)
* [register_fragment_loaders(register)](https://llm.datasette.io/en/stable/plugins/plugin-hooks.html#register-fragment-loaders-register)
* [开发模型插件](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html)
* [插件的初始结构](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html#the-initial-structure-of-the-plugin)
* [安装你的插件进行试用](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html#installing-your-plugin-to-try-it-out)
* [构建马尔可夫链](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html#building-the-markov-chain)
* [执行马尔可夫链](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html#executing-the-markov-chain)
* [将其添加到插件中](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html#adding-that-to-the-plugin)
* [理解 execute()](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html#understanding-execute)
* [提示词和响应会记录到数据库](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html#prompts-and-responses-are-logged-to-the-database)
* [添加选项](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html#adding-options)
* [分发你的插件](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html#distributing-your-plugin)
* [GitHub 仓库](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html#github-repositories)
* [将插件发布到 PyPI](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html#publishing-plugins-to-pypi)
* [添加元数据](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html#adding-metadata)
* [如果出现问题该怎么办](https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html#what-to-do-if-it-breaks)
* [高级模型插件](https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html)
* [技巧:懒加载昂贵的依赖项](https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html#tip-lazily-load-expensive-dependencies)
* [接受 API 密钥的模型](https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html#models-that-accept-api-keys)
* [异步模型](https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html#async-models)
* [支持模式](https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html#supporting-schemas)
* [支持工具](https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html#supporting-tools)
* [多模态模型的附件](https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html#attachments-for-multi-modal-models)
* [结构化消息和流式事件](https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html#structured-messages-and-streaming-events)
* [在 build_messages 中使用 prompt.messages](https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html#consuming-prompt-messages-in-build-messages)
* [在后续请求中恢复不透明元数据](https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html#restoring-opaque-metadata-on-subsequent-requests)
* [跟踪 token 使用量](https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html#tracking-token-usage)
* [跟踪解析后的模型名称](https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html#tracking-resolved-model-names)
* [LLM_RAISE_ERRORS](https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html#llm-raise-errors)
* [插件的实用函数](https://llm.datasette.io/en/stable/plugins/plugin-utilities.html)
* [llm.get_key()](https://llm.datasette.io/en/stable/plugins/plugin-utilities.html#llm-get-key)
* [llm.user_dir()](https://llm.datasette.io/en/stable/plugins/plugin-utilities.html#llm-user-dir)
* [llm.ModelError](https://llm.datasette.io/en/stable/plugins/plugin-utilities.html#llm-modelerror)
* [Response.fake()](https://llm.datasette.io/en/stable/plugins/plugin-utilities.html#response-fake)
* [Python API](https://llm.datasette.io/en/stable/python-api.html)
* [基本提示词执行](https://llm.datasette.io/en/stable/python-api.html#basic-prompt-execution)
* [系统提示词](https://llm.datasette.io/en/stable/python-api.html#system-prompts)
* [附件](https://llm.datasette.io/en/stable/python-api.html#attachments)
* [工具](https://llm.datasette.io/en/stable/python-api.html#tools)
* [模式](https://llm.datasette.io/en/stable/python-api.html#schemas)
* [片段](https://llm.datasette.io/en/stable/python-api.html#fragments)
* [模型选项](https://llm.datasette.io/en/stable/python-api.html#model-options)
* [传递 API 密钥](https://llm.datasette.io/en/stable/python-api.html#passing-an-api-key)
* [来自插件的模型](https://llm.datasette.io/en/stable/python-api.html#models-from-plugins)
* [访问底层 JSON](https://llm.datasette.io/en/stable/python-api.html#accessing-the-underlying-json)
* [Token 使用量](https://llm.datasette.io/en/stable/python-api.html#token-usage)
* [流式响应](https://llm.datasette.io/en/stable/python-api.html#streaming-responses)
* [结构化消息和流式事件](https://llm.datasette.io/en/stable/python-api.html#structured-messages-and-streaming-events)
* [异步模型](https://llm.datasette.io/en/stable/python-api.html#async-models)
* [`AsyncResponse`](https://llm.datasette.io/en/stable/python-api.html#llm.AsyncResponse)
* [工具函数可以是同步或异步的](https://llm.datasette.io/en/stable/python-api.html#tool-functions-can-be-sync-or-async)
* [异步模型的工具使用](https://llm.datasette.io/en/stable/python-api.html#tool-use-for-async-models)
* [对话](https://llm.datasette.io/en/stable/python-api.html#conversations)
* [使用工具的对话](https://llm.datasette.io/en/stable/python-api.html#conversations-using-tools)
* [列出模型](https://llm.datasette.io/en/stable/python-api.html#listing-models)
* [在响应完成时运行代码](https://llm.datasette.io/en/stable/python-api.html#running-code-when-a-response-has-completed)
* [其他函数](https://llm.datasette.io/en/stable/python-api.html#other-functions)
* [set_alias(alias, model_id)](https://llm.datasette.io/en/stable/python-api.html#set-alias-alias-model-id)
* [remove_alias(alias)](https://llm.datasette.io/en/stable/python-api.html#remove-alias-alias)
* [set_default_model(alias)](https://llm.datasette.io/en/stable/python-api.html#set-default-model-alias)
* [get_default_model()](https://llm.datasette.io/en/stable/python-api.html#get-default-model)
* [set_default_embedding_model(alias) and get_default_embedding_model()](https://llm.datasette.io/en/stable/python-api.html#set-default-embedding-model-alias-and-get-default-embedding-model)
* [记录到 SQLite](https://llm.datasette.io/en/stable/logging.html)
* [查看日志](https://llm.datasette.io/en/stable/logging.html#viewing-the-logs)
* [-s/short 模式](https://llm.datasette.io/en/stable/logging.html#s-short-mode)
* [对话日志](https://llm.datasette.io/en/stable/logging.html#logs-for-a-conversation)
* [搜索日志](https://llm.datasette.io/en/stable/logging.html#searching-the-logs)
* [按特定 ID 之后的记录过滤](https://llm.datasette.io/en/stable/logging.html#filtering-past-a-specific-id)
* [按模型过滤](https://llm.datasette.io/en/stable/logging.html#filtering-by-model)
* [按使用了特定片段的提示词过滤](https://llm.datasette.io/en/stable/logging.html#filtering-by-prompts-that-used-specific-fragments)
* [按使用了特定工具的提示词过滤](https://llm.datasette.io/en/stable/logging.html#filtering-by-prompts-that-used-specific-tools)
* [浏览使用模式收集的数据](https://llm.datasette.io/en/stable/logging.html#browsing-data-collected-using-schemas)
* [使用 Datasette 浏览日志](https://llm.datasette.io/en/stable/logging.html#browsing-logs-using-datasette)
* [备份数据库](https://llm.datasette.io/en/stable/logging.html#backing-up-your-database)
* [SQL 模式](https://llm.datasette.io/en/stable/logging.html#sql-schema)
* [相关工具](https://llm.datasette.io/en/stable/related-tools.html)
* [strip-tags](https://llm.datasette.io/en/stable/related-tools.html#strip-tags)
* [ttok](https://llm.datasette.io/en/stable/related-tools.html#ttok)
* [Symbex](https://llm.datasette.io/en/stable/related-tools.html#symbex)
* [CLI 参考](https://llm.datasette.io/en/stable/help.html)
* [llm help](https://llm.datasette.io/en/stable/help.html#llm-help)
* [llm prompt help](https://llm.datasette.io/en/stable/help.html#llm-prompt-help)
* [llm chat help](https://llm.datasette.io/en/stable/help.html#llm-chat-help)
* [llm keys help](https://llm.datasette.io/en/stable/help.html#llm-keys-help)
* [llm logs help](https://llm.datasette.io/en/stable/help.html#llm-logs-help)
* [llm models help](https://llm.datasette.io/en/stable/help.html#llm-models-help)
* [llm templates help](https://llm.datasette.io/en/stable/help.html#llm-templates-help)
* [llm schemas help](https://llm.datasette.io/en/stable/help.html#llm-schemas-help)
* [llm tools help](https://llm.datasette.io/en/stable/help.html#llm-tools-help)
* [llm aliases help](https://llm.datasette.io/en/stable/help.html#llm-aliases-help)
* [llm fragments help](https://llm.datasette.io/en/stable/help.html#llm-fragments-help)
* [llm plugins help](https://llm.datasette.io/en/stable/help.html#llm-plugins-help)
* [llm install help](https://llm.datasette.io/en/stable/help.html#llm-install-help)
* [llm uninstall help](https://llm.datasette.io/en/stable/help.html#llm-uninstall-help)
* [llm embed help](https://llm.datasette.io/en/stable/help.html#llm-embed-help)
* [llm embed-multi help](https://llm.datasette.io/en/stable/help.html#llm-embed-multi-help)
* [llm similar help](https://llm.datasette.io/en/stable/help.html#llm-similar-help)
* [llm embed-models help](https://llm.datasette.io/en/stable/help.html#llm-embed-models-help)
* [llm collections help](https://llm.datasette.io/en/stable/help.html#llm-collections-help)
* [llm openai help](https://llm.datasette.io/en/stable/help.html#llm-openai-help)
* [贡献](https://llm.datasette.io/en/stable/contributing.html)
* [更新已记录的 HTTP API 交互及相关快照](https://llm.datasette.io/en/stable/contributing.html#updating-recorded-http-api-interactions-and-associated-snapshots)
* [调试技巧](https://llm.datasette.io/en/stable/contributing.html#debugging-tricks)
* [文档](https://llm.datasette.io/en/stable/contributing.html#documentation)
* [发布流程](https://llm.datasette.io/en/stable/contributing.html#release-process)
* [更新日志](https://llm.datasette.io/en/stable/changelog.html)
<!-- [[[end]]] -->