import gradio as gr
import train
from frontend import *
from db import initialize_sqlite_db, initialize_prompt_store
from global_var import init_global_var, get_sql_engine, get_prompt_store

if __name__ == "__main__":
    init_global_var()
    initialize_sqlite_db(get_sql_engine())
    initialize_prompt_store(get_prompt_store())
    with gr.Blocks() as app:
        gr.Markdown("# 基于文档驱动的自适应编码大模型微调框架")
        with gr.Tabs():
            with gr.TabItem("模型管理"):
                model_manage_page()
            with gr.TabItem("模型推理"):
                chat_page()
            with gr.TabItem("模型微调"):
                train_page()
            with gr.TabItem("数据集生成"):
                dataset_generate_page()
            with gr.TabItem("数据集管理"):
                dataset_manage_page()
            with gr.TabItem("提示词模板管理"):
                prompt_manage_page()
            with gr.TabItem("设置"):
                setting_page()
    
    app.launch(server_name="0.0.0.0")