mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-20 18:12:35 +00:00
docs: update oci documentation and examples. (#32749)
Adding Oracle Generative AI as one of the providers for langchain. Updated the old examples in the documentation with the new working examples. --------- Co-authored-by: Vishal Karwande <vishalkarwande@Vishals-MacBook-Pro.local> Co-authored-by: Mason Daugherty <mason@langchain.dev>
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
"source": [
|
||||
"# ChatOCIGenAI\n",
|
||||
"\n",
|
||||
"This notebook provides a quick overview for getting started with OCIGenAI [chat models](/docs/concepts/chat_models). For detailed documentation of all ChatOCIGenAI features and configurations head to the [API reference](https://python.langchain.com/api_reference/community/chat_models/langchain_community.chat_models.oci_generative_ai.ChatOCIGenAI.html).\n",
|
||||
"This notebook provides a quick overview for getting started with OCIGenAI [chat models](/docs/concepts/chat_models). For detailed documentation of all ChatOCIGenAI features and configurations head to the [API reference](https://pypi.org/project/langchain-oci/).\n",
|
||||
"\n",
|
||||
"Oracle Cloud Infrastructure (OCI) Generative AI is a fully managed service that provides a set of state-of-the-art, customizable large language models (LLMs) that cover a wide range of use cases, and which is available through a single API.\n",
|
||||
"Using the OCI Generative AI service you can access ready-to-use pretrained models, or create and host your own fine-tuned custom models based on your own data on dedicated AI clusters. Detailed documentation of the service and API is available __[here](https://docs.oracle.com/en-us/iaas/Content/generative-ai/home.htm)__ and __[here](https://docs.oracle.com/en-us/iaas/api/#/en/generative-ai/20231130/)__.\n",
|
||||
@@ -26,9 +26,9 @@
|
||||
"## Overview\n",
|
||||
"### Integration details\n",
|
||||
"\n",
|
||||
"| Class | Package | Local | Serializable | [JS support](https://js.langchain.com/docs/integrations/chat/oci_generative_ai) |\n",
|
||||
"| :--- | :--- | :---: | :---: | :---: |\n",
|
||||
"| [ChatOCIGenAI](https://python.langchain.com/api_reference/community/chat_models/langchain_community.chat_models.oci_generative_ai.ChatOCIGenAI.html) | [langchain-community](https://python.langchain.com/api_reference/community/index.html) | ❌ | ❌ | ❌ |\n",
|
||||
"| Class | Package | Local | Serializable | [JS support](https://js.langchain.com/docs/integrations/chat/oci_generative_ai) |\n",
|
||||
"| :--- |:---------------------------------------------------------------------------------| :---: | :---: | :---: |\n",
|
||||
"| [ChatOCIGenAI](https://python.langchain.com/api_reference/community/chat_models/langchain_community.chat_models.oci_generative_ai.ChatOCIGenAI.html) | [langchain-oci](https://github.com/oracle/langchain-oracle) | ❌ | ❌ | ❌ |\n",
|
||||
"\n",
|
||||
"### Model features\n",
|
||||
"| [Tool calling](/docs/how_to/tool_calling/) | [Structured output](/docs/how_to/structured_output/) | [JSON mode](/docs/how_to/structured_output/#advanced-specifying-the-method-for-structuring-outputs) | [Image input](/docs/how_to/multimodal_inputs/) | Audio input | Video input | [Token-level streaming](/docs/how_to/chat_streaming/) | Native async | [Token usage](/docs/how_to/chat_token_usage_tracking/) | [Logprobs](/docs/how_to/logprobs/) |\n",
|
||||
@@ -37,7 +37,7 @@
|
||||
"\n",
|
||||
"## Setup\n",
|
||||
"\n",
|
||||
"To access OCIGenAI models you'll need to install the `oci` and `langchain-community` packages.\n",
|
||||
"To access OCIGenAI models you'll need to install the `oci` and `langchain-oci` packages.\n",
|
||||
"\n",
|
||||
"### Credentials\n",
|
||||
"\n",
|
||||
@@ -84,13 +84,15 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain_oci.chat_models import ChatOCIGenAI\n",
|
||||
"from langchain_core.messages import AIMessage, HumanMessage, SystemMessage\n",
|
||||
"\n",
|
||||
"chat = ChatOCIGenAI(\n",
|
||||
" model_id=\"cohere.command-r-16k\",\n",
|
||||
" model_id=\"cohere.command-r-plus-08-2024\",\n",
|
||||
" service_endpoint=\"https://inference.generativeai.us-chicago-1.oci.oraclecloud.com\",\n",
|
||||
" compartment_id=\"MY_OCID\",\n",
|
||||
" model_kwargs={\"temperature\": 0.7, \"max_tokens\": 500},\n",
|
||||
" compartment_id=\"compartment_id\",\n",
|
||||
" model_kwargs={\"temperature\": 0, \"max_tokens\": 500},\n",
|
||||
" auth_type=\"SECURITY_TOKEN\",\n",
|
||||
" auth_profile=\"auth_profile_name\",\n",
|
||||
" auth_file_location=\"auth_file_location\",\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
@@ -110,14 +112,7 @@
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"messages = [\n",
|
||||
" SystemMessage(content=\"your are an AI assistant.\"),\n",
|
||||
" AIMessage(content=\"Hi there human!\"),\n",
|
||||
" HumanMessage(content=\"tell me a joke.\"),\n",
|
||||
"]\n",
|
||||
"response = chat.invoke(messages)"
|
||||
]
|
||||
"source": "response = chat.invoke(\"Tell me one fact about Earth\")"
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
@@ -146,13 +141,22 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain_core.prompts import ChatPromptTemplate\n",
|
||||
"from langchain_core.prompts import PromptTemplate\n",
|
||||
"from langchain_oci.chat_models import ChatOCIGenAI\n",
|
||||
"\n",
|
||||
"prompt = ChatPromptTemplate.from_template(\"Tell me a joke about {topic}\")\n",
|
||||
"chain = prompt | chat\n",
|
||||
"\n",
|
||||
"response = chain.invoke({\"topic\": \"dogs\"})\n",
|
||||
"print(response.content)"
|
||||
"llm = ChatOCIGenAI(\n",
|
||||
" model_id=\"cohere.command-r-plus-08-2024\",\n",
|
||||
" service_endpoint=\"https://inference.generativeai.us-chicago-1.oci.oraclecloud.com\",\n",
|
||||
" compartment_id=\"compartment_id\",\n",
|
||||
" model_kwargs={\"temperature\": 0, \"max_tokens\": 500},\n",
|
||||
" auth_type=\"SECURITY_TOKEN\",\n",
|
||||
" auth_profile=\"auth_profile_name\",\n",
|
||||
" auth_file_location=\"auth_file_location\",\n",
|
||||
")\n",
|
||||
"prompt = PromptTemplate(input_variables=[\"query\"], template=\"{query}\")\n",
|
||||
"llm_chain = prompt | llm\n",
|
||||
"response = llm_chain.invoke(\"what is the capital of france?\")\n",
|
||||
"print(response)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -162,7 +166,7 @@
|
||||
"source": [
|
||||
"## API reference\n",
|
||||
"\n",
|
||||
"For detailed documentation of all ChatOCIGenAI features and configurations head to the API reference: https://python.langchain.com/api_reference/community/chat_models/langchain_community.chat_models.oci_generative_ai.ChatOCIGenAI.html"
|
||||
"For detailed documentation of all ChatOCIGenAI features and configurations head to the API reference: https://pypi.org/project/langchain-oci/"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@@ -22,30 +22,28 @@
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Setup\n",
|
||||
"Ensure that the oci sdk and the langchain-community package are installed"
|
||||
"Ensure that the oci sdk and the langchain-community package are installed\n",
|
||||
"\n",
|
||||
":::caution You are currently on a page documenting the use of Oracle's text generation models. Which are deprecated."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install -U langchain-oci"
|
||||
]
|
||||
"execution_count": null,
|
||||
"source": "!pip install -U langchain-oci"
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Usage"
|
||||
]
|
||||
"source": "## Usage"
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": [
|
||||
"from langchain_oci.llms import OCIGenAI\n",
|
||||
"\n",
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Oracle Cloud Infrastructure (OCI)
|
||||
# Oracle Cloud Infrastructure (OCI)
|
||||
|
||||
The `LangChain` integrations related to [Oracle Cloud Infrastructure](https://www.oracle.com/artificial-intelligence/).
|
||||
|
||||
@@ -11,16 +11,14 @@ The `LangChain` integrations related to [Oracle Cloud Infrastructure](https://ww
|
||||
To use, you should have the latest `oci` python SDK and the langchain_community package installed.
|
||||
|
||||
```bash
|
||||
pip install -U langchain_oci
|
||||
python -m pip install -U langchain-oci
|
||||
```
|
||||
|
||||
See [chat](/docs/integrations/llms/oci_generative_ai), [complete](/docs/integrations/chat/oci_generative_ai), and [embedding](/docs/integrations/text_embedding/oci_generative_ai) usage examples.
|
||||
See [chat](/docs/integrations/chat/oci_generative_ai), [complete](/docs/integrations/chat/oci_generative_ai), and [embedding](/docs/integrations/text_embedding/oci_generative_ai) usage examples.
|
||||
|
||||
```python
|
||||
from langchain_oci.chat_models import ChatOCIGenAI
|
||||
|
||||
from langchain_oci.llms import OCIGenAI
|
||||
|
||||
from langchain_oci.embeddings import OCIGenAIEmbeddings
|
||||
```
|
||||
|
||||
|
@@ -26,13 +26,11 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install -U langchain_oci"
|
||||
]
|
||||
"execution_count": null,
|
||||
"source": "!pip install -U langchain-oci"
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
@@ -75,9 +73,9 @@
|
||||
"\n",
|
||||
"# use default authN method API-key\n",
|
||||
"embeddings = OCIGenAIEmbeddings(\n",
|
||||
" model_id=\"MY_EMBEDDING_MODEL\",\n",
|
||||
" model_id=\"cohere.embed-v4.0\",\n",
|
||||
" service_endpoint=\"https://inference.generativeai.us-chicago-1.oci.oraclecloud.com\",\n",
|
||||
" compartment_id=\"MY_OCID\",\n",
|
||||
" compartment_id=\"compartment_id\",\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
|
@@ -239,6 +239,13 @@ ${llmVarName} = ChatWatsonx(
|
||||
model: "deepseek-chat",
|
||||
apiKeyName: "DEEPSEEK_API_KEY",
|
||||
packageName: "langchain-deepseek",
|
||||
},
|
||||
{
|
||||
value: "chatocigenai",
|
||||
label: "ChatOCIGenAI",
|
||||
model: "cohere.command-r-plus-08-2024",
|
||||
apiKeyName: "OCI_API_KEY",
|
||||
packageName: "langchain-oci",
|
||||
}
|
||||
].map((item) => ({
|
||||
...item,
|
||||
|
@@ -34,6 +34,7 @@ export default function EmbeddingTabs(props) {
|
||||
fakeEmbeddingParams,
|
||||
hideFakeEmbedding,
|
||||
customVarName,
|
||||
hideOCIGenAIEmbeddings
|
||||
} = props;
|
||||
|
||||
const openAIParamsOrDefault = openaiParams ?? `model="text-embedding-3-large"`;
|
||||
@@ -183,6 +184,15 @@ export default function EmbeddingTabs(props) {
|
||||
default: false,
|
||||
shouldHide: hideFakeEmbedding,
|
||||
},
|
||||
{
|
||||
value: "OCIGenAIEmbeddings",
|
||||
label: "OCIGenAIEmbeddings",
|
||||
text: `from langchain_oci.embeddings import OCIGenAIEmbeddings`,
|
||||
apiKeyName: "OCI_API_KEY",
|
||||
packageName: "langchain-oci",
|
||||
default: false,
|
||||
shouldHide: hideOCIGenAIEmbeddings,
|
||||
},
|
||||
];
|
||||
|
||||
const modelOptions = tabItems
|
||||
|
@@ -247,6 +247,17 @@ const FEATURE_TABLES = {
|
||||
"multimodal": true,
|
||||
"local": false,
|
||||
"apiLink": "https://python.langchain.com/api_reference/perplexity/chat_models/langchain_perplexity.chat_models.ChatPerplexity.html"
|
||||
},
|
||||
{
|
||||
"name": "ChatOCIGenAI",
|
||||
"package": "langchain-oci",
|
||||
"link": "oci_generative_ai",
|
||||
"structured_output": true,
|
||||
"tool_calling": true,
|
||||
"json_mode": true,
|
||||
"multimodal": true,
|
||||
"local": false,
|
||||
"apiLink": "https://github.com/oracle/langchain-oracle"
|
||||
}
|
||||
],
|
||||
},
|
||||
@@ -418,6 +429,13 @@ const FEATURE_TABLES = {
|
||||
package: "langchain-nvidia",
|
||||
apiLink: "https://python.langchain.com/api_reference/nvidia_ai_endpoints/embeddings/langchain_nvidia_ai_endpoints.embeddings.NVIDIAEmbeddings.html"
|
||||
},
|
||||
{
|
||||
name: "OCIGenAIEmbeddings",
|
||||
link: "oci_generative_ai",
|
||||
package: "langchain-oci",
|
||||
apiLink: "https://github.com/oracle/langchain-oracle"
|
||||
|
||||
}
|
||||
]
|
||||
},
|
||||
document_retrievers: {
|
||||
|
@@ -729,4 +729,8 @@ packages:
|
||||
- name: langchain-scrapeless
|
||||
repo: scrapeless-ai/langchain-scrapeless
|
||||
path: .
|
||||
- name: langchain-oci
|
||||
name_title: Oracle Cloud Infrastructure (OCI)
|
||||
repo: oracle/langchain-oracle
|
||||
path: .
|
||||
|
||||
|
Reference in New Issue
Block a user