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.3.tar.gz (10.7 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.3-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modulecontextstreaming-0.0.3.tar.gz
  • Upload date:
  • Size: 10.7 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.3.tar.gz
Algorithm Hash digest
SHA256 4908bfd14d469df6c78d3b1bff6ee596a48a40389972fd92d88d65fb63b88c9f
MD5 2c51562f8d70902dc9d65eceb389de4f
BLAKE2b-256 838f8f72de526ddae2965c5aa69c866103f2ab33c88aecada53c9704e8bb38e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for modulecontextstreaming-0.0.3.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.3-py3-none-any.whl.

File metadata

File hashes

Hashes for modulecontextstreaming-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a07e39bc46da426ab9a87fde91455f34727f8850b4a4abf5da30dd296c6aa0f7
MD5 3d7846f1c4b6770f010cf70139dad6d4
BLAKE2b-256 9c96c6d89d1ee0069151706f34c147559861a37d3ea8f2083e20a2c9a4a66c80

See more details on using hashes here.

Provenance

The following attestation bundles were made for modulecontextstreaming-0.0.3-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