Skip to main content

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

langchain_clickzetta-0.1.0.tar.gz (70.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_clickzetta-0.1.0-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

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

Hashes for langchain_clickzetta-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9d19574d40c03e3388ecc6716fb4b09d12d6c758e9220946d270629c130cf46b
MD5 d9635086660bfbf89766c59712f9e715
BLAKE2b-256 f438ab0e5903bd67e7a15b372b8d178d7a15126d2f90e6bfeaff72f8c8ce53d5

See more details on using hashes here.

File details

Details for the file langchain_clickzetta-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_clickzetta-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05be06f7bd7810bb138f561fe6e7d3fb78b35ee85ec44659ecaf5c640422794b
MD5 0962750fbedfdb9f3635ff6074cd3b55
BLAKE2b-256 411e9b6404373940eb10fd16c50358bcb08699587b6e810ce949ad83e5d84bca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page