Skip to main content

A gRPC service for providing real-time, streamable context to LLMs.

Project description

ModuleContextStreaming (MCS) ๐Ÿš€

A high-performance gRPC service designed to provide real-time, streamable context to Large Language Models (LLMs). This project serves as a robust backend for AI applications that require secure, low-latency communication with server-side tools and resources.


Features

  • High-Performance Streaming: Built on gRPC and HTTP/2 for efficient, multiplexed, and low-latency data streaming.
  • Strict API Contract: Uses Protocol Buffers (.proto) as the single source of truth for the API, with code generation for type-safe communication.
  • Authentication-Ready: Designed for secure communication with JWT-based authentication via Keycloak (implementation pending).
  • Asynchronous-Capable: The gRPC foundation allows for highly concurrent and scalable server implementations.

You are absolutely right. Thank you for the correction. The README.md should reflect your actual project structure.

Here is the corrected "Project Structure" section. You can replace the old one in your README.md with this updated version.


Project Structure

The project is organized with the root directory containing the Python package, API definitions, and supporting files.

ModuleContextStreaming/         # The project root directory
โ”œโ”€โ”€ ModuleContextStreaming/     # The main, installable Python package
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ server.py
โ”‚   โ”œโ”€โ”€ client.py
โ”‚   โ”œโ”€โ”€ auth.py
โ”‚   โ”œโ”€โ”€ exceptions.py
โ”‚   โ”œโ”€โ”€ mcs_pb2.py
โ”‚   โ””โ”€โ”€ mcs_pb2_grpc.py
โ”œโ”€โ”€ protos/
โ”‚   โ””โ”€โ”€ mcs.proto             # The API contract source of truth
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ simple_server.py      # Example runnable server (To-Do)
โ”‚   โ””โ”€โ”€ simple_client.py      # Example runnable client (To-Do)
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ ...                   # Unit and integration tests (To-Do)
โ”œโ”€โ”€ build.py                  # Script to generate and patch gRPC code
โ”œโ”€โ”€ DESIGN.md                 # Your design document
โ”œโ”€โ”€ pyproject.toml            # Project metadata and dependencies
โ””โ”€โ”€ README.md

Setup and Installation

Follow these steps to set up your local development environment.

#1. Prerequisites

  • Python 3.10+
  • Git

#2. Installation Steps

  1. Clone the repository:

    git clone https://github.com/armstrongsam25/ModuleContextStreaming.git
    cd ModuleContextStreaming
    
  2. Create and activate a virtual environment:

    # Create the virtual environment
    python -m venv .venv
    
    # Activate it (Windows)
    .\.venv\Scripts\activate
    
    # Activate it (macOS/Linux)
    source .venv/bin/activate
    
  3. Install dependencies: This command installs the project in editable mode (-e) along with all core and development dependencies.

    pip install -e .[dev]
    
  4. Generate gRPC Code: This is the final setup step. Run the build.py script to compile the .proto file and automatically apply the necessary import patch.

    python build_scripts.py
    

    You only need to re-run this command when you make changes to the protos/mcs.proto file.


Usage

To test the client-server communication, you will need two separate terminals.

  1. Start the Server: In your first terminal (with the virtual environment activated), run:

    python -m ModuleContextStreaming.server
    

    You should see the message: โœ… Server started, listening on port 50051.

  2. Run the Client: In your second terminal (with the virtual environment activated), run:

    python -m ModuleContextStreaming.client
    

    The client will make several calls to the server and print the responses, including the streamed data.


Roadmap (Not Yet Implemented) ๐Ÿ—บ๏ธ

This project is in the early stages of development. The following key features from the design document are planned but not yet implemented:

  • ๐Ÿ” Authentication & Authorization:

    • Implement the server-side gRPC Interceptor in auth.py to validate Keycloak JWTs on every protected RPC call.
    • Implement a real OAuth 2.0 flow in the client to acquire tokens from Keycloak instead of using a placeholder.
  • ๐Ÿ›ก๏ธ Secure Transport (TLS):

    • Upgrade the server and client from using an insecure_channel to a secure_channel with SSL/TLS encryption.
  • โš™๏ธ Real Tool Implementation:

    • Connect the StreamToolCall method in server.py to actual backend logic instead of returning placeholder data.
  • ๐Ÿ“„ Configuration Management:

    • Load settings like the server port and Keycloak URLs from a configuration file (e.g., .env) instead of being hardcoded.
  • โœ๏ธ Logging:

    • Integrate a structured logging library (e.g., logging) for better debugging and monitoring.
  • ๐Ÿงช Testing:

    • Add unit tests for server-side logic.
    • Add integration tests to verify the client-server communication and authentication flow.

License

Distributed under the MIT License.

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

modulecontextstreaming-0.0.4.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

modulecontextstreaming-0.0.4-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file modulecontextstreaming-0.0.4.tar.gz.

File metadata

  • Download URL: modulecontextstreaming-0.0.4.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for modulecontextstreaming-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2ec4707acfcc117747d1d780bc35102b3e8c22390059aafb8e3f59c7dccc8274
MD5 d97c62cc8db79ca5b0e991d19cd68858
BLAKE2b-256 e5781afc8f67dd7d7c719912630474833456c01116e4bbd9ef89695532f4b64c

See more details on using hashes here.

Provenance

The following attestation bundles were made for modulecontextstreaming-0.0.4.tar.gz:

Publisher: publish-to-pypi.yml on armstrongsam25/ModuleContextStreaming

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

File details

Details for the file modulecontextstreaming-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for modulecontextstreaming-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6ee7fc58f28d420054855bcce6c672bbda20a9d183988bd6d671d12a508d05e9
MD5 bf3b05d6c8b83dc840e646299f670605
BLAKE2b-256 1c67cb32fe6e38a1373c1d0517b85006613ad47a3f46b71385382e333b175b3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for modulecontextstreaming-0.0.4-py3-none-any.whl:

Publisher: publish-to-pypi.yml on armstrongsam25/ModuleContextStreaming

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