跳到主要内容
Open In ColabOpen on GitHub

KoboldAI API

KoboldAI 是一个“基于浏览器的前端,用于借助多个本地和远程 AI 模型进行 AI 辅助写作……”。它有一个公共和本地 API,可以在 LangChain 中使用。

本示例介绍了如何将 LangChain 与该 API 结合使用。

文档可以在浏览器中通过在端点末尾添加 /api 找到(例如 http://127.0.0.1/:5000/api)。

from langchain_community.llms import KoboldApiLLM
API 参考:KoboldApiLLM

在使用 --api 或 --public-api 启动 webui 后,将下面显示的端点替换为输出中显示的端点。

您可以选择传入温度(temperature)或最大长度(max_length)等参数。

llm = KoboldApiLLM(endpoint="http://192.168.1.144:5000", max_length=80)
response = llm.invoke(
"### Instruction:\nWhat is the first book of the bible?\n### Response:"
)