-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f19235
commit fece99e
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: "LangChain Integration" | ||
--- | ||
Pezzo supports integration with LangChain for observability and monitoring. Integration is as easy as configuring the LLM to proxy requests to Pezzo. | ||
|
||
## Example: LangChain with OpenAI | ||
|
||
Below is an example using `ChatOpenAI`. The same can be applied to chains and agents. | ||
|
||
<Tabs> | ||
<Tab title="LangChain + Node.js"> | ||
```ts | ||
import { ChatOpenAI } from "langchain/chat_models/openai"; | ||
|
||
const llm = new ChatOpenAI({ | ||
openAIApiKey: process.env.OPENAI_API_KEY, | ||
temperature: 0, | ||
configuration: { | ||
baseURL: "https://proxy.pezzo.ai/openai/v1", | ||
defaultHeaders: { | ||
"X-Pezzo-Api-Key": "<Your API Key>", | ||
"X-Pezzo-Project-Id": "<Your Project ID>", | ||
"X-Pezzo-Environment": "Production", | ||
}, | ||
}, | ||
}); | ||
|
||
const llmResult = await llm.predict("Tell me 5 fun facts about yourself!"); | ||
``` | ||
</Tab> | ||
<Tab title="LangChain + Python"> | ||
```py | ||
from langchain.chat_models import ChatOpenAI | ||
|
||
llm = ChatOpenAI( | ||
openai_api_key='<>', | ||
openai_api_base="https://proxy.pezzo.ai/openai/v1", | ||
default_headers={ | ||
"X-Pezzo-Api-Key": "<Your API Key>", | ||
"X-Pezzo-Project-Id": "<Your Project ID>", | ||
"X-Pezzo-Environment": "Production", | ||
} | ||
) | ||
|
||
llm_result = llm.predict("Tell me 5 fun facts about yourself!") | ||
``` | ||
</Tab> | ||
</Tabs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters