Python SDK for the GuruCloud Knowledge Bank API
Project description
GuruCloud KB SDK
Python SDK for the GuruCloud Knowledge Bank API — a multi-dimensional, semantic vector store. Every Knowledge Bank has a configurable dimension schema: each dimension is its own embedding space, and search is a weighted combination across the dimensions you choose.
pip install gurucloud-kb
Authenticate
from gurucloud_kb import GuruCloudClient
client = GuruCloudClient(api_key="kb_your_api_key") # keys start with "kb_"
API keys carry scopes: read (search, list), write (add/update entries),
admin (create/delete KBs, change the schema).
Mental model (read this first)
A Knowledge Bank is not a single vector index. It is a set of named dimensions, each of which is embedded separately:
| Concept | What it is |
|---|---|
| Dimension | A named field that gets its own embedding(s). The default KB has content, useful_for, relevant_systems, relevant_tasks. |
single dimension |
One vector per entry (e.g. content). |
multi dimension |
A list of values, each embedded; matches ANY value (e.g. relevant_systems). |
| Weighted search | You query several dimensions at once; each has a weight; scores combine into one ranked result. |
metadata_filters |
Exact (non-semantic) JSONB filtering layered on top of the semantic ranking. |
You can use the 4 default dimensions, or define your own semantic dimensions when you create a KB.
Create a KB with custom semantic dimensions
Pass a dimension_schema to create_kb. Each dimension becomes its own
embedding space and is automatically searchable.
kb = client.create_kb(
name="support-kb",
description="Resolved support tickets",
dimension_schema={
"version": 1,
"combination_mode": "weighted_sum",
"dimensions": [
# one vector per entry, required
{"name": "symptom", "display_name": "Symptom",
"description": "What the user reported",
"dimension_type": "single", "required": True, "default_weight": 1.5},
{"name": "resolution", "display_name": "Resolution",
"description": "How it was fixed",
"dimension_type": "single", "required": True},
# a list field — each value embedded, matches ANY
{"name": "products", "display_name": "Products",
"description": "Affected products",
"dimension_type": "multi", "max_items": 8},
],
},
)
print(kb.id, kb.name)
If you omit dimension_schema, you get the default 4-dimension schema
(content, useful_for, relevant_systems, relevant_tasks).
Embedding model. Every dimension in a KB shares one model (
text-embedding-3-small, 1536-dim). The model is not currently selectable through the SDK.
Evolve the schema later (admin scope)
kb.get_schema() # current KBDimensionSchema
kb.validate_schema(new_schema) # returns warnings, applies nothing
kb.update_schema(new_schema) # replace the whole schema
kb.add_dimension({"name": "severity_notes", "display_name": "Severity",
"description": "Severity context", "dimension_type": "single"})
kb.remove_dimension("severity_notes")
Add entries
Provide a value for each dimension. single dimensions take a string;
multi dimensions take a list of strings.
kb.add_entry({
"dimensions": {
"symptom": "Login loops back to the sign-in page after SSO",
"resolution": "Cleared the stale SAML session cookie on the gateway",
"products": ["web app", "mobile app"],
},
"metadata": {"status": "resolved", "severity": "high"},
})
# Batch ingest (deduplicates by default)
kb.ingest([{ "dimensions": {...} }, { "dimensions": {...} }])
Search
Simple — one string against content
results = kb.search("how does authentication work?")
Multi-dimensional weighted search
Map each dimension to a query. The required per-dimension key is
query_text, and weight scales that dimension's contribution. Scores
are combined per combination_mode.
results = kb.search({
"dimensions": {
"symptom": {"query_text": "login loops after SSO", "weight": 2.0},
"products": {"query_text": "mobile app", "weight": 0.5},
},
"combination_mode": "weighted_sum",
"metadata_filters": {"status": "resolved"}, # exact, non-semantic
"k": 10,
"threshold": 0.35,
})
for r in results:
print(r["combined_score"], r["dimensions"] if "dimensions" in r else r)
Per-dimension you can also override aggregation, top_k, and
min_threshold:
"products": {"query_text": "mobile", "weight": 1.0,
"aggregation": "max", "min_threshold": 0.2}
Search request reference
| Field | Type | Notes |
|---|---|---|
dimensions |
{name: {query_text, weight, aggregation?, top_k?, min_threshold?}} |
At least one dimension required. Must be searchable. |
combination_mode |
weighted_sum | weighted_product | max | min | custom |
How dimension scores combine. |
custom_formula |
str |
Required when combination_mode="custom"; SQL over <dim>_score. |
metadata_filters |
dict |
Exact JSONB containment, e.g. {"status": "resolved"}. |
category_filters |
[{tag, max_results, min_score}] |
Bucket results by metadata tag. |
k, threshold |
int, float |
Result count / minimum combined score. |
aggregation (for multi dimensions): max, avg, min, top_k_avg,
sum, count.
The SDK also accepts the older spellings query (per dimension) and
filters (top level) and rewrites them to query_text / metadata_filters
for you — but prefer the canonical names above.
Use the KB as an MCP server (agent injection)
mcp_def = kb.get_mcp_server_definition()
agent_config = {
"mcpServers": {
mcp_def["server_name"]: {
"type": mcp_def["type"],
"url": mcp_def["url"],
"headers": {"Authorization": f"Bearer {api_key}"},
}
}
}
# Or mint a dedicated never-expiring token (admin scope):
pat = kb.generate_pat(token_name="My Agent")
The MCP tools (query_knowledge_bank, report_learning) are generated from
your schema — every searchable dimension becomes a <dimension>_query
parameter automatically.
Async
The async client mirrors the sync API exactly — every method is awaitable.
from gurucloud_kb import AsyncGuruCloudClient
async with AsyncGuruCloudClient(api_key="kb_...") as client:
kb = await client.get_kb("your-kb-uuid")
results = await kb.search({
"dimensions": {"content": {"query_text": "JWT", "weight": 1.0}},
"k": 5,
})
Typed contracts
All request/response shapes are exported as TypedDicts / Literals for
editor + agent autocompletion:
from gurucloud_kb import (
DimensionConfig, DimensionSchema, DimensionType,
DimensionQuery, SearchRequest, CombinationMode, Aggregation,
CategoryFilter, EntryInput, EntryResult, KBInfo,
)
Project details
Release history Release notifications | RSS feed
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 gurucloud_kb-0.1.1.tar.gz.
File metadata
- Download URL: gurucloud_kb-0.1.1.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e035a0f9926a69164b93c78602bb7b5a01e7006ca2ccd1e75a9c2e2fb15b12a
|
|
| MD5 |
6a7136c8d1d2b0032cbd179ddbc4a08d
|
|
| BLAKE2b-256 |
d7f42b973cb4433a9ef367a5c726b66cc2519200a10d6b83775d287d0125cedc
|
File details
Details for the file gurucloud_kb-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gurucloud_kb-0.1.1-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e75fff32148cce0dd08af979780a92aed1eeaa328b2be4ca2b3b06050b59fcc
|
|
| MD5 |
359eb61b7b730e15d18a6ea572adc447
|
|
| BLAKE2b-256 |
95ef583e14ee66b9c1efa4e4f9e3d68ac272c0c0764a37b6961a3b83c16e21e5
|