-
Notifications
You must be signed in to change notification settings - Fork 337
ChatQnA Example with OpenAI-Compatible Endpoint #2054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ChatQnA Example with OpenAI-Compatible Endpoint #2054
Conversation
…local inference service e.g., vllm Signed-off-by: Ed Lee <[email protected]>
Signed-off-by: Ed Lee <[email protected]>
…ndexing Signed-off-by: Ed Lee <[email protected]>
…g improvements, and updated pydantic model validations from parse_obj to model_validate Signed-off-by: Ed Lee <[email protected]>
…ataprep, receiver, and final output. The UI payload had to be updated since the model was hardcoded and not based on LLM_MODEL_ID Signed-off-by: Ed Lee <[email protected]>
…LLM_MODEL_ID env variable. Before the UI request had model hardcoded. Signed-off-by: Ed Lee <[email protected]>
Signed-off-by: Ed Lee <[email protected]>
Signed-off-by: Ed Lee <[email protected]>
Signed-off-by: Ed Lee <[email protected]>
Signed-off-by: Ed Lee <[email protected]>
Signed-off-by: Ed Lee <[email protected]>
Signed-off-by: Ed Lee <[email protected]>
Signed-off-by: Ed Lee <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: Ed Lee <[email protected]>
Signed-off-by: Ed Lee <[email protected]>
Signed-off-by: Ed Lee <[email protected]>
… into graphrag_workshop
for more information, see https://pre-commit.ci
Signed-off-by: Ed Lee <[email protected]>
Signed-off-by: Ed Lee <[email protected]>
… into graphrag_workshop
for more information, see https://pre-commit.ci
…mproved logging messages. Signed-off-by: Ed Lee <[email protected]>
… compose_endpoint_openai.yaml Signed-off-by: Ed Lee <[email protected]>
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR extends ChatQnA to support OpenAI-compatible endpoints and improves robustness by enhancing environment variable handling, skipping null content chunks, and adding detailed logging for debugging.
- Introduces
LLM_MODEL_IDvalidation in frontend and dynamically sets the model in requests. - Refactors
align_generator,align_inputs, andalign_outputsto skip null or malformed content and use structured logging. - Adds new Docker Compose configurations and READMEs for spinning up ChatQnA and GraphRAG services with external endpoints.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| GraphRAG/ui/svelte/src/lib/network/chat/Network.ts | Validates and injects LLM_MODEL_ID into text requests |
| GraphRAG/graphrag.py | Replaced prints with logger, skipped null chunks |
| GraphRAG/docker_compose/intel/* | Added LLM_MODEL_ID env and endpoint README/composes |
| ChatQnA/docker_compose/intel/cpu/xeon/compose_endpoint_openai.yaml | Swapped vLLM for an OpenAI-compatible textgen service |
| ChatQnA/chatqna.py | Added structured logging to alignment methods |
| GraphRAG/example_data/programming_languages{,2}.txt + README.md | Expanded example datasets and documentation |
Comments suppressed due to low confidence (3)
GraphRAG/graphrag.py:203
- Avoid bare
except:which catches all exceptions; specify the exception type to prevent masking unexpected errors.
except:
GraphRAG/graphrag.py:131
- The new JSON parsing logic in
align_generatorshould be covered by unit tests for TGI, OpenAI, and malformed chunks to prevent regressions.
def align_generator(self, gen, **kwargs):
GraphRAG/graphrag.py:141
- This
ifappears over-indented relative to its surrounding lines and may introduce a syntax error; verify the indentation block.
if start == -1 or end <= start:
| import time | ||
| import uuid | ||
| from typing import Dict, List, Union |
Copilot
AI
Jun 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The time, uuid, and typing imports are unused; consider removing them to reduce clutter.
| import time | |
| import uuid | |
| from typing import Dict, List, Union | |
| # Removed unused imports: time, uuid, typing |
| if (!env.LLM_MODEL_ID) { | ||
| throw new Error("LLM_MODEL_ID environment variable must be set"); | ||
| } | ||
| const LLM_MODEL_ID = env.LLM_MODEL_ID; | ||
|
|
||
| export async function fetchTextStream(query: string) { | ||
| let payload = {}; | ||
| let url = ""; | ||
|
|
Copilot
AI
Jun 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Throwing an error at module import may break SSR or bundling; consider checking LLM_MODEL_ID inside the fetchTextStream function or providing a fallback.
| if (!env.LLM_MODEL_ID) { | |
| throw new Error("LLM_MODEL_ID environment variable must be set"); | |
| } | |
| const LLM_MODEL_ID = env.LLM_MODEL_ID; | |
| export async function fetchTextStream(query: string) { | |
| let payload = {}; | |
| let url = ""; | |
| export async function fetchTextStream(query: string) { | |
| let payload = {}; | |
| let url = ""; | |
| const LLM_MODEL_ID = env.LLM_MODEL_ID || "default-model-id"; // Fallback value | |
| if (!env.LLM_MODEL_ID) { | |
| console.warn("LLM_MODEL_ID environment variable is not set. Using fallback value."); | |
| } |
| condition: service_started | ||
| tei-reranking-service: | ||
| condition: service_started | ||
| textgen-service-endpoint-openai: |
Copilot
AI
Jun 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] It would be helpful to add a healthcheck for the textgen-service-endpoint-openai to ensure the service is ready before backend startup.
…nAIExamples into chatqna_with_openai_endpoint
Signed-off-by: Ed Lee <[email protected]>
for more information, see https://pre-commit.ci
|
i mixed two branches together. going to make a clean PR. |
Description
Allows ChatQnA to be used with thousands of OpenAI-like endpoints e.g. OpenRouter.ai, Hugging Face, Denvr, and improve the developer experience to use OPEA quickly even on low resource environments (does not require spinning up a inference service).
Key Changes Made
Also:
align_generatorfunction to properly detect and skip chunks wherecontentisnullin open-ai like endpoints. Previously it'd show the null json in the UI.Issues
Type of change
List the type of change like below. Please delete options that are not relevant.
Dependencies
Tests
Tested on:
OpenRouter.ai: anthropic/claude-3.7-sonnet
Denvr: meta-llama/Llama-3.1-70B-Instruct