This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes several changes to improve the readability, maintainability, and functionality of the
python_enginemodule. The most important changes include the introduction of a newStreamWriteCallbackfunction, renaming and refactoring of certain functions and variables, and updates to the handling of process management.Improvements to readability and maintainability:
WriteCallbackfunction toStreamWriteCallbackand moved it inside an anonymous namespace for better encapsulation.constructWindowsCommandLinetoConstructWindowsCommandLine,cmdLinetocmd_line, andprocessMaptoprocess_map_. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17]Process management improvements:
PythonEngine::GetModelConfigmethod to retrieve model configurations using a shared lock for thread safety.PythonEngine::SpawnProcessto handle process creation for both Windows and POSIX systems, including proper handling of command line arguments and process IDs. [1] [2]PythonEngine::TerminateModelProcessmethod to correctly handle process termination and resource cleanup. [1] [2]Additional enhancements:
PythonEngine::HandleChatCompletionmethod to log a warning message indicating that the feature is not yet supported.PythonEngine::HandleInferenceto ensure the presence of required fields in the JSON body. [1] [2]StreamContextstruct and related callback function within thepython_enginenamespace for better code organization.These changes collectively enhance the robustness and clarity of the
python_enginemodule, making it easier to maintain and extend in the future.## Describe Your ChangesFixes Issues
Self Checklist