feiyun0112 / Gradio.Net

⭐Gradio for .NET – a port of Gradio, an open-source Python package that allows you to quickly build a demo or web application for your machine learning model, API, or any arbitrary Python function. Gradio for .NET – 基于 Gradio 的 .NET 移植,Gradio 是一个开源 Python 包,允许你为机器学习模型、API 或任何任意 Python 函数快速构建演示或 Web 应用程序。
Apache License 2.0
246 stars 31 forks source link

消息框不显示 #11

Open sangyuxiaowu opened 3 months ago

sangyuxiaowu commented 3 months ago

执行消息框提示后,如果不加入await Task.Delay(2000);将直接不显示消息框,如下:

static async Task<Output> change_models(Input input)
{
    var models = Utils.config?.Models?.Select(x => x.Name).ToList();
    if (models == null)
    {
        throw new Exception("Failed to fetch models from the server.");
    }

    string server = Textbox.Payload(input.Data[0]);
    string model = Dropdown.Payload(input.Data[1]).Single();
    if (server == "")
    {
        throw new Exception("Server URL cannot be empty.");
    }

    // 取得模型是第几个
    var index = models.IndexOf(model);
    if (index == -1)
    {
        throw new Exception("Model not found in the list of available models.");
    }
    if (Utils.config.Current == index)
    {
        // 没有切换模型
        return gr.Output(gr.Dropdown(choices: models, value: model, interactive: true));
    }
    var res = await Utils.client.PutAsync($"{server}/models/{index}/switch", null);
    // 请求失败
    if (!res.IsSuccessStatusCode)
    {
        // 错误信息未返回
        gr.Warning("Failed to switch model.");
       //await Task.Delay(2000);
        return gr.Output(gr.Dropdown(choices: models, value: models[Utils.config.Current], interactive: true));
    }
    Utils.config.Current = index;
    return gr.Output(gr.Dropdown(choices: models, value: model, interactive: true));
}
feiyun0112 commented 3 months ago

i cannot repeat it.

please provide reproduction solution

sangyuxiaowu commented 3 months ago

https://github.com/sangyuxiaowu/LLamaWorker/blob/1a23be24a4541e9c4e36c1a032c0b752cb00bb25/ChatUI/Program.cs#L144

feiyun0112 commented 3 months ago

gradio issue https://github.com/gradio-app/gradio/issues/8630