-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
25 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include gpt_server/script/*.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
import argparse | ||
import subprocess | ||
import os | ||
import typer | ||
|
||
app = typer.Typer() | ||
root_dir = os.path.dirname(__file__) | ||
root_dir = os.path.abspath(root_dir) | ||
chat_ui_path = os.path.join(root_dir, "serving", "chat_ui.py") | ||
server_ui_path = os.path.join(root_dir, "serving", "server_ui.py") | ||
|
||
|
||
def run(): | ||
parser = argparse.ArgumentParser(description="GPT Server CLI") | ||
parser.add_argument("--chat_ui", action="store_true", help="启动问答UI界面") | ||
parser.add_argument("--server_ui", action="store_true", help="启动服务UI界面") | ||
args = parser.parse_args() | ||
print(args) | ||
if args.chat_ui: | ||
cmd = f"streamlit run {chat_ui_path}" | ||
subprocess.run(cmd, shell=True) | ||
if args.server_ui: | ||
@app.command(help="启动 GPT Server UI") | ||
def ui( | ||
server: bool = typer.Option(False, help="启动服务UI界面"), | ||
chat: bool = typer.Option(False, help="启动问答UI界面"), | ||
): | ||
if server: | ||
cmd = f"streamlit run {server_ui_path}" | ||
subprocess.run(cmd, shell=True) | ||
if chat: | ||
cmd = f"streamlit run {chat_ui_path}" | ||
subprocess.run(cmd, shell=True) | ||
|
||
|
||
def main(): | ||
app() | ||
|
||
|
||
if __name__ == "__main__": | ||
run() | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import os | ||
import sys | ||
import subprocess | ||
from setuptools import setup, find_packages | ||
from setuptools.command.install import install | ||
|
||
|
@@ -9,27 +7,6 @@ | |
version_file = "gpt_server/version.py" | ||
|
||
|
||
# 自定义安装类 | ||
class CustomInstallCommand(install): | ||
"""自定义安装命令类,用于在安装过程中执行额外的脚本""" | ||
|
||
def run(self): | ||
# 调用父类的 run 方法 | ||
install.run(self) | ||
|
||
# 运行 Bash 脚本 | ||
script_path = os.path.join(os.path.dirname(__file__), "install.sh") | ||
if os.path.exists(script_path): | ||
print("Running install_script.sh...") | ||
try: | ||
subprocess.check_call(["/bin/bash", script_path]) | ||
except subprocess.CalledProcessError as e: | ||
print(f"Error executing script {script_path}: {e}") | ||
sys.exit(1) | ||
else: | ||
print(f"Script {script_path} not found!") | ||
|
||
|
||
def readme(): | ||
with open(os.path.join(pwd, "README.md"), encoding="utf-8") as f: | ||
content = f.read() | ||
|
@@ -51,9 +28,7 @@ def get_version(): | |
long_description_content_type="text/markdown", | ||
author="Yu Liu", | ||
author_email="[email protected]", | ||
packages=find_packages(exclude=()), | ||
packages=find_packages(), | ||
include_package_data=True, # 确保包含 MANIFEST.in 中的文件 | ||
# ... 其他 setup 参数 ... | ||
cmdclass={ | ||
"install": CustomInstallCommand, # 关联自定义安装类 | ||
}, | ||
) |