Skip to content

Conversation

@nv-guomingz
Copy link
Collaborator

@nv-guomingz nv-guomingz commented Jul 28, 2025

It's a supplement PR of #6321.

  • Add a example as part of online serving example,
  • Remove the useless code of test case for json schema feature.

Summary by CodeRabbit

  • New Features

    • Added a new example script demonstrating chat completions with JSON schema response format using the OpenAI Python client.
  • Tests

    • Removed an unused asynchronous client fixture from the test suite.
    • Expanded test coverage by adding the new example script to existing test cases.

@nv-guomingz nv-guomingz requested review from LinPoly and syuoni July 28, 2025 16:23
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 28, 2025

📝 Walkthrough

"""

Walkthrough

A new example script demonstrating the use of the OpenAI Python client with a JSON schema response format was added. Additionally, a pytest fixture for an asynchronous client was removed from a test file, and a test function was updated to include the new example script in its parameterization.

Changes

Cohort / File(s) Change Summary
New Example Script
examples/serve/openai_completion_client_json_schema.py
Added a script showing how to use the OpenAI client to request chat completions with a specified JSON schema.
Test Fixture Removal
tests/unittest/llmapi/apps/_test_openai_chat_json.py
Removed the async_client pytest fixture; no other test or fixture changes were made.
Test Parameter Update
tests/unittest/llmapi/apps/_test_trtllm_serve_example.py
Updated test_trtllm_serve_examples parameterization to include the new example script for testing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

Community want to contribute

Suggested reviewers

  • litaotju
  • hchings
  • Superjomn
    """

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6bed9d2 and 8c50fe7.

📒 Files selected for processing (3)
  • examples/serve/openai_completion_client_json_schema.py (1 hunks)
  • tests/unittest/llmapi/apps/_test_openai_chat_json.py (0 hunks)
  • tests/unittest/llmapi/apps/_test_trtllm_serve_example.py (1 hunks)
💤 Files with no reviewable changes (1)
  • tests/unittest/llmapi/apps/_test_openai_chat_json.py
✅ Files skipped from review due to trivial changes (1)
  • examples/serve/openai_completion_client_json_schema.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/unittest/llmapi/apps/_test_trtllm_serve_example.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai bot requested review from hchings and litaotju July 28, 2025 16:23
@coderabbitai coderabbitai bot added the Doc <NV>TRTLLM's textual/illustrative materials: API refs, guides, tutorials. Improvement & clarity. label Jul 28, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
examples/serve/openai_completion_client_json_schema.py (2)

16-17: Fix unnecessary line break in role assignment.

The line break between "role": and "user" is unnecessary and affects readability.

-        "role":
-        "user",
+        "role": "user",

19-19: Remove unnecessary f-string formatting.

The f-string is unnecessary since no variables are being formatted into the string.

-        f"Give me the information of the biggest city of China in the JSON format.",
+        "Give me the information of the biggest city of China in the JSON format.",
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4904473 and a8c6819.

📒 Files selected for processing (2)
  • examples/serve/openai_completion_client_json_schema.py (1 hunks)
  • tests/unittest/llmapi/apps/_test_openai_chat_json.py (0 hunks)
💤 Files with no reviewable changes (1)
  • tests/unittest/llmapi/apps/_test_openai_chat_json.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

**/*.py: Python code should conform to Python 3.8+.
Indent Python code with 4 spaces. Do not use tabs.
Always maintain the namespace when importing in Python, even if only one class or function from a module is used.
Python filenames should use snake_case (e.g., some_file.py).
Python classes should use PascalCase (e.g., class SomeClass).
Python functions and methods should use snake_case (e.g., def my_awesome_function():).
Python local variables should use snake_case, and prefix k for variable names that start with a number (e.g., k_99th_percentile).
Python global variables should use upper snake_case and prefix G (e.g., G_MY_GLOBAL).
Python constants should use upper snake_case (e.g., MY_CONSTANT).
Avoid shadowing variables declared in an outer scope in Python.
Initialize all externally visible members of a Python class in the constructor.
For interfaces that may be used outside a Python file, prefer docstrings over comments.
Comments in Python should be reserved for code within a function, or interfaces that are local to a file.
Use Google style docstrings for Python classes and functions, which can be parsed by Sphinx.
Attributes and variables in Python can be documented inline; attribute docstrings will be rendered under the docstring for the class.
Avoid using reflection in Python when functionality can be easily achieved without it.
When using try-except blocks in Python, limit the except to the smallest set of errors possible.
When using try-except blocks to handle multiple possible variable types in Python, keep the body of the try as small as possible, using the else block to implement the logic.

Files:

  • examples/serve/openai_completion_client_json_schema.py
**/*.{cpp,h,hpp,cc,cxx,cu,py}

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

