Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylibscope-1.2.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

pylibscope-1.2.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

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

Hashes for pylibscope-1.2.1.tar.gz
Algorithm Hash digest
SHA256 9e10f252458189855cc2bcdb8805061d00d10f2c0d44e1231912ae772740e93f
MD5 32c7bb9104b6813ea7668476a8bc9771
BLAKE2b-256 2eaae7f1e2555d3fe0a744dd49114176952d5a560539015223c8fe2ad26c34e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylibscope-1.2.1.tar.gz:

Publisher: release-python.yml on RobertLD/libscope

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pylibscope-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b68d7ce1409c1d06b8fa3dbef056d2e9b086c385f9df57ef068511257227968d
MD5 7302785cc47ed3a14bff68d53ad510e9
BLAKE2b-256 04f074f03d282144e4dc297c7c636546626e407f31ab10ad0e5ec7d5792dd0a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylibscope-1.2.1-py3-none-any.whl:

Publisher: release-python.yml on RobertLD/libscope

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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