Skip to main content

Python SDK for Conduit — the knowledge graph engine. Includes LangChain retriever.

Project description

conduit-ai

Python SDK for Conduit — the knowledge graph engine.

Install

pip install conduit-ai                    # Core client
pip install 'conduit-ai[langchain]'       # With LangChain retriever

Quick Start

Ask a question

from conduit_ai import ConduitClient

client = ConduitClient(api_key="ck_...", endpoint="http://localhost:4000")

answer = client.ask("How does Snowflake Cortex Search work?")
print(answer.answer)
print(f"Sources: {len(answer.sources)}")

Conversational follow-ups

import uuid

thread_id = str(uuid.uuid4())

answer1 = client.ask("What is Delta Live Tables?", thread_id=thread_id)
answer2 = client.ask("Can I use it with Cortex?", thread_id=thread_id)
# ^ automatically rewritten to: "Can I use Delta Live Tables with Snowflake Cortex?"

Retrieve context (no LLM)

ctx = client.context("data pipeline best practices", limit=5)
for result in ctx.results:
    print(f"{result.title} ({result.score:.2f})")
    print(f"  Domains: {result.domains}")

Stream tokens

async for token in client.aask_stream("Compare Databricks and Snowflake for ML"):
    print(token, end="", flush=True)

LangChain Retriever

Drop Conduit into any LangChain/LangGraph chain:

from conduit_ai.retriever import ConduitRetriever
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough
from langchain_core.output_parsers import StrOutputParser

retriever = ConduitRetriever(
    api_key="ck_...",
    endpoint="http://localhost:4000",
    kai_id="kai_snowflake",   # Optional: scope to a Kai
    limit=8,
)

prompt = ChatPromptTemplate.from_template(
    "Answer based on context:\n{context}\n\nQuestion: {question}"
)

chain = (
    {"context": retriever, "question": RunnablePassthrough()}
    | prompt
    | ChatOpenAI(model="gpt-4o")
    | StrOutputParser()
)

result = chain.invoke("How do I set up change data capture?")

Retriever Options

Parameter Default Description
api_key None Conduit API key
endpoint https://api.conduit.datakai.com Conduit server URL
kai_id None Scope retrieval to a specific Kai
limit 8 Max results to retrieve
include_content True Include full zettel content in documents
include_graph_context False Use /context endpoint (includes graph neighbors) instead of /ask

Scoped Knowledge (Kais)

Kais are knowledge views — filtered subsets of the graph scoped by domain, topic, or knowledge type.

# Query only Snowflake knowledge
client = ConduitClient(api_key="ck_...", kai_id="kai_snowflake")
answer = client.ask("How do dynamic tables work?")

# Or per-retriever
retriever = ConduitRetriever(api_key="ck_...", kai_id="kai_aws")

Async Support

Every method has an async counterpart:

answer = await client.aask("question")
ctx = await client.acontext("query")

async with ConduitClient(api_key="ck_...") as client:
    answer = await client.aask("question")

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

conduit_ai-0.2.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

conduit_ai-0.2.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file conduit_ai-0.2.0.tar.gz.

File metadata

  • Download URL: conduit_ai-0.2.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for conduit_ai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bce8cb57270b9dca479d3c8b469630f87449cb2e596f50543c021378c8059aa6
MD5 d7205efcd90bda11a729897d28b94e40
BLAKE2b-256 e4f05a419b9b3c7fbe82f622b3bab6c4a57f8d02833082513819e3284ca0301f

See more details on using hashes here.

File details

Details for the file conduit_ai-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: conduit_ai-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for conduit_ai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b0e042e32939bc3a48934a028cca3a793663d3f6b11816a35e989cff6504b4a
MD5 7325dc8bba439d6c974223a6f48eab08
BLAKE2b-256 34872601523185ffa110398b02034948fd453a04a75245ca015753e5f717a7ae

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