Context Hub (Chub) Documentation

repository·main·Indexed 28 days ago

https://github.com/andrewyng/context-hub

Context Hub (Chub) provides coding agents with curated, versioned documentation to prevent API hallucinations. Includes the @aisuite/chub CLI for searching, fetching, and annotating documentation in Python or JavaScript, designed for integration into autonomous agent workflows and skills.

Tokens
2.7M
Snippets
8.4K
Records
10.6K
Agent score
96%

What's inside context-hub

  1. Overview of LiveKit Python SDK capabilities in the demo

    main

    The demo showcases several core LiveKit functionalities:

    • Access Token Generation: Create JWT tokens with configurable user identity, display name, room permissions (join, publish, subscribe), and expiration.
    • Room Management: Use the server API to create, list, and delete rooms, as well as manage participants.
    • Recording (Egress): Start room composite recordings and configure output formats.
    • Real-time Connection: Connect to rooms, handle track subscriptions, and process video/audio streams.
    • RPC Methods: Register RPC method handlers and perform remote procedure calls between participants.
  2. Manage Elasticsearch/OpenSearch Domains (Control Plane)

    main

    Use this package for control-plane operations (managing the service itself).

    Use this for:

    • Creating, deleting, or updating domains.
    • Inspecting domain status, endpoints, or configuration.
    • Changing instance sizing, storage, security, or logging settings.
    • Managing tags, packages, upgrades, and software updates.

    DO NOT use this for:

    • Indexing documents.
    • Running searches (/_search).
    • Bulk operations (/_bulk).

    For data-plane traffic (searching/indexing), use DescribeElasticsearchDomainCommand to fetch the domain endpoint, then use a signed HTTP client to send requests to that endpoint.

  3. Understand the h11 Core Model

    main

    h11 is a low-level, sans-I/O HTTP/1.1 protocol state machine. It is not an HTTP client or server library; it does not handle sockets, TLS, connection pooling, or redirects. Instead, it turns HTTP/1.1 bytes into typed events and vice versa.

    The Four Core Operations

    1. Read bytes from your transport (socket, stream, etc.).
    2. Feed bytes into conn.receive_data(...).
    3. Pull events using conn.next_event().
    4. Build and serialize events using conn.send(...).

    Important Event Types

    • Request / Response / InformationalResponse
    • Data (for request/response bodies)
    • EndOfMessage (signals the end of a message)
    • ConnectionClosed

    Important States and Sentinels

    • NEED_DATA: Call next_event() again only after reading more bytes.
    • PAUSED: Stop reading until the application advances the connection cycle.
    • IDLE, SEND_BODY, SEND_RESPONSE, DONE, MUST_CLOSE
  4. Important: Use the correct client for Data vs Admin tasks

    main

    The google-cloud-memcache package is an Admin API client. It is used for provisioning, inspecting, and managing Memcached instances.

    Do NOT use this package for Memcached key/value traffic (get, set, delete, etc.).

    Correct Workflow:

    1. Use google-cloud-memcache to create/inspect the instance.
    2. Retrieve the discovery_endpoint or node addresses from the Instance object.
    3. Use a standard Memcached protocol client (e.g., pymemcache) in your application to perform data operations using those endpoints.
  5. Choose the right PyNaCl cryptographic primitive

    main

    Select a primitive based on your security requirements:

    PrimitiveUse Case
    SigningKey / VerifyKeySign data with Ed25519 and verify tampering.
    SecretBoxEncrypt with a shared 32-byte secret key.
    AeadEncrypt with a shared 32-byte secret key and authenticate extra metadata (aad).
    BoxEncrypt between two Curve25519 keypairs (peer-to-peer).
    SealedBoxEncrypt to a recipient's public key where the sender cannot decrypt.
    pwhashStore password hashes or derive keys from passwords.
  6. Compare Crawl vs Map APIs

    main

    Choose between crawl and map based on your specific use case:

    FeatureCrawlMap
    ReturnsFull contentURLs only
    SpeedSlowerFaster
    Best forRAG, deep analysis, documentationSite structure discovery, URL collection

    Use Crawl when:

    • You need full content extraction.
    • You are building RAG systems.
    • You need to process paginated or nested content.

    Use Map when:

    • You need quick site structure discovery.
    • You only need to collect URLs without content.
    • You are planning a crawl strategy.
  7. Supported file formats in LandingAI ADE

    main

    LandingAI ADE supports over 20 file formats across several categories. Use the following guide to select the appropriate format for your use case:

    CategoryFormatsNotes
    PDFPDFNative format; no conversion impact
    ImagesJPEG, JPG, PNG, + 15 moreCommon formats fully supported; OCR applied automatically
    DocumentsDOC, DOCX, ODTConverted to PDF before parsing; layout may change
    PresentationsPPT, PPTX, ODPConverted to PDF before parsing; animations/transitions lost
    SpreadsheetsCSV, XLSXExtracted as table chunks; converted to HTML tables in Markdown

    Best Practices

    • For critical layout preservation: Convert DOCX, PPTX, or ODT files to PDF manually before parsing.
    • For complex layouts: Use the dpt-2-latest model.
    • For large files: Use the Parse Jobs API (async) for files > 50 pages or large spreadsheets.
  8. Understand the Search Ranking Model

    main

    Context Hub uses a multi-layered scoring model to rank search results. The final score is calculated using the following formula:

    final_score = term_relevance * (1 + qualityScore / 20) * source_boost

    1. Term Relevance (Match)

    Uses weighted field scoring (BM25-style) instead of flat points:

    • id: 3.0 weight
    • name: 2.5 weight
    • tags: 2.0 weight
    • description: 1.0 weight

    2. Description Quality Score

    A deterministic score (0-10) computed at build time and stored as _qualityScore. It acts as a multiplier: a perfect score (10) provides a 1.5x boost.

    3. Source Authority Boost

    A multiplier based on the entry's source field:

    • maintainer: 1.3x
    • official: 1.2x
    • community: 1.0x
  9. Choose the right multidict type

    main

    Select a type based on your requirements for key uniqueness, case sensitivity, and mutability:

    • MultiDict: Mutable mapping that allows duplicate keys and preserves insertion order. Use this for URL query parameters or form fields.
    • CIMultiDict: Like MultiDict, but key lookup is case-insensitive. Ideal for HTTP headers.
    • MultiDictProxy: A read-only, live dynamic view over a MultiDict.
    • CIMultiDictProxy: A read-only, live dynamic view over a CIMultiDict.
    • istr: A str subclass used for case-insensitive key handling.

    Note: Keys must be str instances or subclasses of str (like istr).

  10. Install the Azure Network Management SDK for Python

    main

    To manage Azure networking resources (VNets, subnets, NSGs, etc.) via the management plane, install azure-mgmt-network along with azure-identity for authentication. It is recommended to pin the version to 30.2.0 for compatibility with this guide.

    Using pip:

    python -m pip install "azure-mgmt-network==30.2.0" azure-identity

    Using uv:

    uv add "azure-mgmt-network==30.2.0" azure-identity

    Using poetry:

    poetry add "azure-mgmt-network==30.2.0" azure-identity
    python -m pip install "azure-mgmt-network==30.2.0" azure-identity
  11. Configure the Document AI client with regional endpoints

    main

    Document AI is regional. You must initialize the DocumentProcessorServiceClient with a client_options object where the api_endpoint matches the location of your processor (e.g., us or eu).

    Required parameters:

    • project_id
    • location (e.g., us, eu)
    • processor_id
    • mime_type (e.g., application/pdf, image/png)

    Failure to match the endpoint to the processor location will result in errors.

    from google.api_core.client_options import ClientOptions
    from google.cloud import documentai
    
    location = "us"
    
    client = documentai.DocumentProcessorServiceClient(
        client_options=ClientOptions(
            api_endpoint=f"{location}-documentai.googleapis.com"
        )
    )