|
|
@ -24,6 +24,8 @@ pip install tiktoken
|
|
|
|
|
|
|
|
|
|
|
|
## LLM
|
|
|
|
## LLM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See a [usage example](/docs/integrations/llms/openai).
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
```python
|
|
|
|
from langchain.llms import OpenAI
|
|
|
|
from langchain.llms import OpenAI
|
|
|
|
```
|
|
|
|
```
|
|
|
@ -32,16 +34,31 @@ If you are using a model hosted on `Azure`, you should use different wrapper for
|
|
|
|
```python
|
|
|
|
```python
|
|
|
|
from langchain.llms import AzureOpenAI
|
|
|
|
from langchain.llms import AzureOpenAI
|
|
|
|
```
|
|
|
|
```
|
|
|
|
For a more detailed walkthrough of the `Azure` wrapper, see [this notebook](/docs/integrations/llms/azure_openai_example.html)
|
|
|
|
For a more detailed walkthrough of the `Azure` wrapper, see [here](/docs/integrations/llms/azure_openai_example)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Chat model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See a [usage example](/docs/integrations/chat_models/openai).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
|
|
|
from langchain.chat_models import ChatOpenAI
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If you are using a model hosted on `Azure`, you should use different wrapper for that:
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
|
|
|
from langchain.llms import AzureChatOpenAI
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
For a more detailed walkthrough of the `Azure` wrapper, see [here](/docs/integrations/chat_models/azure_openai)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Text Embedding Model
|
|
|
|
## Text Embedding Model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See a [usage example](/docs/integrations/text_embedding/openai)
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
```python
|
|
|
|
from langchain.embeddings import OpenAIEmbeddings
|
|
|
|
from langchain.embeddings import OpenAIEmbeddings
|
|
|
|
```
|
|
|
|
```
|
|
|
|
For a more detailed walkthrough of this, see [this notebook](/docs/integrations/text_embedding/openai.html)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Tokenizer
|
|
|
|
## Tokenizer
|
|
|
@ -54,15 +71,7 @@ You can also use it to count tokens when splitting documents with
|
|
|
|
from langchain.text_splitter import CharacterTextSplitter
|
|
|
|
from langchain.text_splitter import CharacterTextSplitter
|
|
|
|
CharacterTextSplitter.from_tiktoken_encoder(...)
|
|
|
|
CharacterTextSplitter.from_tiktoken_encoder(...)
|
|
|
|
```
|
|
|
|
```
|
|
|
|
For a more detailed walkthrough of this, see [this notebook](/docs/modules/data_connection/document_transformers/text_splitters/tiktoken.html)
|
|
|
|
For a more detailed walkthrough of this, see [this notebook](/docs/modules/data_connection/document_transformers/text_splitters/tiktoken)
|
|
|
|
|
|
|
|
|
|
|
|
## Chain
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See a [usage example](/docs/guides/safety/moderation).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
|
|
|
from langchain.chains import OpenAIModerationChain
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Document Loader
|
|
|
|
## Document Loader
|
|
|
|
|
|
|
|
|
|
|
@ -79,3 +88,12 @@ See a [usage example](/docs/integrations/retrievers/chatgpt-plugin).
|
|
|
|
```python
|
|
|
|
```python
|
|
|
|
from langchain.retrievers import ChatGPTPluginRetriever
|
|
|
|
from langchain.retrievers import ChatGPTPluginRetriever
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Chain
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See a [usage example](/docs/guides/safety/moderation).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
|
|
|
from langchain.chains import OpenAIModerationChain
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|