跳到主要内容
Open on GitHub

Helicone

本页介绍了如何在 LangChain 中使用 Helicone 生态系统。

什么是 Helicone?

Helicone 是一个 开源 可观测性平台,可代理您的 OpenAI 流量,并为您提供关于您的支出、延迟和使用情况的关键见解。

Screenshot of the Helicone dashboard showing average requests per day, response time, tokens per response, total cost, and a graph of requests over time.

快速开始

在您的 LangChain 环境中,您只需添加以下参数即可。

export OPENAI_API_BASE="https://oai.hconeai.com/v1"

现在前往 helicone.ai 创建您的帐户,并在我们的仪表板中添加您的 OpenAI API 密钥以查看您的日志。

Interface for entering and managing OpenAI API keys in the Helicone dashboard.

如何启用 Helicone 缓存

from langchain_openai import OpenAI
import openai
openai.api_base = "https://oai.hconeai.com/v1"

llm = OpenAI(temperature=0.9, headers={"Helicone-Cache-Enabled": "true"})
text = "What is a helicone?"
print(llm.invoke(text))
API 参考:OpenAI

Helicone 缓存文档

如何使用 Helicone 自定义属性

from langchain_openai import OpenAI
import openai
openai.api_base = "https://oai.hconeai.com/v1"

llm = OpenAI(temperature=0.9, headers={
"Helicone-Property-Session": "24",
"Helicone-Property-Conversation": "support_issue_2",
"Helicone-Property-App": "mobile",
})
text = "What is a helicone?"
print(llm.invoke(text))
API 参考:OpenAI

Helicone 属性文档


此页面是否对您有帮助?