feat(frontend): 添加了设置页面的api provider展示
This commit is contained in:
@@ -1,9 +1,35 @@
|
||||
import gradio as gr
|
||||
from typing import List, Dict
|
||||
from sqlmodel import Session, select
|
||||
from db import get_engine
|
||||
from schema import APIProvider
|
||||
import os
|
||||
|
||||
# 获取数据库引擎
|
||||
engine = get_engine(os.path.join(os.path.dirname(__file__), "..", "workdir"))
|
||||
|
||||
def setting_page():
|
||||
def get_providers() -> List[List[str]]:
|
||||
with Session(engine) as session:
|
||||
providers = session.exec(select(APIProvider)).all()
|
||||
return [
|
||||
[p.id, p.model_id, p.base_url, p.api_key or ""]
|
||||
for p in providers
|
||||
]
|
||||
|
||||
with gr.Blocks() as demo:
|
||||
gr.Markdown("## 设置")
|
||||
gr.Markdown("## API Provider 管理")
|
||||
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
pass
|
||||
# API Provider列表
|
||||
with gr.Column(scale=2):
|
||||
provider_table = gr.DataFrame(
|
||||
headers=["id" , "model id", "URL", "API Key"],
|
||||
datatype=["number","str", "str", "str"],
|
||||
interactive=True,
|
||||
value=get_providers(),
|
||||
wrap=True,
|
||||
col_count=(4, "fixed")
|
||||
)
|
||||
|
||||
return demo
|
Reference in New Issue
Block a user