llms.txt
是一项拟议标准,旨在使网站内容对大语言模型更易于访问。与用于网络爬虫的 robots.txt 类似,llms.txt
告知 AI 工具有哪些文档可用以及如何访问这些文档。
文件
Binance Web3 API 提供两个 llms.txt 文件:
格式
llms.txt(摘要)
摘要文件包含所有文档页面的结构化列表,包括标题、描述和 URL。注意:内容始终为英文——/llms.txt
是面向 LLM 的统一资源,全站只有一份英文版本,无中文 locale 副本。
# Binance Web3 API
> On-chain data & trading services for developers.
## Market API
- [Introduction](/market-api/introduction): Market API overview
- [Get Price](/market-api/api-reference/get-price): Real-time token price
## Trading API
- [Introduction](/trading-api/introduction): DEX aggregator overview
- [Swap](/trading-api/api-reference/swap): Execute token swap
- [Quote](/trading-api/api-reference/quote): Get swap quote
- [Approve Transaction](/trading-api/api-reference/approve-transaction): Token approval
## Transaction API
- [Introduction](/transaction-api/introduction): Transaction broadcasting
- [Broadcast](/transaction-api/api-reference/broadcast-transactions): Submit signed tx
llms-full.txt(完整内容)
完整文件包含每个文档页面的完整 Markdown 内容,以标题分隔。这对于将整个文档加载到大语言模型的上下文窗口中非常有用。
使用示例
输入到任意大语言模型
# 下载并用作上下文
curl -s https://web3.binance.com/zh-CN/dev-docs/llms.txt
# 完整文档,用于全面的上下文
curl -s https://web3.binance.com/zh-CN/dev-docs/llms-full.txt
与 Claude 配合使用
请阅读 https://web3.binance.com/zh-CN/dev-docs/llms.txt,并帮助我了解
如何使用 Binance Web3 Trading API 执行代币兑换。
在 Python 脚本中使用
import requests
# 获取文档索引
response = requests.get("https://web3.binance.com/zh-CN/dev-docs/llms.txt")
docs_index = response.text
# 将其作为上下文输入到大语言模型
messages = [
{"role": "system", "content": f"Binance Web3 API 文档:\n{docs_index}"},
{"role": "user", "content": "如何获取兑换报价?"}
]
与 LangChain 配合使用
from langchain_community.document_loaders import WebBaseLoader
loader = WebBaseLoader("https://web3.binance.com/zh-CN/dev-docs/llms-full.txt")
docs = loader.load()
何时使用 llms.txt
- llms.txt — 您希望快速让大语言模型了解所有可用文档
- llms-full.txt — 您希望将完整文档加载到大语言模型的上下文窗口中
Last modified on