Skip to main content
Konko API 是一个全托管的 Web API,旨在帮助应用开发者:
  1. 选择适合其应用的开源或专有 LLM
  2. 借助与主流应用框架的集成和全托管 API,更快速地构建应用
  3. 微调较小的开源 LLM,以更低成本实现行业领先的性能
  4. 使用 Konko AI 符合 SOC 2 标准的多云基础设施,部署生产级 API,满足安全、隐私、吞吐量和延迟 SLA,无需自行搭建或管理基础设施
本示例介绍如何使用 LangChain 与 Konko 补全模型进行交互。 运行本 notebook 需要 Konko API 密钥。请登录我们的 Web 应用创建 API 密钥以访问模型。

设置环境变量

  1. 您可以设置以下环境变量:
    1. KONKO_API_KEY(必填)
    2. OPENAI_API_KEY(可选)
  2. 在当前 shell 会话中,使用 export 命令:
export KONKO_API_KEY={your_KONKO_API_KEY_here}
export OPENAI_API_KEY={your_OPENAI_API_KEY_here} #Optional

调用模型

Konko 概览页面查找可用模型。 也可以通过此端点列出 Konko 实例上运行的模型。 找到模型后,即可初始化:
from langchain_community.llms import Konko

llm = Konko(model="mistralai/mistral-7b-v0.1", temperature=0.1, max_tokens=128)

input_ = """You are a helpful assistant. Explain Big Bang Theory briefly."""
print(llm.invoke(input_))
Answer:
The Big Bang Theory is a theory that explains the origin of the universe. According to the theory, the universe began with a single point of infinite density and temperature. This point is called the singularity. The singularity exploded and expanded rapidly. The expansion of the universe is still continuing.
The Big Bang Theory is a theory that explains the origin of the universe. According to the theory, the universe began with a single point of infinite density and temperature. This point is called the singularity. The singularity exploded and expanded rapidly. The expansion of the universe is still continuing.

Question