Skip to content

Commit f11dd17

Browse files
karwandevishalVishal Karwandemdrxy
authored
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 <[email protected]> Co-authored-by: Mason Daugherty <[email protected]>
1 parent d5a4abf commit f11dd17

File tree

9 files changed

+85
-48
lines changed

9 files changed

+85
-48
lines changed

docs/docs/integrations/chat/oci_generative_ai.ipynb

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"source": [
1818
"# ChatOCIGenAI\n",
1919
"\n",
20-
"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",
20+
"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",
2121
"\n",
2222
"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",
2323
"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 @@
2626
"## Overview\n",
2727
"### Integration details\n",
2828
"\n",
29-
"| Class | Package | Local | Serializable | [JS support](https://js.langchain.com/docs/integrations/chat/oci_generative_ai) |\n",
30-
"| :--- | :--- | :---: | :---: | :---: |\n",
31-
"| [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",
29+
"| Class | Package | Local | Serializable | [JS support](https://js.langchain.com/docs/integrations/chat/oci_generative_ai) |\n",
30+
"| :--- |:---------------------------------------------------------------------------------| :---: | :---: | :---: |\n",
31+
"| [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",
3232
"\n",
3333
"### Model features\n",
3434
"| [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 @@
3737
"\n",
3838
"## Setup\n",
3939
"\n",
40-
"To access OCIGenAI models you'll need to install the `oci` and `langchain-community` packages.\n",
40+
"To access OCIGenAI models you'll need to install the `oci` and `langchain-oci` packages.\n",
4141
"\n",
4242
"### Credentials\n",
4343
"\n",
@@ -84,13 +84,15 @@
8484
"outputs": [],
8585
"source": [
8686
"from langchain_oci.chat_models import ChatOCIGenAI\n",
87-
"from langchain_core.messages import AIMessage, HumanMessage, SystemMessage\n",
8887
"\n",
8988
"chat = ChatOCIGenAI(\n",
90-
" model_id=\"cohere.command-r-16k\",\n",
89+
" model_id=\"cohere.command-r-plus-08-2024\",\n",
9190
" service_endpoint=\"https://inference.generativeai.us-chicago-1.oci.oraclecloud.com\",\n",
92-
" compartment_id=\"MY_OCID\",\n",
93-
" model_kwargs={\"temperature\": 0.7, \"max_tokens\": 500},\n",
91+
" compartment_id=\"compartment_id\",\n",
92+
" model_kwargs={\"temperature\": 0, \"max_tokens\": 500},\n",
93+
" auth_type=\"SECURITY_TOKEN\",\n",
94+
" auth_profile=\"auth_profile_name\",\n",
95+
" auth_file_location=\"auth_file_location\",\n",
9496
")"
9597
]
9698
},
@@ -110,14 +112,7 @@
110112
"tags": []
111113
},
112114
"outputs": [],
113-
"source": [
114-
"messages = [\n",
115-
" SystemMessage(content=\"your are an AI assistant.\"),\n",
116-
" AIMessage(content=\"Hi there human!\"),\n",
117-
" HumanMessage(content=\"tell me a joke.\"),\n",
118-
"]\n",
119-
"response = chat.invoke(messages)"
120-
]
115+
"source": "response = chat.invoke(\"Tell me one fact about Earth\")"
121116
},
122117
{
123118
"cell_type": "code",
@@ -146,13 +141,22 @@
146141
"metadata": {},
147142
"outputs": [],
148143
"source": [
149-
"from langchain_core.prompts import ChatPromptTemplate\n",
150-
"\n",
151-
"prompt = ChatPromptTemplate.from_template(\"Tell me a joke about {topic}\")\n",
152-
"chain = prompt | chat\n",
144+
"from langchain_core.prompts import PromptTemplate\n",
145+
"from langchain_oci.chat_models import ChatOCIGenAI\n",
153146
"\n",
154-
"response = chain.invoke({\"topic\": \"dogs\"})\n",
155-
"print(response.content)"
147+
"llm = ChatOCIGenAI(\n",
148+
" model_id=\"cohere.command-r-plus-08-2024\",\n",
149+
" service_endpoint=\"https://inference.generativeai.us-chicago-1.oci.oraclecloud.com\",\n",
150+
" compartment_id=\"compartment_id\",\n",
151+
" model_kwargs={\"temperature\": 0, \"max_tokens\": 500},\n",
152+
" auth_type=\"SECURITY_TOKEN\",\n",
153+
" auth_profile=\"auth_profile_name\",\n",
154+
" auth_file_location=\"auth_file_location\",\n",
155+
")\n",
156+
"prompt = PromptTemplate(input_variables=[\"query\"], template=\"{query}\")\n",
157+
"llm_chain = prompt | llm\n",
158+
"response = llm_chain.invoke(\"what is the capital of france?\")\n",
159+
"print(response)"
156160
]
157161
},
158162
{
@@ -162,7 +166,7 @@
162166
"source": [
163167
"## API reference\n",
164168
"\n",
165-
"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"
169+
"For detailed documentation of all ChatOCIGenAI features and configurations head to the API reference: https://pypi.org/project/langchain-oci/"
166170
]
167171
}
168172
],

docs/docs/integrations/llms/oci_generative_ai.ipynb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,28 @@
2222
"metadata": {},
2323
"source": [
2424
"## Setup\n",
25-
"Ensure that the oci sdk and the langchain-community package are installed"
25+
"Ensure that the oci sdk and the langchain-community package are installed\n",
26+
"\n",
27+
":::caution You are currently on a page documenting the use of Oracle's text generation models. Which are deprecated."
2628
]
2729
},
2830
{
29-
"cell_type": "code",
30-
"execution_count": null,
3131
"metadata": {},
32+
"cell_type": "code",
3233
"outputs": [],
33-
"source": [
34-
"!pip install -U langchain-oci"
35-
]
34+
"execution_count": null,
35+
"source": "!pip install -U langchain-oci"
3636
},
3737
{
38-
"cell_type": "markdown",
3938
"metadata": {},
40-
"source": [
41-
"## Usage"
42-
]
39+
"cell_type": "markdown",
40+
"source": "## Usage"
4341
},
4442
{
45-
"cell_type": "code",
46-
"execution_count": null,
4743
"metadata": {},
44+
"cell_type": "code",
4845
"outputs": [],
46+
"execution_count": null,
4947
"source": [
5048
"from langchain_oci.llms import OCIGenAI\n",
5149
"\n",
File renamed without changes.

docs/docs/integrations/providers/oci.mdx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Oracle Cloud Infrastructure (OCI)
1+
# Oracle Cloud Infrastructure (OCI)
22

33
The `LangChain` integrations related to [Oracle Cloud Infrastructure](https://www.oracle.com/artificial-intelligence/).
44

@@ -11,16 +11,14 @@ The `LangChain` integrations related to [Oracle Cloud Infrastructure](https://ww
1111
To use, you should have the latest `oci` python SDK and the langchain_community package installed.
1212

1313
```bash
14-
pip install -U langchain_oci
14+
python -m pip install -U langchain-oci
1515
```
1616

17-
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.
17+
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.
1818

1919
```python
2020
from langchain_oci.chat_models import ChatOCIGenAI
2121

22-
from langchain_oci.llms import OCIGenAI
23-
2422
from langchain_oci.embeddings import OCIGenAIEmbeddings
2523
```
2624

docs/docs/integrations/text_embedding/oci_generative_ai.ipynb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@
2626
]
2727
},
2828
{
29-
"cell_type": "code",
30-
"execution_count": null,
3129
"metadata": {},
30+
"cell_type": "code",
3231
"outputs": [],
33-
"source": [
34-
"!pip install -U langchain_oci"
35-
]
32+
"execution_count": null,
33+
"source": "!pip install -U langchain-oci"
3634
},
3735
{
3836
"cell_type": "markdown",
@@ -75,9 +73,9 @@
7573
"\n",
7674
"# use default authN method API-key\n",
7775
"embeddings = OCIGenAIEmbeddings(\n",
78-
" model_id=\"MY_EMBEDDING_MODEL\",\n",
76+
" model_id=\"cohere.embed-v4.0\",\n",
7977
" service_endpoint=\"https://inference.generativeai.us-chicago-1.oci.oraclecloud.com\",\n",
80-
" compartment_id=\"MY_OCID\",\n",
78+
" compartment_id=\"compartment_id\",\n",
8179
")\n",
8280
"\n",
8381
"\n",

docs/src/theme/ChatModelTabs.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@ ${llmVarName} = ChatWatsonx(
239239
model: "deepseek-chat",
240240
apiKeyName: "DEEPSEEK_API_KEY",
241241
packageName: "langchain-deepseek",
242+
},
243+
{
244+
value: "chatocigenai",
245+
label: "ChatOCIGenAI",
246+
model: "cohere.command-r-plus-08-2024",
247+
apiKeyName: "OCI_API_KEY",
248+
packageName: "langchain-oci",
242249
}
243250
].map((item) => ({
244251
...item,

docs/src/theme/EmbeddingTabs.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default function EmbeddingTabs(props) {
3434
fakeEmbeddingParams,
3535
hideFakeEmbedding,
3636
customVarName,
37+
hideOCIGenAIEmbeddings
3738
} = props;
3839

3940
const openAIParamsOrDefault = openaiParams ?? `model="text-embedding-3-large"`;
@@ -183,6 +184,15 @@ export default function EmbeddingTabs(props) {
183184
default: false,
184185
shouldHide: hideFakeEmbedding,
185186
},
187+
{
188+
value: "OCIGenAIEmbeddings",
189+
label: "OCIGenAIEmbeddings",
190+
text: `from langchain_oci.embeddings import OCIGenAIEmbeddings`,
191+
apiKeyName: "OCI_API_KEY",
192+
packageName: "langchain-oci",
193+
default: false,
194+
shouldHide: hideOCIGenAIEmbeddings,
195+
},
186196
];
187197

188198
const modelOptions = tabItems

docs/src/theme/FeatureTables.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,17 @@ const FEATURE_TABLES = {
247247
"multimodal": true,
248248
"local": false,
249249
"apiLink": "https://python.langchain.com/api_reference/perplexity/chat_models/langchain_perplexity.chat_models.ChatPerplexity.html"
250+
},
251+
{
252+
"name": "ChatOCIGenAI",
253+
"package": "langchain-oci",
254+
"link": "oci_generative_ai",
255+
"structured_output": true,
256+
"tool_calling": true,
257+
"json_mode": true,
258+
"multimodal": true,
259+
"local": false,
260+
"apiLink": "https://github.com/oracle/langchain-oracle"
250261
}
251262
],
252263
},
@@ -418,6 +429,13 @@ const FEATURE_TABLES = {
418429
package: "langchain-nvidia",
419430
apiLink: "https://python.langchain.com/api_reference/nvidia_ai_endpoints/embeddings/langchain_nvidia_ai_endpoints.embeddings.NVIDIAEmbeddings.html"
420431
},
432+
{
433+
name: "OCIGenAIEmbeddings",
434+
link: "oci_generative_ai",
435+
package: "langchain-oci",
436+
apiLink: "https://github.com/oracle/langchain-oracle"
437+
438+
}
421439
]
422440
},
423441
document_retrievers: {

libs/packages.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,4 +729,8 @@ packages:
729729
- name: langchain-scrapeless
730730
repo: scrapeless-ai/langchain-scrapeless
731731
path: .
732+
- name: langchain-oci
733+
name_title: Oracle Cloud Infrastructure (OCI)
734+
repo: oracle/langchain-oracle
735+
path: .
732736

0 commit comments

Comments
 (0)