Docs refactor (#480)
Big docs refactor! Motivation is to make it easier for people to find
resources they are looking for. To accomplish this, there are now three
main sections:
- Getting Started: steps for getting started, walking through most core
functionality
- Modules: these are different modules of functionality that langchain
provides. Each part here has a "getting started", "how to", "key
concepts" and "reference" section (except in a few select cases where it
didnt easily fit).
- Use Cases: this is to separate use cases (like summarization, question
answering, evaluation, etc) from the modules, and provide a different
entry point to the code base.
There is also a full reference section, as well as extra resources
(glossary, gallery, etc)
Co-authored-by: Shreya Rajpal <ShreyaR@users.noreply.github.com>
2023-01-02 16:24:09 +00:00
|
|
|
# OpenAI
|
|
|
|
|
2023-05-29 14:19:43 +00:00
|
|
|
>[OpenAI](https://en.wikipedia.org/wiki/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](https://platform.openai.com/docs/models) is powered by a diverse set of models with different capabilities and price points.
|
|
|
|
>
|
|
|
|
>[ChatGPT](https://chat.openai.com) is the Artificial Intelligence (AI) chatbot developed by `OpenAI`.
|
Docs refactor (#480)
Big docs refactor! Motivation is to make it easier for people to find
resources they are looking for. To accomplish this, there are now three
main sections:
- Getting Started: steps for getting started, walking through most core
functionality
- Modules: these are different modules of functionality that langchain
provides. Each part here has a "getting started", "how to", "key
concepts" and "reference" section (except in a few select cases where it
didnt easily fit).
- Use Cases: this is to separate use cases (like summarization, question
answering, evaluation, etc) from the modules, and provide a different
entry point to the code base.
There is also a full reference section, as well as extra resources
(glossary, gallery, etc)
Co-authored-by: Shreya Rajpal <ShreyaR@users.noreply.github.com>
2023-01-02 16:24:09 +00:00
|
|
|
|
|
|
|
## Installation and Setup
|
2023-05-29 14:19:43 +00:00
|
|
|
- Install the Python SDK with
|
|
|
|
```bash
|
|
|
|
pip install openai
|
|
|
|
```
|
Docs refactor (#480)
Big docs refactor! Motivation is to make it easier for people to find
resources they are looking for. To accomplish this, there are now three
main sections:
- Getting Started: steps for getting started, walking through most core
functionality
- Modules: these are different modules of functionality that langchain
provides. Each part here has a "getting started", "how to", "key
concepts" and "reference" section (except in a few select cases where it
didnt easily fit).
- Use Cases: this is to separate use cases (like summarization, question
answering, evaluation, etc) from the modules, and provide a different
entry point to the code base.
There is also a full reference section, as well as extra resources
(glossary, gallery, etc)
Co-authored-by: Shreya Rajpal <ShreyaR@users.noreply.github.com>
2023-01-02 16:24:09 +00:00
|
|
|
- Get an OpenAI api key and set it as an environment variable (`OPENAI_API_KEY`)
|
2023-05-29 14:19:43 +00:00
|
|
|
- If you want to use OpenAI's tokenizer (only available for Python 3.9+), install it
|
|
|
|
```bash
|
|
|
|
pip install tiktoken
|
|
|
|
```
|
Docs refactor (#480)
Big docs refactor! Motivation is to make it easier for people to find
resources they are looking for. To accomplish this, there are now three
main sections:
- Getting Started: steps for getting started, walking through most core
functionality
- Modules: these are different modules of functionality that langchain
provides. Each part here has a "getting started", "how to", "key
concepts" and "reference" section (except in a few select cases where it
didnt easily fit).
- Use Cases: this is to separate use cases (like summarization, question
answering, evaluation, etc) from the modules, and provide a different
entry point to the code base.
There is also a full reference section, as well as extra resources
(glossary, gallery, etc)
Co-authored-by: Shreya Rajpal <ShreyaR@users.noreply.github.com>
2023-01-02 16:24:09 +00:00
|
|
|
|
|
|
|
|
2023-05-29 14:19:43 +00:00
|
|
|
## LLM
|
Docs refactor (#480)
Big docs refactor! Motivation is to make it easier for people to find
resources they are looking for. To accomplish this, there are now three
main sections:
- Getting Started: steps for getting started, walking through most core
functionality
- Modules: these are different modules of functionality that langchain
provides. Each part here has a "getting started", "how to", "key
concepts" and "reference" section (except in a few select cases where it
didnt easily fit).
- Use Cases: this is to separate use cases (like summarization, question
answering, evaluation, etc) from the modules, and provide a different
entry point to the code base.
There is also a full reference section, as well as extra resources
(glossary, gallery, etc)
Co-authored-by: Shreya Rajpal <ShreyaR@users.noreply.github.com>
2023-01-02 16:24:09 +00:00
|
|
|
|
|
|
|
```python
|
|
|
|
from langchain.llms import OpenAI
|
|
|
|
```
|
|
|
|
|
2023-05-29 14:19:43 +00:00
|
|
|
If you are using a model hosted on `Azure`, you should use different wrapper for that:
|
Docs refactor (#480)
Big docs refactor! Motivation is to make it easier for people to find
resources they are looking for. To accomplish this, there are now three
main sections:
- Getting Started: steps for getting started, walking through most core
functionality
- Modules: these are different modules of functionality that langchain
provides. Each part here has a "getting started", "how to", "key
concepts" and "reference" section (except in a few select cases where it
didnt easily fit).
- Use Cases: this is to separate use cases (like summarization, question
answering, evaluation, etc) from the modules, and provide a different
entry point to the code base.
There is also a full reference section, as well as extra resources
(glossary, gallery, etc)
Co-authored-by: Shreya Rajpal <ShreyaR@users.noreply.github.com>
2023-01-02 16:24:09 +00:00
|
|
|
```python
|
|
|
|
from langchain.llms import AzureOpenAI
|
|
|
|
```
|
2023-07-25 04:20:32 +00:00
|
|
|
For a more detailed walkthrough of the `Azure` wrapper, see [this notebook](/docs/integrations/llms/azure_openai_example.html)
|
2023-06-16 18:52:56 +00:00
|
|
|
|
Docs refactor (#480)
Big docs refactor! Motivation is to make it easier for people to find
resources they are looking for. To accomplish this, there are now three
main sections:
- Getting Started: steps for getting started, walking through most core
functionality
- Modules: these are different modules of functionality that langchain
provides. Each part here has a "getting started", "how to", "key
concepts" and "reference" section (except in a few select cases where it
didnt easily fit).
- Use Cases: this is to separate use cases (like summarization, question
answering, evaluation, etc) from the modules, and provide a different
entry point to the code base.
There is also a full reference section, as well as extra resources
(glossary, gallery, etc)
Co-authored-by: Shreya Rajpal <ShreyaR@users.noreply.github.com>
2023-01-02 16:24:09 +00:00
|
|
|
|
|
|
|
|
2023-05-29 14:19:43 +00:00
|
|
|
## Text Embedding Model
|
Docs refactor (#480)
Big docs refactor! Motivation is to make it easier for people to find
resources they are looking for. To accomplish this, there are now three
main sections:
- Getting Started: steps for getting started, walking through most core
functionality
- Modules: these are different modules of functionality that langchain
provides. Each part here has a "getting started", "how to", "key
concepts" and "reference" section (except in a few select cases where it
didnt easily fit).
- Use Cases: this is to separate use cases (like summarization, question
answering, evaluation, etc) from the modules, and provide a different
entry point to the code base.
There is also a full reference section, as well as extra resources
(glossary, gallery, etc)
Co-authored-by: Shreya Rajpal <ShreyaR@users.noreply.github.com>
2023-01-02 16:24:09 +00:00
|
|
|
|
|
|
|
```python
|
|
|
|
from langchain.embeddings import OpenAIEmbeddings
|
|
|
|
```
|
2023-07-25 04:20:32 +00:00
|
|
|
For a more detailed walkthrough of this, see [this notebook](/docs/integrations/text_embedding/openai.html)
|
2023-06-05 23:08:55 +00:00
|
|
|
|
|
|
|
|
2023-05-29 14:19:43 +00:00
|
|
|
## Tokenizer
|
Docs refactor (#480)
Big docs refactor! Motivation is to make it easier for people to find
resources they are looking for. To accomplish this, there are now three
main sections:
- Getting Started: steps for getting started, walking through most core
functionality
- Modules: these are different modules of functionality that langchain
provides. Each part here has a "getting started", "how to", "key
concepts" and "reference" section (except in a few select cases where it
didnt easily fit).
- Use Cases: this is to separate use cases (like summarization, question
answering, evaluation, etc) from the modules, and provide a different
entry point to the code base.
There is also a full reference section, as well as extra resources
(glossary, gallery, etc)
Co-authored-by: Shreya Rajpal <ShreyaR@users.noreply.github.com>
2023-01-02 16:24:09 +00:00
|
|
|
|
|
|
|
There are several places you can use the `tiktoken` tokenizer. By default, it is used to count tokens
|
|
|
|
for OpenAI LLMs.
|
|
|
|
|
|
|
|
You can also use it to count tokens when splitting documents with
|
|
|
|
```python
|
|
|
|
from langchain.text_splitter import CharacterTextSplitter
|
|
|
|
CharacterTextSplitter.from_tiktoken_encoder(...)
|
|
|
|
```
|
2023-06-16 18:52:56 +00:00
|
|
|
For a more detailed walkthrough of this, see [this notebook](/docs/modules/data_connection/document_transformers/text_splitters/tiktoken.html)
|
Docs refactor (#480)
Big docs refactor! Motivation is to make it easier for people to find
resources they are looking for. To accomplish this, there are now three
main sections:
- Getting Started: steps for getting started, walking through most core
functionality
- Modules: these are different modules of functionality that langchain
provides. Each part here has a "getting started", "how to", "key
concepts" and "reference" section (except in a few select cases where it
didnt easily fit).
- Use Cases: this is to separate use cases (like summarization, question
answering, evaluation, etc) from the modules, and provide a different
entry point to the code base.
There is also a full reference section, as well as extra resources
(glossary, gallery, etc)
Co-authored-by: Shreya Rajpal <ShreyaR@users.noreply.github.com>
2023-01-02 16:24:09 +00:00
|
|
|
|
2023-05-29 14:19:43 +00:00
|
|
|
## Chain
|
|
|
|
|
2023-07-25 04:20:32 +00:00
|
|
|
See a [usage example](/docs/modules/chains/additional/moderation).
|
Docs refactor (#480)
Big docs refactor! Motivation is to make it easier for people to find
resources they are looking for. To accomplish this, there are now three
main sections:
- Getting Started: steps for getting started, walking through most core
functionality
- Modules: these are different modules of functionality that langchain
provides. Each part here has a "getting started", "how to", "key
concepts" and "reference" section (except in a few select cases where it
didnt easily fit).
- Use Cases: this is to separate use cases (like summarization, question
answering, evaluation, etc) from the modules, and provide a different
entry point to the code base.
There is also a full reference section, as well as extra resources
(glossary, gallery, etc)
Co-authored-by: Shreya Rajpal <ShreyaR@users.noreply.github.com>
2023-01-02 16:24:09 +00:00
|
|
|
|
|
|
|
```python
|
|
|
|
from langchain.chains import OpenAIModerationChain
|
|
|
|
```
|
2023-05-29 14:19:43 +00:00
|
|
|
|
|
|
|
## Document Loader
|
|
|
|
|
2023-07-25 04:20:32 +00:00
|
|
|
See a [usage example](/docs/integrations/document_loaders/chatgpt_loader).
|
2023-05-29 14:19:43 +00:00
|
|
|
|
|
|
|
```python
|
|
|
|
from langchain.document_loaders.chatgpt import ChatGPTLoader
|
|
|
|
```
|
2023-06-03 22:29:03 +00:00
|
|
|
|
|
|
|
## Retriever
|
|
|
|
|
2023-07-25 04:20:32 +00:00
|
|
|
See a [usage example](/docs/integrations/retrievers/chatgpt-plugin).
|
2023-06-03 22:29:03 +00:00
|
|
|
|
|
|
|
```python
|
|
|
|
from langchain.retrievers import ChatGPTPluginRetriever
|
|
|
|
```
|