-
Notifications
You must be signed in to change notification settings - Fork 337
ChatQnA Example with OpenAI-Compatible Endpoint #2060
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
Conversation
Signed-off-by: Ed Lee <[email protected]>
Signed-off-by: Ed Lee <[email protected]>
…w null json. Also improved exception handling and logging Signed-off-by: Ed Lee <[email protected]>
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
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 enables ChatQnA to run against OpenAI-compatible endpoints via a new Docker Compose setup and enhances the core Python logic to better handle and log streaming responses.
- Added
compose_endpoint_openai.yamlfor spinning up ChatQnA with OPEA text-generation service backed by OpenAI-like endpoints. - Updated
chatqna.pyto improve logging, skip null-content chunks in the generator, and bolster error handling. - Fixed
align_generatorto filter out invalid or null JSON and added debug/error logs.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ChatQnA/docker_compose/intel/cpu/xeon/compose_endpoint_openai.yaml | New Compose file replacing vLLM with an OpenAI-compatible endpoint and related services. |
| ChatQnA/chatqna.py | Enhanced input/output alignment, added logging, and refactored align_generator. |
Comments suppressed due to low confidence (4)
ChatQnA/docker_compose/intel/cpu/xeon/compose_endpoint_openai.yaml:98
- [nitpick] Component name 'OpeaTextGenService' is inconsistent with other OPEA naming conventions; consider using uppercase 'OPEA' or aligning with existing style.
LLM_COMPONENT_NAME: OpeaTextGenService
ChatQnA/docker_compose/intel/cpu/xeon/compose_endpoint_openai.yaml:104
- [nitpick] The comment says 'Add OpenRouter API Key' but the variable is 'OPENAI_API_KEY'; clarify the env var or comment to avoid confusion.
OPENAI_API_KEY: ${OPENAI_API_KEY} # Add OpenRouter API Key
ChatQnA/docker_compose/intel/cpu/xeon/compose_endpoint_openai.yaml:166
- [nitpick] BACKEND_SERVICE_NAME 'chatqna' does not match the container name 'chatqna-xeon-backend-server'; consider aligning these to prevent misconfiguration.
- BACKEND_SERVICE_NAME=chatqna
ChatQnA/chatqna.py:189
- The updated
align_generatorlogic introduces new behaviors (skipping null content, error handling) but lacks corresponding unit tests; consider adding tests to cover these scenarios.
def align_generator(self, gen, **kwargs):
ChatQnA/docker_compose/intel/cpu/xeon/compose_endpoint_openai.yaml
Outdated
Show resolved
Hide resolved
…yaml Co-authored-by: Copilot <[email protected]>
5b9dbb2 to
be85abc
Compare
Signed-off-by: Ed Lee <[email protected]>
be85abc to
2b7715e
Compare
|
I accepted a Co-pilot commit but wouldn't let me sign the commit after that. Will create a new 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. Using endpoints would not require spinning up a inference service.
Key Changes Made:
Also:
Issues
Helps address issue:
Type of change
List the type of change like below. Please delete options that are not relevant.
Dependencies
No new third party dependencies, but uses recent updated textgen component:
https://github.com/opea-project/
GenAIComps/pull/1395 (the component was updated to filter null inputs. Some openai standard null inputs are disallowed by OpenRouter.ai).
Tests
Tested on:
OpenRouter.ai: anthropic/claude-3.7-sonnet
Denvr: meta-llama/Llama-3.1-70B-Instruct