Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions docs/docs/integrations/chat/oci_generative_ai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
")"
]
},
Expand All @@ -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",
Expand Down Expand Up @@ -146,13 +141,22 @@
"metadata": {},
"outputs": [],
"source": [
"from langchain_core.prompts import ChatPromptTemplate\n",
"\n",
"prompt = ChatPromptTemplate.from_template(\"Tell me a joke about {topic}\")\n",
"chain = prompt | chat\n",
"from langchain_core.prompts import PromptTemplate\n",
"from langchain_oci.chat_models import ChatOCIGenAI\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)"
]
},
{
Expand All @@ -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/"
]
}
],
Expand Down
22 changes: 10 additions & 12 deletions docs/docs/integrations/llms/oci_generative_ai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Usage"
]
"cell_type": "markdown",
"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",
Expand Down
8 changes: 3 additions & 5 deletions docs/docs/integrations/providers/oci.mdx
Original file line number Diff line number Diff line change
@@ -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/).

Expand All @@ -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
```

Expand Down
12 changes: 5 additions & 7 deletions docs/docs/integrations/text_embedding/oci_generative_ai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions docs/src/theme/ChatModelTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions docs/src/theme/EmbeddingTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function EmbeddingTabs(props) {
fakeEmbeddingParams,
hideFakeEmbedding,
customVarName,
hideOCIGenAIEmbeddings
} = props;

const openAIParamsOrDefault = openaiParams ?? `model="text-embedding-3-large"`;
Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions docs/src/theme/FeatureTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
],
},
Expand Down Expand Up @@ -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: {
Expand Down
4 changes: 4 additions & 0 deletions libs/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .