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.1.0.tar.gz (7.9 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.1.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: conduit_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 7.9 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.1.0.tar.gz
Algorithm Hash digest
SHA256 9d50eae842c3119886d3dfc47a2c60692b0366d957de209f42a56d6c668a715b
MD5 4b098b6b5c4ce649e61174a22004babb
BLAKE2b-256 d3e84a93d6e0df037a9ef7aeb99560c31b4f10be5fc25b6e269ee5f41140ef75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: conduit_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 49966ad31af64b57197959f5e3cca22b9b512f08864182d22dc587dee20ceb6b
MD5 2fa668ed36091f7fdf25432395bd095e
BLAKE2b-256 a42f00d92726c0ec404cf16578b0941e6fa05579fed647265fb740d0172a2870

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