PromptLayer OpenAI
此模块已被弃用,不再受支持。以下文档不适用于 0.2.0 或更高版本。
¥This module has been deprecated and is no longer supported. The documentation below will not work in versions 0.2.0 or later.
LangChain 与 PromptLayer 集成,用于记录和调试提示和响应。要添加对 PromptLayer 的支持:
¥LangChain integrates with PromptLayer for logging and debugging prompts and responses. To add support for PromptLayer:
在此处创建一个 PromptLayer 账户:[https://promptlayer.com](https://promptlayer.com)。](https://www.promptlayer.com/\)。)
¥Create a PromptLayer account here: https://promptlayer.com.
创建一个 API 令牌,并将其作为
PromptLayerOpenAI
构造函数中的promptLayerApiKey
参数或PROMPTLAYER_API_KEY
环境变量传递。¥Create an API token and pass it either as
promptLayerApiKey
argument in thePromptLayerOpenAI
constructor or in thePROMPTLAYER_API_KEY
environment variable.
import { PromptLayerOpenAI } from "langchain/llms/openai";
const model = new PromptLayerOpenAI({
temperature: 0.9,
apiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.OPENAI_API_KEY
promptLayerApiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.PROMPTLAYER_API_KEY
});
const res = await model.invoke(
"What would be a good company name a company that makes colorful socks?"
);
Azure PromptLayerOpenAI
LangChain 还与 PromptLayer 集成,用于 Azure 托管的 OpenAI 实例:
¥LangChain also integrates with PromptLayer for Azure-hosted OpenAI instances:
import { PromptLayerOpenAI } from "langchain/llms/openai";
const model = new PromptLayerOpenAI({
temperature: 0.9,
azureOpenAIApiKey: "YOUR-AOAI-API-KEY", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiInstanceName: "YOUR-AOAI-INSTANCE-NAME", // In Node.js defaults to process.env.AZURE_OPENAI_API_INSTANCE_NAME
azureOpenAIApiDeploymentName: "YOUR-AOAI-DEPLOYMENT-NAME", // In Node.js defaults to process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME
azureOpenAIApiCompletionsDeploymentName:
"YOUR-AOAI-COMPLETIONS-DEPLOYMENT-NAME", // In Node.js defaults to process.env.AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME
azureOpenAIApiEmbeddingsDeploymentName:
"YOUR-AOAI-EMBEDDINGS-DEPLOYMENT-NAME", // In Node.js defaults to process.env.AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME
azureOpenAIApiVersion: "YOUR-AOAI-API-VERSION", // In Node.js defaults to process.env.AZURE_OPENAI_API_VERSION
azureOpenAIBasePath: "YOUR-AZURE-OPENAI-BASE-PATH", // In Node.js defaults to process.env.AZURE_OPENAI_BASE_PATH
promptLayerApiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.PROMPTLAYER_API_KEY
});
const res = await model.invoke(
"What would be a good company name a company that makes colorful socks?"
);
请求和响应将记录在 PromptLayer 仪表板 中。
¥The request and the response will be logged in the PromptLayer dashboard.
注意:在流式传输模式下,PromptLayer 不会记录响应。
¥Note: In streaming mode PromptLayer will not log the response.
相关
¥Related
大语言模型 概念指南
¥LLM conceptual guide
大语言模型 操作指南
¥LLM how-to guides