上层接地检查
此笔记本介绍了如何开始使用 Upstage 接地检查模型。
安装
安装langchain-upstage包。
pip install -U langchain-upstage
环境设置
确保设置以下环境变量:
UPSTAGE_API_KEY:来自 Upstage 开发人员文档的 Upstage API 密钥。
import os
os.environ["UPSTAGE_API_KEY"] = "YOUR_API_KEY"
用法
初始化UpstageGroundednessCheck类。
from langchain_upstage import UpstageGroundednessCheck
groundedness_check = UpstageGroundednessCheck()
API 参考:UpstageGroundednessCheck
使用run检查输入文本的接地性的方法。
request_input = {
"context": "Mauna Kea is an inactive volcano on the island of Hawai'i. Its peak is 4,207.3 m above sea level, making it the highest point in Hawaii and second-highest peak of an island on Earth.",
"answer": "Mauna Kea is 5,207.3 meters tall.",
}
response = groundedness_check.invoke(request_input)
print(response)