Skip to content

Feature: OpenAI-compatible endpoint for text generation #1395

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

Merged
merged 91 commits into from
Jun 12, 2025

Conversation

edlee123
Copy link
Contributor

@edlee123 edlee123 commented Mar 17, 2025

Description

This pull request introduces code and tests using OpeaTextGenService that can connect to any OpenAI style endpoint.
This allows devs a large choice of endpoints using openapi-like endpoints such as OpenRouter.ai. , and use OPEA with low resources

This PR updates OpeaTextGenService so it can connect with OpenAI-like endpoints from OpenRouter.ai (in addition to vLLM and TGI):

Key Changes:

  • OpenAI-like endpoints such as OpenRouter.ai disallows some inputs from being null e.g. top_p (omitting it is ok). The input in OpeaTextGenService.align_input previously passed None/null defaults from ChatCompletionRequest, LLMParamsDoc, SearchDoc defaults. This PR adds a method _filter_api_params to take care of null + not omitted inputs.
  • Added docker service , textgen-service-endpoint-openai, in the comps/llms/deployment/docker_compose/compose_text-generation.yaml file to make explicit use the use of OpeaTextGenService for openai-like endpoints.
  • Added unit test to test OpeaTextGenService can connect with API key to OpenAI-like API.

Issues

n/a

Type of change

List the type of change like below. Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds new functionality)
  • Breaking change (fix or feature that would break existing design and interface)
  • Others (enhancement, documentation, validation, etc.)

Dependencies

n/a

Tests

tests/llms/test_llms_textgen_endpoint_openai.sh

This spins up a vllm endpoint, and then tests the connection with a token to the openAI style endpoint using OpeaTextGenService .

@edlee123 edlee123 mentioned this pull request Mar 19, 2025
4 tasks
@edlee123
Copy link
Contributor Author

Related to #1399 , so the opea microservice can have the api key.

@xiguiw xiguiw added the A0 need to scrub label Mar 26, 2025
@xiguiw
Copy link
Collaborator

xiguiw commented Mar 26, 2025

@edlee123

I am afraid CI cannot verify the OPENAI API without api Key.

@chensuyue
How do we process such case?

@chensuyue
Copy link
Collaborator

@edlee123

I am afraid CI cannot verify the OPENAI API without api Key.

@chensuyue How do we process such case?

Yes, we don't have this key for CI test.

@chensuyue
Copy link
Collaborator

Know issues:
textgen-native-phi4-gaudi #1760
llms_text-generation_service_vllm_on_intel_hpu #1769

@edlee123
Copy link
Contributor Author

edlee123 commented Jun 4, 2025

Know issues: textgen-native-phi4-gaudi #1760 llms_text-generation_service_vllm_on_intel_hpu #1769

Thank you!

@edlee123 edlee123 requested a review from Spycsh as a code owner June 4, 2025 15:43
Copy link

codecov bot commented Jun 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
comps/cores/proto/api_protocol.py 92.11% <100.00%> (+0.03%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@edlee123
Copy link
Contributor Author

edlee123 commented Jun 5, 2025

HI @ftian1 and @lkk12014402 thank you for the review. I think there would be three tests that fail because of these known issues:

textgen-native-phi4-gaudi #1760
llms_text-generation_service_vllm_on_intel_hpu #1769

Would it be ok to merge this PR (unrelated to above issues)?

@edlee123 edlee123 requested review from ftian1 and lkk12014402 June 5, 2025 23:17
@joshuayao joshuayao added this to OPEA Jun 6, 2025
@joshuayao joshuayao added this to the v1.4 milestone Jun 6, 2025
@joshuayao joshuayao moved this to In review in OPEA Jun 6, 2025
@chickenrae chickenrae self-requested a review June 9, 2025 19:52
@chickenrae chickenrae merged commit 2eaa3a5 into opea-project:main Jun 12, 2025
24 of 27 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in OPEA Jun 12, 2025
@edlee123
Copy link
Contributor Author

Thank you all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A0 need to scrub
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.