Skip to content

Conversation

@chenyushuo
Copy link
Collaborator

Description

As the title says.

Currently, Tinker's OpenAI-compatible API implementation is still incomplete. Instead, we're using our custom self.chat() method to replicate the functionality of openai.OpenAI.chat.completions.create().

Once Tinker's API is fully implemented and stable, we plan to switch to using this official endpoint directly.

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has passed all tests
  • Docstrings have been added/updated in Google Style
  • Documentation has been updated
  • Code is ready for review

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @chenyushuo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces preliminary support for using the OpenAI client with the Tinker backend. It addresses the current incompleteness of Tinker's native OpenAI-compatible API by implementing a custom routing mechanism that directs OpenAI client chat completion requests to Tinker's internal chat method. This allows for immediate integration and testing of Tinker models via an OpenAI-like interface, with a clear path to transition to Tinker's official API once it becomes stable.

Highlights

  • Tinker Backend OpenAI Client Support: Implemented a mechanism to allow the OpenAI client to interact with the Tinker backend, even though Tinker's native OpenAI API is still in beta.
  • Custom Chat Method Integration: The OpenAI client's chat.completions.create method is temporarily overridden to call Tinker's custom self.chat() method, replicating the desired functionality.
  • Tinker-specific Test Suite: A new test class, TestTinkerAsyncAPIServer, was introduced to specifically validate the OpenAI client's interaction with the Tinker backend.
  • Configuration Enhancements: The configuration system now automatically sets auxiliary model engine types to 'tinker' when Tinker is enabled, ensuring consistent backend usage.
  • Model Wrapper Refinements: The ModelWrapper class was updated to dynamically retrieve model paths and API keys, and to handle Tinker-specific API call routing and history recording.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for the Tinker backend, including a custom implementation to work around Tinker's incomplete OpenAI-compatible API. The changes are extensive, touching model wrappers, configurations, and tests. The refactoring of the test setup is a good improvement for extensibility. However, I've identified a critical issue in the OpenAI client patching logic, significant code duplication, and a few other areas for improvement, such as removing leftover debug code and avoiding in-place modification of arguments. Addressing these points will enhance the code's robustness and maintainability.

@chenyushuo
Copy link
Collaborator Author

/unittest-module-common

@github-actions
Copy link

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
42 41 0 1 0 0 11m 53s

Skipped

Tests Status
tests/common/vllm_test.py::TestTinkerAsyncAPIServer::test_api_async skipped ⏭️

Tests

Test Name Status Flaky Duration
tests/common/config_test.py::TestConfig::test_all_examples_are_valid 36.7s
tests/common/config_test.py::TestConfig::test_chat_template_path 68ms
tests/common/config_test.py::TestConfig::test_config_flatten 30ms
tests/common/config_test.py::TestConfig::test_continue_from_checkpoint_is_valid 136ms
tests/common/config_test.py::TestConfig::test_default_workflow 66ms
tests/common/config_test.py::TestConfig::test_load_default_config 3.5s
tests/common/config_test.py::TestConfig::test_max_token_len_per_gpu_set_correctly 403ms
tests/common/config_test.py::TestConfig::test_optimizer_config_propagation 70ms
tests/common/config_test.py::TestConfig::test_update_config_from_ray_cluster 1.7s
tests/common/experience_test.py::TestEID::test_eid_properties 1ms
tests/common/experience_test.py::TestExperience::test_action_mask_and_logprobs_type 1ms
tests/common/experience_test.py::TestExperience::test_assertions 1ms
tests/common/experience_test.py::TestExperience::test_dpo_experience 1ms
tests/common/experience_test.py::TestExperience::test_gather 1ms
tests/common/experience_test.py::TestExperience::test_gather_with_token_level_reward 1ms
tests/common/experience_test.py::TestExperience::test_hf_datasets_conversion 13ms
tests/common/experience_test.py::TestExperience::test_multi_turn_experience 1ms
tests/common/experience_test.py::TestExperience::test_serialize_deserialize 1ms
tests/common/experience_test.py::TestExperience::test_single_turn_experience 1ms
tests/common/experience_test.py::TestExperience::test_to_dict 1ms
tests/common/experience_test.py::TestExperienceConversion::test_batch_conversion 1ms
tests/common/experience_test.py::TestExperienceConversion::test_dpo_experience_batch_conversion 1ms
tests/common/experience_test.py::TestExperienceConversion::test_experience_model_experience_conversion 1ms
tests/common/experience_test.py::TestExperienceConversion::test_gather_experiences_with_custom_fields 1ms
tests/common/experience_test.py::TestExperienceConversion::test_multiturn_experience_batch_converstion 1ms
tests/common/vllm_test.py::ModelWrapperTest_0::test_generate 1m 17s
tests/common/vllm_test.py::ModelWrapperTest_1::test_generate 1m 5s
tests/common/vllm_test.py::ModelWrapperTest_2::test_generate 34.3s
tests/common/vllm_test.py::TestModelLen_0::test_model_len 51.9s
tests/common/vllm_test.py::TestModelLen_1::test_model_len 21.8s
tests/common/vllm_test.py::TestModelLen_2::test_model_len 57.0s
tests/common/vllm_test.py::TestModelLenWithoutPromptTruncation::test_model_len 50.8s
tests/common/vllm_test.py::TestAPIServer::test_api 24.2s
tests/common/vllm_test.py::TestLogprobs::test_logprobs_api 21.8s
tests/common/vllm_test.py::TestAsyncAPIServer::test_api_async 24.5s
tests/common/vllm_test.py::TestTinkerAsyncAPIServer::test_api_async ⏭️ 1ms
tests/common/vllm_test.py::TestTokenizer::test_action_mask 278ms
tests/common/vllm_test.py::TestTokenizer::test_action_mask_with_tools 269ms
tests/common/vllm_test.py::TestAPIServerToolCall_0_deepseek_r1::test_api_tool_calls 53.0s
tests/common/vllm_test.py::TestAPIServerToolCall_1::test_api_tool_calls 22.3s
tests/common/vllm_test.py::TestSuperLongGeneration::test_generate 1m 25s
tests/common/vllm_test.py::TestTinkerAPI::test_tinker_api 1m 13s

Github Test Reporter by CTRF 💚

@pan-x-c pan-x-c merged commit 44e35a1 into modelscope:main Jan 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants