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
-
Clone the repository:
git clone https://github.com/armstrongsam25/ModuleContextStreaming.git cd ModuleContextStreaming
-
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
-
Install dependencies: This command installs the project in editable mode (
-e) along with all core and development dependencies.pip install -e .[dev]
-
Generate gRPC Code: This is the final setup step. Run the
build.pyscript to compile the.protofile and automatically apply the necessary import patch.python build_scripts.pyYou only need to re-run this command when you make changes to the
protos/mcs.protofile.
Usage
To test the client-server communication, you will need two separate terminals.
-
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. -
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.pyto 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.
- Implement the server-side gRPC Interceptor in
-
๐ก๏ธ Secure Transport (TLS):
- Upgrade the server and client from using an
insecure_channelto asecure_channelwith SSL/TLS encryption.
- Upgrade the server and client from using an
-
โ๏ธ Real Tool Implementation:
- Connect the
StreamToolCallmethod inserver.pyto actual backend logic instead of returning placeholder data.
- Connect the
-
๐ Configuration Management:
- Load settings like the server port and Keycloak URLs from a configuration file (e.g.,
.env) instead of being hardcoded.
- Load settings like the server port and Keycloak URLs from a configuration file (e.g.,
-
โ๏ธ Logging:
- Integrate a structured logging library (e.g.,
logging) for better debugging and monitoring.
- Integrate a structured logging library (e.g.,
-
๐งช 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
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 modulecontextstreaming-0.0.1.tar.gz.
File metadata
- Download URL: modulecontextstreaming-0.0.1.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
210add36fb70ba6631b6adc9ab3139feb0da56fe24c9fea4b78b236eb4dd1dda
|
|
| MD5 |
9e01c52a7064e0f36cf72db605794c5d
|
|
| BLAKE2b-256 |
1d5729ba7009c00f3aa35d6aa836b9f3f12e81e74e1cf487b483d8dfd635034f
|
File details
Details for the file modulecontextstreaming-0.0.1-py3-none-any.whl.
File metadata
- Download URL: modulecontextstreaming-0.0.1-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82cc74647b06b903cda7d8554f6bfbedf8301c5209d5fb1905e42089518340db
|
|
| MD5 |
fc05eb12acbbf411e59c3fa71120a11a
|
|
| BLAKE2b-256 |
d930051f2bf5d30e98eca1d8fb563b9f5410dc44c737017f2142ec7ad888d0b2
|