Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
OurBuilding Ambient Agents with LangGraph course is now available on LangChain Academy!
Open on GitHub

OpenAI

All functionality related to OpenAI

OpenAI is American artificial intelligence (AI) research laboratoryconsisting of the non-profitOpenAI Incorporatedand its for-profit subsidiary corporationOpenAI Limited Partnership.OpenAI conducts AI research with the declared intention of promoting and developing a friendly AI.OpenAI systems run on anAzure-based supercomputing platform fromMicrosoft.

TheOpenAI API is powered by a diverse set of models with different capabilities and price points.

ChatGPT is the Artificial Intelligence (AI) chatbot developed byOpenAI.

Installation and Setup

Install the integration package with

pip install langchain-openai

Get an OpenAI api key and set it as an environment variable (OPENAI_API_KEY)

Chat model

See ausage example.

from langchain_openaiimport ChatOpenAI
API Reference:ChatOpenAI

If you are using a model hosted onAzure, you should use different wrapper for that:

from langchain_openaiimport AzureChatOpenAI
API Reference:AzureChatOpenAI

For a more detailed walkthrough of theAzure wrapper, seehere.

LLM

See ausage example.

from langchain_openaiimport OpenAI
API Reference:OpenAI

If you are using a model hosted onAzure, you should use different wrapper for that:

from langchain_openaiimport AzureOpenAI
API Reference:AzureOpenAI

For a more detailed walkthrough of theAzure wrapper, seehere.

Embedding Model

See ausage example

from langchain_openaiimport OpenAIEmbeddings
API Reference:OpenAIEmbeddings

Document Loader

See ausage example.

from langchain_community.document_loaders.chatgptimport ChatGPTLoader
API Reference:ChatGPTLoader

Retriever

See ausage example.

from langchain.retrieversimport ChatGPTPluginRetriever

Tools

Dall-E Image Generator

OpenAI Dall-E are text-to-image models developed byOpenAIusing deep learning methodologies to generate digital images from natural language descriptions,called "prompts".

See ausage example.

from langchain_community.utilities.dalle_image_generatorimport DallEAPIWrapper
API Reference:DallEAPIWrapper

Adapter

See ausage example.

from langchain.adaptersimport openaias lc_openai
API Reference:openai

Tokenizer

There are several places you can use thetiktoken tokenizer. By default, it is used to count tokensfor OpenAI LLMs.

You can also use it to count tokens when splitting documents with

from langchain.text_splitterimport CharacterTextSplitter
CharacterTextSplitter.from_tiktoken_encoder(...)
API Reference:CharacterTextSplitter

For a more detailed walkthrough of this, seethis notebook

Chain

See ausage example.

from langchain.chainsimport OpenAIModerationChain
API Reference:OpenAIModerationChain

[8]ページ先頭

©2009-2025 Movatter.jp