OpenAI
与OpenAI相关的所有功能
OpenAI is American artificial intelligence (AI) research laboratory consisting of the non-profit OpenAI Incorporated and its for-profit subsidiary corporation OpenAI Limited Partnership. OpenAI conducts AI research with the declared intention of promoting and developing a friendly AI. OpenAI systems run on an Azure-based supercomputing platform from Microsoft.
The OpenAI API is powered by a diverse set of models with different capabilities and price points.
ChatGPT is the Artificial Intelligence (AI) chatbot developed by
OpenAI.
安装与设置
使用以下命令安装集成包:
pip install langchain-openai
获取一个 OpenAI API 密钥并将其设置为环境变量 (OPENAI_API_KEY)
聊天模型
查看一个 使用示例。
from langchain_openai import ChatOpenAI
如果您使用的是托管在 Azure 上的模型,您应该使用不同的包装器:
from langchain_openai import AzureChatOpenAI
有关 Azure 包装器的更详细说明,请参见 此处。
LLM
查看一个 使用示例。
from langchain_openai import OpenAI
如果您使用的是托管在 Azure 上的模型,您应该使用不同的包装器:
from langchain_openai import AzureOpenAI
有关 Azure 包装器的更详细说明,请参见 此处。
嵌入模型
查看一个 使用示例
from langchain_openai import OpenAIEmbeddings
文档加载器
查看一个 使用示例。
from langchain_community.document_loaders.chatgpt import ChatGPTLoader
检索器
查看一个 使用示例。
from langchain.retrievers import ChatGPTPluginRetriever
工具
Dall-E 图像生成器
OpenAI Dall-E are text-to-image models developed by
OpenAIusing deep learning methodologies to generate digital images from natural language descriptions, called "prompts".
查看一个 使用示例。
from langchain_community.utilities.dalle_image_generator import DallEAPIWrapper
适集成
查看一个 使用示例。
from langchain.adapters import openai as lc_openai
分词器
您可以使用 tiktoken 分词器的几个位置。默认情况下,它用于计算 OpenAI LLM 的标记数。
你还可以在使用它分割文档时用来计算标记数量。
from langchain.text_splitter import CharacterTextSplitter
CharacterTextSplitter.from_tiktoken_encoder(...)
有关此内容的更详细说明,请参见 这个笔记本
Chains
查看一个 使用示例。
from langchain.chains import OpenAIModerationChain