mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
481d3855dc
- `llm(prompt)` -> `llm.invoke(prompt)` - `llm(prompt=prompt` -> `llm.invoke(prompt)` (same with `messages=`) - `llm(prompt, callbacks=callbacks)` -> `llm.invoke(prompt, config={"callbacks": callbacks})` - `llm(prompt, **kwargs)` -> `llm.invoke(prompt, **kwargs)`
54 lines
1.8 KiB
Plaintext
54 lines
1.8 KiB
Plaintext
# Helicone
|
|
|
|
This page covers how to use the [Helicone](https://helicone.ai) ecosystem within LangChain.
|
|
|
|
## What is Helicone?
|
|
|
|
Helicone is an [open-source](https://github.com/Helicone/helicone) observability platform that proxies your OpenAI traffic and provides you key insights into your spend, latency and usage.
|
|
|
|
![Screenshot of the Helicone dashboard showing average requests per day, response time, tokens per response, total cost, and a graph of requests over time.](/img/HeliconeDashboard.png "Helicone Dashboard")
|
|
|
|
## Quick start
|
|
|
|
With your LangChain environment you can just add the following parameter.
|
|
|
|
```bash
|
|
export OPENAI_API_BASE="https://oai.hconeai.com/v1"
|
|
```
|
|
|
|
Now head over to [helicone.ai](https://www.helicone.ai/signup) to create your account, and add your OpenAI API key within our dashboard to view your logs.
|
|
|
|
![Interface for entering and managing OpenAI API keys in the Helicone dashboard.](/img/HeliconeKeys.png "Helicone API Key Input")
|
|
|
|
## How to enable Helicone caching
|
|
|
|
```python
|
|
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))
|
|
```
|
|
|
|
[Helicone caching docs](https://docs.helicone.ai/advanced-usage/caching)
|
|
|
|
## How to use Helicone custom properties
|
|
|
|
```python
|
|
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))
|
|
```
|
|
|
|
[Helicone property docs](https://docs.helicone.ai/advanced-usage/custom-properties)
|