File tree Expand file tree Collapse file tree 4 files changed +25
-40
lines changed Expand file tree Collapse file tree 4 files changed +25
-40
lines changed Original file line number Diff line number Diff line change 1+ include gpt_server/script/*.yaml
Original file line number Diff line number Diff line change 1- import argparse
21import subprocess
32import os
3+ import typer
44
5+ app = typer .Typer ()
56root_dir = os .path .dirname (__file__ )
67root_dir = os .path .abspath (root_dir )
78chat_ui_path = os .path .join (root_dir , "serving" , "chat_ui.py" )
89server_ui_path = os .path .join (root_dir , "serving" , "server_ui.py" )
910
1011
11- def run ():
12- parser = argparse .ArgumentParser (description = "GPT Server CLI" )
13- parser .add_argument ("--chat_ui" , action = "store_true" , help = "启动问答UI界面" )
14- parser .add_argument ("--server_ui" , action = "store_true" , help = "启动服务UI界面" )
15- args = parser .parse_args ()
16- print (args )
17- if args .chat_ui :
18- cmd = f"streamlit run { chat_ui_path } "
19- subprocess .run (cmd , shell = True )
20- if args .server_ui :
12+ @app .command (help = "启动 GPT Server UI" )
13+ def ui (
14+ server : bool = typer .Option (False , help = "启动服务UI界面" ),
15+ chat : bool = typer .Option (False , help = "启动问答UI界面" ),
16+ ):
17+ if server :
2118 cmd = f"streamlit run { server_ui_path } "
2219 subprocess .run (cmd , shell = True )
20+ if chat :
21+ cmd = f"streamlit run { chat_ui_path } "
22+ subprocess .run (cmd , shell = True )
23+
24+
25+ def main ():
26+ app ()
2327
2428
2529if __name__ == "__main__" :
26- run ()
30+ main ()
Original file line number Diff line number Diff line change @@ -24,5 +24,10 @@ dependencies = [
2424 " vllm==0.6.3" ,
2525]
2626
27+
2728[project .scripts ]
28- gpt_server = " gpt_server.cli:run"
29+ gpt_server = " gpt_server.cli:main"
30+
31+ [build-system ]
32+ requires = [" setuptools" , " wheel" ]
33+ build-backend = " setuptools.build_meta"
Original file line number Diff line number Diff line change 11import os
2- import sys
3- import subprocess
42from setuptools import setup , find_packages
53from setuptools .command .install import install
64
97version_file = "gpt_server/version.py"
108
119
12- # 自定义安装类
13- class CustomInstallCommand (install ):
14- """自定义安装命令类,用于在安装过程中执行额外的脚本"""
15-
16- def run (self ):
17- # 调用父类的 run 方法
18- install .run (self )
19-
20- # 运行 Bash 脚本
21- script_path = os .path .join (os .path .dirname (__file__ ), "install.sh" )
22- if os .path .exists (script_path ):
23- print ("Running install_script.sh..." )
24- try :
25- subprocess .check_call (["/bin/bash" , script_path ])
26- except subprocess .CalledProcessError as e :
27- print (f"Error executing script { script_path } : { e } " )
28- sys .exit (1 )
29- else :
30- print (f"Script { script_path } not found!" )
31-
32-
3310def readme ():
3411 with open (os .path .join (pwd , "README.md" ), encoding = "utf-8" ) as f :
3512 content = f .read ()
@@ -51,9 +28,7 @@ def get_version():
5128 long_description_content_type = "text/markdown" ,
5229 author = "Yu Liu" ,
533054- packages = find_packages (exclude = ()),
31+ packages = find_packages (),
32+ include_package_data = True , # 确保包含 MANIFEST.in 中的文件
5533 # ... 其他 setup 参数 ...
56- cmdclass = {
57- "install" : CustomInstallCommand , # 关联自定义安装类
58- },
5934)
You can’t perform that action at this time.
0 commit comments