fastdeploy.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import sys
  15. from ....utils.deps import require_genai_engine_plugin
  16. from ..configs.utils import (
  17. backend_config_to_args,
  18. set_config_defaults,
  19. update_backend_config,
  20. )
  21. def run_fastdeploy_server(
  22. host, port, model_name, model_dir, config, chat_template_path
  23. ):
  24. require_genai_engine_plugin("fastdeploy-server")
  25. if chat_template_path:
  26. set_config_defaults(config, {"chat-template": str(chat_template_path)})
  27. update_backend_config(
  28. config,
  29. {
  30. "model": model_dir,
  31. "host": host,
  32. "port": port,
  33. },
  34. )
  35. args = backend_config_to_args(config)
  36. sys.argv[1:] = args
  37. from fastdeploy.entrypoints.openai.api_server import main as run
  38. run()