LangChain
Use LangChain with Oracle AI Database to build retrieval-augmented generation, agentic search, semantic caching, chat history, and memory-augmented AI applications.
LangChain is an open source framework for building applications powered by large language models (LLMs). It provides standardized interfaces for connecting LLMs to data sources, tools, and memory systems.
Why LangChain with Oracle AI Database
Oracle AI Database combines relational, document, graph, and vector data in a single engine. When paired with LangChain, it eliminates the need for a separate vector database and provides a complete platform for AI application development.
Key capabilities of the integration:
- Vector search: Store and query embedding vectors alongside relational data using Oracle AI Vector Search.
- Full-text search: Use Oracle Text’s
CONTAINSoperator for keyword-based retrieval with fuzzy matching and stemming. - Hybrid search: Combine keyword and semantic signals in a single retrieval call for higher-quality results (Oracle Database 26ai).
- Document loading: Load 150+ file formats (PDF, DOCX, HTML, and more) through Oracle Text’s built-in document processing engine.
- In-database embeddings: Run ONNX embedding models directly inside the database to avoid network round-trips.
- Semantic caching: Store LLM generations in
OracleSemanticCacheand retrieve prior responses by vector similarity. - Chat message history: Persist session-scoped LangChain messages with
OracleChatMessageHistory. - Agent memory: Store conversation history, knowledge bases, and agent state with ACID guarantees and semantic searchability.
- Summarization: Generate document summaries using Oracle’s built-in text processing or external providers.
Architecture
A typical LangChain + Oracle AI Database application follows this data flow:
- Ingest: Load documents with
OracleDocLoader, chunk them withOracleTextSplitter. - Embed: Generate vector embeddings with
OracleEmbeddings(in-database ONNX model) or any LangChain-compatible embedding model. - Store: Persist documents, metadata, and vectors in
OracleVS(Oracle AI Vector Search). - Index: Create HNSW or IVF indexes for fast approximate nearest-neighbor search.
- Retrieve: Query using semantic search, full-text search, or hybrid search depending on the use case.
- Cache: Use
OracleSemanticCacheto reuse responses for repeated or semantically similar prompts. - Remember: Persist ordered chat turns with
OracleChatMessageHistory. - Generate: Pass retrieved context and conversation history to an LLM via LangChain chains or LangGraph agents.
Language Support
Oracle provides LangChain integration packages for multiple languages. Select a language below for the complete integration guide:
| Language | Package | Status |
|---|---|---|
| Python | langchain-oracledb |
Available |
| JavaScript | @oracle/langchain-oracledb |
Available |
| Java | dev.langchain4j:langchain4j-oracle |
Available |
Resources
- Oracle AI Developer Hub: Notebooks, applications, and reference materials.
- LangChain documentation: Official LangChain framework documentation.
- LangChain4j Oracle embedding store documentation: Official LangChain4j Oracle embedding store reference.
- Oracle AI Vector Search documentation: Oracle vector search capabilities.
- Oracle LiveLabs AI Agent Workshop: Hands-on lab for building AI agents with Oracle AI Database.