Python SDK for the LibScope AI knowledge base
Project description
libscope Python SDK
Python client library for the libscope AI knowledge base.
Installation
pip install libscope
Or for development:
pip install -e ".[dev]"
Quick Start
from libscope import LibscopeClient
with LibscopeClient() as client:
# Add a document from a URL
doc = client.add_document("https://docs.python.org/3/tutorial/")
# Add a document from raw text
client.add_text("My Notes", "Some useful content...", topic="python")
# Search
results = client.search("how to use decorators")
for hit in results.results:
print(f"{hit.title}: {hit.score:.2f}")
# Manage tags
client.add_tags(doc.id, ["python", "tutorial"])
# Ask a question (RAG)
answer = client.ask("What is the best practice for error handling?")
print(answer.answer)
Async Usage
import asyncio
from libscope import AsyncLibscopeClient
async def main():
async with AsyncLibscopeClient() as client:
results = await client.search("decorators")
for hit in results.results:
print(f"{hit.title}: {hit.score:.2f}")
asyncio.run(main())
Configuration
# Custom server URL and timeout
client = LibscopeClient(
base_url="http://my-server:3378",
timeout=60.0,
)
API Reference
Document Operations
| Method | Description |
|---|---|
search(query, *, limit, topic, tags, min_score) |
Semantic search |
add_document(url, *, topic, tags) |
Index a document from URL |
add_text(title, content, *, topic, tags) |
Index raw text |
get_document(doc_id) |
Get a document by ID |
list_documents(*, topic, limit, offset) |
List documents |
delete_document(doc_id) |
Delete a document |
Topic Operations
| Method | Description |
|---|---|
list_topics() |
List all topics |
create_topic(name, *, parent_id) |
Create a topic |
Tag Operations
| Method | Description |
|---|---|
add_tags(doc_id, tags) |
Add tags to a document |
remove_tags(doc_id, tags) |
Remove tags from a document |
list_tags() |
List all tags |
Analytics & Q&A
| Method | Description |
|---|---|
get_analytics() |
Get knowledge base statistics |
ask(question, *, topic) |
RAG-powered question answering |
health() |
Check server health |
Requirements
- Python 3.9+
- A running libscope server (default:
http://localhost:3378)
License
MIT
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 pylibscope-1.2.1.tar.gz.
File metadata
- Download URL: pylibscope-1.2.1.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e10f252458189855cc2bcdb8805061d00d10f2c0d44e1231912ae772740e93f
|
|
| MD5 |
32c7bb9104b6813ea7668476a8bc9771
|
|
| BLAKE2b-256 |
2eaae7f1e2555d3fe0a744dd49114176952d5a560539015223c8fe2ad26c34e4
|
Provenance
The following attestation bundles were made for pylibscope-1.2.1.tar.gz:
Publisher:
release-python.yml on RobertLD/libscope
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylibscope-1.2.1.tar.gz -
Subject digest:
9e10f252458189855cc2bcdb8805061d00d10f2c0d44e1231912ae772740e93f - Sigstore transparency entry: 1009331333
- Sigstore integration time:
-
Permalink:
RobertLD/libscope@80874788f903e0249951c5712282ff4e8d3ce229 -
Branch / Tag:
refs/tags/v1.2.1 - Owner: https://github.com/RobertLD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@80874788f903e0249951c5712282ff4e8d3ce229 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pylibscope-1.2.1-py3-none-any.whl.
File metadata
- Download URL: pylibscope-1.2.1-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b68d7ce1409c1d06b8fa3dbef056d2e9b086c385f9df57ef068511257227968d
|
|
| MD5 |
7302785cc47ed3a14bff68d53ad510e9
|
|
| BLAKE2b-256 |
04f074f03d282144e4dc297c7c636546626e407f31ab10ad0e5ec7d5792dd0a1
|
Provenance
The following attestation bundles were made for pylibscope-1.2.1-py3-none-any.whl:
Publisher:
release-python.yml on RobertLD/libscope
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylibscope-1.2.1-py3-none-any.whl -
Subject digest:
b68d7ce1409c1d06b8fa3dbef056d2e9b086c385f9df57ef068511257227968d - Sigstore transparency entry: 1009331338
- Sigstore integration time:
-
Permalink:
RobertLD/libscope@80874788f903e0249951c5712282ff4e8d3ce229 -
Branch / Tag:
refs/tags/v1.2.1 - Owner: https://github.com/RobertLD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@80874788f903e0249951c5712282ff4e8d3ce229 -
Trigger Event:
push
-
Statement type: