update server build method
This commit is contained in:
@@ -11,6 +11,16 @@ def opt_to_config(save_path:str, *nargs):
|
|||||||
subprocess.run(["python", "--save-path", save_path, *nargs])
|
subprocess.run(["python", "--save-path", save_path, *nargs])
|
||||||
|
|
||||||
|
|
||||||
|
def _build_and_load_pipeline_config(pipeline_id: str,
|
||||||
|
pipeline_config_dir: str,
|
||||||
|
cmd: List[str]):
|
||||||
|
save_config_f = osp.join(pipeline_config_dir, f"{pipeline_id}.yml")
|
||||||
|
opt_to_config(save_config_f, *cmd)
|
||||||
|
|
||||||
|
# TODO: think if returning the built pipeline is better or just the config obj for front_api
|
||||||
|
return load_tyro_conf(save_config_f)
|
||||||
|
|
||||||
|
|
||||||
def update_pipeline_registry(pipeline_id:str,
|
def update_pipeline_registry(pipeline_id:str,
|
||||||
prompt_set:str,
|
prompt_set:str,
|
||||||
registry_f:str="configs/pipeline_registry.json"):
|
registry_f:str="configs/pipeline_registry.json"):
|
||||||
@@ -30,40 +40,6 @@ def update_pipeline_registry(pipeline_id:str,
|
|||||||
json.dump(registry, f, indent=4)
|
json.dump(registry, f, indent=4)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# def build_route(pipeline_id:str,
|
|
||||||
# prompt_set:str,
|
|
||||||
# tool_keys:List[str],
|
|
||||||
# port:str,
|
|
||||||
# api_key: str,
|
|
||||||
# fast_auth_keys: Optional[str] = None,
|
|
||||||
# entry_pnt:str="fastapi_server/server_dashscope.py",
|
|
||||||
# llm_name:str="qwen-plus"):
|
|
||||||
# cmd = [
|
|
||||||
# "python", entry_pnt,
|
|
||||||
# "--port", str(port),
|
|
||||||
# "route", # ------------
|
|
||||||
# "--llm-name", llm_name,
|
|
||||||
# "--api-key", api_key,
|
|
||||||
# "--pipeline-id", pipeline_id,
|
|
||||||
# "--prompt-set-id", prompt_set,
|
|
||||||
# "tool_node", # ------------
|
|
||||||
# "--llm-name", llm_name,
|
|
||||||
# "--api-key", api_key,
|
|
||||||
# "--pipeline-id", pipeline_id,
|
|
||||||
# "--prompt-set-id", prompt_set,
|
|
||||||
# ]
|
|
||||||
# if tool_keys:
|
|
||||||
# cmd.extend(
|
|
||||||
# ["--tool-manager-config.client-tool-manager.tool-keys", *tool_keys]
|
|
||||||
# )
|
|
||||||
# env: Dict[str, str] = os.environ.copy()
|
|
||||||
# if fast_auth_keys:
|
|
||||||
# env["FAST_AUTH_KEYS"] = fast_auth_keys
|
|
||||||
# sv_prc = subprocess.Popen(cmd, env=env)
|
|
||||||
|
|
||||||
# return sv_prc, f"http://127.0.0.1:{port}/api/"
|
|
||||||
|
|
||||||
def build_route(pipeline_id:str,
|
def build_route(pipeline_id:str,
|
||||||
prompt_set:str,
|
prompt_set:str,
|
||||||
tool_keys:List[str],
|
tool_keys:List[str],
|
||||||
@@ -90,26 +66,18 @@ def build_route(pipeline_id:str,
|
|||||||
["--tool-manager-config.client-tool-manager.tool-keys", *tool_keys]
|
["--tool-manager-config.client-tool-manager.tool-keys", *tool_keys]
|
||||||
)
|
)
|
||||||
|
|
||||||
save_config_f = osp.join(pipeline_config_dir, f"{pipeline_id}.yml")
|
return _build_and_load_pipeline_config(pipeline_id, pipeline_config_dir, cmd)
|
||||||
opt_to_config(save_config_f, *cmd)
|
|
||||||
|
|
||||||
# TODO: think if returning the built pipeline is better or just the config obj for front_api
|
|
||||||
return load_tyro_conf(save_config_f)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def build_react(pipeline_id:str,
|
def build_react(pipeline_id:str,
|
||||||
prompt_set:str,
|
prompt_set:str,
|
||||||
tool_keys:List[str],
|
tool_keys:List[str],
|
||||||
port:str,
|
|
||||||
api_key: str,
|
api_key: str,
|
||||||
fast_auth_keys: Optional[str] = None,
|
|
||||||
entry_pnt:str="fastapi_server/server_dashscope.py",
|
entry_pnt:str="fastapi_server/server_dashscope.py",
|
||||||
llm_name:str="qwen-plus"):
|
llm_name:str="qwen-plus",
|
||||||
|
pipeline_config_dir="configs/pipelines"):
|
||||||
cmd = [
|
cmd = [
|
||||||
"python", entry_pnt,
|
"python", entry_pnt,
|
||||||
"--port", str(port),
|
|
||||||
"react", # ------------
|
"react", # ------------
|
||||||
"--llm-name", llm_name,
|
"--llm-name", llm_name,
|
||||||
"--api-key", api_key,
|
"--api-key", api_key,
|
||||||
@@ -120,12 +88,9 @@ def build_react(pipeline_id:str,
|
|||||||
cmd.extend(
|
cmd.extend(
|
||||||
["--tool-manager-config.client-tool-manager.tool-keys", *tool_keys]
|
["--tool-manager-config.client-tool-manager.tool-keys", *tool_keys]
|
||||||
)
|
)
|
||||||
env: Dict[str, str] = os.environ.copy()
|
|
||||||
if fast_auth_keys:
|
|
||||||
env["FAST_AUTH_KEYS"] = fast_auth_keys
|
|
||||||
sv_prc = subprocess.Popen(cmd, env=env)
|
|
||||||
|
|
||||||
return sv_prc, f"http://127.0.0.1:{port}/api/"
|
return _build_and_load_pipeline_config(pipeline_id, pipeline_config_dir, cmd)
|
||||||
|
|
||||||
|
|
||||||
# {pipeline_id: build_function}
|
# {pipeline_id: build_function}
|
||||||
GRAPH_BUILD_FNCS = {
|
GRAPH_BUILD_FNCS = {
|
||||||
|
|||||||
Reference in New Issue
Block a user