All TensorRT-LLM Open Source Software code should contain an NVIDIA copyright header that includes the current year. This includes .cpp, .h, .cu, .py, and any other source files which are compiled or interpreted.

Files:

  • examples/serve/openai_completion_client_json_schema.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check
🔇 Additional comments (3)
examples/serve/openai_completion_client_json_schema.py (3)

3-8: LGTM! Proper import and client setup for example.

The import follows namespace preservation guidelines, and the client initialization uses appropriate example values for demonstration purposes.


23-40: Well-structured JSON schema demonstration.

The JSON schema configuration effectively demonstrates the feature with a clear object structure, required fields, and TensorRT-LLM specific chat template options.


42-42: LGTM! Appropriate response handling for example.

The response output follows the standard OpenAI client pattern and is suitable for this demonstration script.

@nv-guomingz
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13221 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13221 [ run ] completed with state FAILURE

@nv-guomingz nv-guomingz force-pushed the user/guomingz/update_trtllm-serve_doc branch from a8c6819 to 1861014 Compare July 29, 2025 02:06
@nv-guomingz
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13270 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13270 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #9909 completed with status: 'FAILURE'

@nv-guomingz nv-guomingz force-pushed the user/guomingz/update_trtllm-serve_doc branch from 1861014 to 2bd193b Compare July 29, 2025 04:00
@nv-guomingz
Copy link
Collaborator Author

/bot run

@coderabbitai coderabbitai bot requested a review from litaotju July 29, 2025 04:01
@tensorrt-cicd
Copy link
Collaborator

PR_Github #13286 [ run ] triggered by Bot

Copy link
Collaborator

@LinPoly LinPoly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add this example to our CI? Like what we do in this file.

@nv-guomingz
Copy link
Collaborator Author

Is it possible to add this example to our CI? Like what we do in this file.

Sure, let me update the code.

@nv-guomingz nv-guomingz force-pushed the user/guomingz/update_trtllm-serve_doc branch from 2bd193b to ecc6650 Compare July 29, 2025 08:37
@tensorrt-cicd
Copy link
Collaborator

PR_Github #13286 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #9924 completed with status: 'FAILURE'

@nv-guomingz nv-guomingz force-pushed the user/guomingz/update_trtllm-serve_doc branch from ecc6650 to a873f32 Compare July 29, 2025 15:05
@coderabbitai coderabbitai bot requested a review from Superjomn July 29, 2025 15:06
@nv-guomingz nv-guomingz force-pushed the user/guomingz/update_trtllm-serve_doc branch from a873f32 to 1dabd0a Compare July 29, 2025 15:41
@nv-guomingz
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13384 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13384 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #10010 completed with status: 'FAILURE'

@nv-guomingz nv-guomingz force-pushed the user/guomingz/update_trtllm-serve_doc branch from 1dabd0a to 6bed9d2 Compare July 30, 2025 05:01
@coderabbitai coderabbitai bot requested a review from QiJune July 30, 2025 05:02
@nv-guomingz
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13483 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13483 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #10097 completed with status: 'SUCCESS'

@nv-guomingz nv-guomingz force-pushed the user/guomingz/update_trtllm-serve_doc branch from 6bed9d2 to 8c50fe7 Compare July 30, 2025 08:10
@nv-guomingz nv-guomingz enabled auto-merge (squash) July 30, 2025 08:10
@nv-guomingz
Copy link
Collaborator Author

/bot reuse-pipeline

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13512 [ reuse-pipeline ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13512 [ reuse-pipeline ] completed with state SUCCESS
Reusing PR_Github #13483 for commit 8c50fe7

@nv-guomingz nv-guomingz merged commit a5540ac into NVIDIA:main Jul 30, 2025
3 checks passed
lancelly pushed a commit to lancelly/TensorRT-LLM that referenced this pull request Aug 6, 2025
jain-ria pushed a commit to jain-ria/TensorRT-LLM that referenced this pull request Aug 7, 2025
@nv-guomingz nv-guomingz deleted the user/guomingz/update_trtllm-serve_doc branch September 30, 2025 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Doc <NV>TRTLLM's textual/illustrative materials: API refs, guides, tutorials. Improvement & clarity.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants