An integration package connecting ClickZetta and LangChain
Project description
LangChain ClickZetta Integration
An integration package connecting ClickZetta and LangChain.
LangChain integration for ClickZetta, providing SQL queries, vector storage, and full-text search capabilities.
Features
- SQL Queries: Natural language to SQL conversion and execution
- Vector Storage: Efficient vector storage and similarity search
- Full-text Search: Advanced text search capabilities with inverted index
- Chat History: Persistent conversation memory
- Hybrid Search: Combine vector and full-text search
- True Hybrid Store: Single table with both vector and inverted indexes (ClickZetta native)
Installation
pip install langchain-clickzetta
Quick Start
Basic Setup
from langchain_clickzetta import ClickZettaEngine
# Create engine
engine = ClickZettaEngine(
service="your-service",
instance="your-instance",
workspace="your-workspace",
schema="your-schema",
username="your-username",
password="your-password",
vcluster="your-vcluster"
)
Vector Storage
from langchain_clickzetta import ClickZettaVectorStore
from langchain_community.embeddings import DashScopeEmbeddings
# Setup embeddings
embeddings = DashScopeEmbeddings(
dashscope_api_key="your-api-key",
model="text-embedding-v4"
)
# Create vector store
vector_store = ClickZettaVectorStore(
engine=engine,
embeddings=embeddings,
table_name="my_vectors"
)
# Add documents
texts = ["Hello world", "LangChain is great"]
vector_store.add_texts(texts)
# Search
results = vector_store.similarity_search("greeting", k=2)
True Hybrid Search
from langchain_clickzetta import ClickZettaHybridStore, ClickZettaUnifiedRetriever
# Create hybrid store (single table with vector + full-text indexes)
hybrid_store = ClickZettaHybridStore(
engine=engine,
embeddings=embeddings,
table_name="hybrid_docs"
)
# Add documents
hybrid_store.add_texts([
"ClickZetta is a high-performance analytics database",
"LangChain enables building applications with LLMs"
])
# Create unified retriever
retriever = ClickZettaUnifiedRetriever(
hybrid_store=hybrid_store,
search_type="hybrid", # "vector", "fulltext", or "hybrid"
alpha=0.5 # Balance between vector and full-text search
)
# Search with hybrid approach
results = retriever.get_relevant_documents("analytics database")
SQL Chain
from langchain_clickzetta import ClickZettaSQLChain
from langchain_community.llms import Tongyi
llm = Tongyi(dashscope_api_key="your-api-key")
sql_chain = ClickZettaSQLChain.from_engine(
engine=engine,
llm=llm
)
result = sql_chain.invoke({"query": "How many tables are there?"})
print(result["result"])
Documentation
For more detailed documentation, see the main repository README and examples.
Development
See CONTRIBUTING.md for development setup and guidelines.
License
This package is released under the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_clickzetta-0.1.0.tar.gz.
File metadata
- Download URL: langchain_clickzetta-0.1.0.tar.gz
- Upload date:
- Size: 70.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d19574d40c03e3388ecc6716fb4b09d12d6c758e9220946d270629c130cf46b
|
|
| MD5 |
d9635086660bfbf89766c59712f9e715
|
|
| BLAKE2b-256 |
f438ab0e5903bd67e7a15b372b8d178d7a15126d2f90e6bfeaff72f8c8ce53d5
|
File details
Details for the file langchain_clickzetta-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_clickzetta-0.1.0-py3-none-any.whl
- Upload date:
- Size: 36.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05be06f7bd7810bb138f561fe6e7d3fb78b35ee85ec44659ecaf5c640422794b
|
|
| MD5 |
0962750fbedfdb9f3635ff6074cd3b55
|
|
| BLAKE2b-256 |
411e9b6404373940eb10fd16c50358bcb08699587b6e810ce949ad83e5d84bca
|