mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-09-27 04:46:16 +08:00
[Feature] add config api (#4254)
This commit is contained in:
@@ -73,7 +73,7 @@ class ServeSubcommand(CLISubcommand):
|
|||||||
name=self.name,
|
name=self.name,
|
||||||
help="Start the FastDeploy OpenAI Compatible API server.",
|
help="Start the FastDeploy OpenAI Compatible API server.",
|
||||||
description="Start the FastDeploy OpenAI Compatible API server.",
|
description="Start the FastDeploy OpenAI Compatible API server.",
|
||||||
usage="fastdeploy serve [model_tag] [options]",
|
usage="fastdeploy serve [options]",
|
||||||
)
|
)
|
||||||
serve_parser = make_arg_parser(serve_parser)
|
serve_parser = make_arg_parser(serve_parser)
|
||||||
serve_parser.add_argument("--config", help="Read CLI options from a config file. Must be a YAML file")
|
serve_parser.add_argument("--config", help="Read CLI options from a config file. Must be a YAML file")
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
@@ -50,6 +51,7 @@ from fastdeploy.entrypoints.openai.serving_completion import OpenAIServingComple
|
|||||||
from fastdeploy.entrypoints.openai.serving_models import ModelPath, OpenAIServingModels
|
from fastdeploy.entrypoints.openai.serving_models import ModelPath, OpenAIServingModels
|
||||||
from fastdeploy.entrypoints.openai.tool_parsers import ToolParserManager
|
from fastdeploy.entrypoints.openai.tool_parsers import ToolParserManager
|
||||||
from fastdeploy.entrypoints.openai.utils import UVICORN_CONFIG, make_arg_parser
|
from fastdeploy.entrypoints.openai.utils import UVICORN_CONFIG, make_arg_parser
|
||||||
|
from fastdeploy.envs import environment_variables
|
||||||
from fastdeploy.metrics.metrics import (
|
from fastdeploy.metrics.metrics import (
|
||||||
EXCLUDE_LABELS,
|
EXCLUDE_LABELS,
|
||||||
cleanup_prometheus_files,
|
cleanup_prometheus_files,
|
||||||
@@ -439,6 +441,29 @@ async def metrics():
|
|||||||
return Response(metrics_text, media_type=CONTENT_TYPE_LATEST)
|
return Response(metrics_text, media_type=CONTENT_TYPE_LATEST)
|
||||||
|
|
||||||
|
|
||||||
|
@metrics_app.get("/config-info")
|
||||||
|
def config_info() -> Response:
|
||||||
|
"""
|
||||||
|
Get the current configuration of the API server.
|
||||||
|
"""
|
||||||
|
global llm_engine
|
||||||
|
if llm_engine is None:
|
||||||
|
return Response("Engine not loaded", status_code=500)
|
||||||
|
cfg = llm_engine.cfg
|
||||||
|
|
||||||
|
def process_object(obj):
|
||||||
|
if hasattr(obj, "__dict__"):
|
||||||
|
# 处理有__dict__属性的对象
|
||||||
|
return obj.__dict__
|
||||||
|
return None # 或其他默认处理
|
||||||
|
|
||||||
|
cfg_dict = {k: v for k, v in cfg.__dict__.items()}
|
||||||
|
env_dict = {k: v() for k, v in environment_variables.items()}
|
||||||
|
cfg_dict["env_config"] = env_dict
|
||||||
|
result_content = json.dumps(cfg_dict, default=process_object, ensure_ascii=False)
|
||||||
|
return Response(result_content, media_type="application/json")
|
||||||
|
|
||||||
|
|
||||||
def run_metrics_server():
|
def run_metrics_server():
|
||||||
"""
|
"""
|
||||||
run metrics server
|
run metrics server
|
||||||
|
@@ -239,6 +239,13 @@ def headers():
|
|||||||
return {"Content-Type": "application/json"}
|
return {"Content-Type": "application/json"}
|
||||||
|
|
||||||
|
|
||||||
|
def test_metrics_config(metrics_url):
|
||||||
|
timeout = 600
|
||||||
|
url = metrics_url.replace("metrics", "config-info")
|
||||||
|
res = requests.get(url, timeout=timeout)
|
||||||
|
assert res.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
def send_request(url, payload, timeout=600):
|
def send_request(url, payload, timeout=600):
|
||||||
"""
|
"""
|
||||||
发送请求到指定的URL,并返回响应结果。
|
发送请求到指定的URL,并返回响应结果。
|
||||||
|
Reference in New Issue
Block a user