Skip to content

Latest commit

 

History

225 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

LangChain 🤝 Oracle

Build agents and AI applications with LangChain, LangGraph, and Oracle AI.

Python versions PyPI downloads License: UPL-1.0 GitHub stars

Packages · Quick start · Samples · Documentation · LangChain docs


This is the official repository for the LangChain integrations with Oracle Cloud Infrastructure (OCI) and Oracle Database. It provides native LangChain and LangGraph components — in Python and JavaScript/TypeScript — for OCI Generative AI, OCI Data Science, and Oracle AI Vector Search.

📦 Packages

Package Version Install What it provides
langchain-oci PyPI pip install -U langchain-oci OCI Generative AI & Data Science. Chat models (ChatOCIGenAI, ChatOCIOpenAI, ChatOCIModelDeployment), embeddings (OCIGenAIEmbeddings), agents (create_oci_agent, create_deepagents_agent), guardrails (OCIGuardrails), and multimodal (vision, PDF, video, audio) support across Cohere, Google, Meta, OpenAI, and xAI models on OCI.
langchain-oracledb PyPI pip install -U langchain-oracledb Oracle AI Vector Search. Vector store (OracleVS), hybrid & text-search retrievers, document loaders (OracleDocLoader), text splitter, in-database embeddings and summaries, semantic cache, and chat message history — all powered by Oracle Database.
langgraph-oracledb PyPI pip install -U langgraph-oracledb LangGraph persistence on Oracle Database. Checkpointers (OracleSaver, AsyncOracleSaver) for durable graph state and a key/value store (OracleStore, AsyncOracleStore) with optional vector search for long-term agent memory.
@oracle/langchain-oracledb npm npm install @oracle/langchain-oracledb LangChain.js for Oracle Database. TypeScript/JavaScript counterparts of the Vector Search components: OracleVS, OracleDocLoader, OracleEmbeddings, OracleSummary, and OracleTextSplitter.

Note

This project merges and replaces the earlier OCI and Oracle AI Vector Search integrations from langchain-community. All packages assume you have credentials configured for the OCI and/or Oracle Database services you use.

🚀 Quick start

Chat with OCI Generative AI

from langchain_oci import ChatOCIGenAI

llm = ChatOCIGenAI(
    model_id="meta.llama-3.3-70b-instruct",
    service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com",
    compartment_id="ocid1.compartment.oc1..xxxxx",
)

print(llm.invoke("Sing a ballad of LangChain.").content)

ChatOCIGenAI supports streaming, tool calling, structured output, and multimodal inputs. See the langchain-oci README for on-demand vs. dedicated AI cluster models, authentication options, and OCI Data Science model deployments.

Vector search with Oracle Database

import oracledb
from langchain_oci import OCIGenAIEmbeddings
from langchain_oracledb.vectorstores import OracleVS, DistanceStrategy

conn = oracledb.connect(user="user", password="password", dsn="dsn")

embeddings = OCIGenAIEmbeddings(
    model_id="cohere.embed-v4.0",
    service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com",
    compartment_id="ocid1.compartment.oc1..xxxxx",
)

vector_store = OracleVS(conn, embeddings, "my_docs", DistanceStrategy.COSINE)
vector_store.add_texts(["Oracle AI Vector Search is built into Oracle Database."])

results = vector_store.similarity_search("What is AI Vector Search?", k=1)

Durable agents with LangGraph

from langgraph_oracledb.checkpoint.oracle import OracleSaver

with OracleSaver.from_conn_string("user/password@localhost:1521/FREEPDB1") as checkpointer:
    checkpointer.setup()  # create tables & apply migrations once
    graph = builder.compile(checkpointer=checkpointer)
    graph.invoke({"messages": [...]}, config={"configurable": {"thread_id": "1"}})

🎓 Samples

The samples/ directory is a numbered, hands-on learning path — start at 01 and work up, or jump straight to the topic you need. Every track has its own README and runnable code; these same samples are featured on the official LangChain OCI integration page.

Sample Level Topics
01: Getting Started Beginner Authentication, basic chat, providers
02: Vision & Multimodal Beginner Image analysis, PDF, video, audio
03: Building AI Agents Intermediate ReAct agents, tools, memory
04: Tool Calling Mastery Intermediate Parallel tools, workflows
05: Structured Output Intermediate Pydantic schemas, JSON modes
07: Async for Production Advanced ainvoke, astream, FastAPI
09: Provider Deep Dive Specialized Meta, Gemini, Cohere, xAI specifics
10: Embeddings Specialized Text & image embeddings, RAG
11: Deepagents Specialized Deep agents with Autonomous Database & OpenSearch datastores

📖 Documentation

Official LangChain integration pages

In this repository

  • libs/oci/README.md — full langchain-oci guide: on-demand and dedicated AI cluster models, multimodal content, structured output, tool calling, deepagents with datastores, and OCI Data Science deployments
  • libs/oracledb/README.md — full langchain-oracledb guide: connecting with python-oracledb, OracleVS with chunking and indexing, loaders, splitter, embeddings, and summaries
  • libs/langgraph-oracledb/README.md — checkpointer and store quickstarts (sync and async), plus vector-search store configuration
  • libs/js/langchain-oracledb/README.md — LangChain.js usage for every component, with build and test instructions
  • samples/README.md — the learning path index, feature coverage matrix, and prerequisites

💁 Contributing

This project welcomes contributions from the community. Contributors must sign the Oracle Contributor Agreement and sign off each commit (git commit -s). See the contribution guide for the full workflow.

🔐 Security

Please report security vulnerabilities privately to Oracle following the security guide — not through public GitHub issues.

📕 License

Copyright (c) 2025 Oracle and/or its affiliates.

Released under the Universal Permissive License v1.0. See LICENSE.txt and THIRD_PARTY_LICENSES.txt for details.

About

The Oracle LangChain integration provides official LangChain support for Oracle’s Generative AI and AI Platform services, enabling developers to build intelligent, secure, and scalable applications powered by Oracle’s cloud technologies.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

60 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages

Generated from oracle/template-repo