Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Conversation

@vansangpfiev
Copy link
Contributor

This pull request includes several changes to improve the readability, maintainability, and functionality of the python_engine module. The most important changes include the introduction of a new StreamWriteCallback function, renaming and refactoring of certain functions and variables, and updates to the handling of process management.

Improvements to readability and maintainability:

  • Refactored the WriteCallback function to StreamWriteCallback and moved it inside an anonymous namespace for better encapsulation.
  • Renamed variables and functions to follow consistent naming conventions, such as constructWindowsCommandLine to ConstructWindowsCommandLine, cmdLine to cmd_line, and processMap to process_map_. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17]

Process management improvements:

  • Added the PythonEngine::GetModelConfig method to retrieve model configurations using a shared lock for thread safety.
  • Updated PythonEngine::SpawnProcess to handle process creation for both Windows and POSIX systems, including proper handling of command line arguments and process IDs. [1] [2]
  • Improved the PythonEngine::TerminateModelProcess method to correctly handle process termination and resource cleanup. [1] [2]

Additional enhancements:

  • Implemented the PythonEngine::HandleChatCompletion method to log a warning message indicating that the feature is not yet supported.
  • Added checks and error handling in PythonEngine::HandleInference to ensure the presence of required fields in the JSON body. [1] [2]
  • Encapsulated the StreamContext struct and related callback function within the python_engine namespace for better code organization.

These changes collectively enhance the robustness and clarity of the python_engine module, making it easier to maintain and extend in the future.## Describe Your Changes

Fixes Issues

  • Closes #
  • Closes #

Self Checklist

  • Added relevant comments, esp in complex areas
  • Updated docs (for bug fixes / features)
  • Created issues for follow-up changes or refactoring needed

@vansangpfiev vansangpfiev marked this pull request as ready for review January 10, 2025 08:14
@vansangpfiev vansangpfiev merged commit c6f86fd into dev Jan 17, 2025
6 checks passed
@vansangpfiev vansangpfiev deleted the chore/python-engine branch January 17, 2025 05:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants