Skip to content

[Bug]: 调用Ollama模型在回复过程中无法取消终止回复 #1171

@GuokaiLiu

Description

@GuokaiLiu

这个bug是否已存在现有issue了?

  • 我确认没有已有issue,且已阅读常见问题

错误表现

如图,在调用Ollama的过程中,无法点击右下角红色的按钮,停止模型的回复。

image

复现操作

  1. 正常部署模型

错误日志

不会报错,但对话窗口会卡住,直到模型全部回复结束

运行环境

  • OS: RHEL 8.8
  • Browser: Edge
  • Gradio version: 4.29.0
  • Python version: 3.10

帮助解决

  • 我愿意协助解决!

补充说明

config.json

{
// 各配置具体说明,见 [https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#配置-configjson]

//== API 配置 ==
// ⭐️ 这里填写的Ollama
"openai_api_key": "Ollama", // 你的 OpenAI API Key,一般必填,若空缺则需在图形界面中填入API Key
"google_genai_api_key": "", // 你的 Google Gemini API Key ,用于 Google Gemini 对话模型
"xmchat_api_key": "", // 你的 xmchat API Key,用于 XMChat 对话模型
"minimax_api_key": "", // 你的 MiniMax API Key,用于 MiniMax 对话模型
"minimax_group_id": "", // 你的 MiniMax Group ID,用于 MiniMax 对话模型
"midjourney_proxy_api_base": "https://xxx/mj", // 你的 https://github.com/novicezk/midjourney-proxy 代理地址
"midjourney_proxy_api_secret": "", // 你的 MidJourney Proxy API Secret,用于鉴权访问 api,可选
"midjourney_discord_proxy_url": "", // 你的 MidJourney Discord Proxy URL,用于对生成对图进行反代,可选
"midjourney_temp_folder": "./tmp", // 你的 MidJourney 临时文件夹,用于存放生成的图片,填空则关闭自动下载切图(直接显示MJ的四宫格图)
"spark_appid": "", // 你的 讯飞星火大模型 API AppID,用于讯飞星火大模型对话模型
"spark_api_key": "", // 你的 讯飞星火大模型 API Key,用于讯飞星火大模型对话模型
"spark_api_secret": "", // 你的 讯飞星火大模型 API Secret,用于讯飞星火大模型对话模型
"claude_api_secret":"",// 你的 Claude API Secret,用于 Claude 对话模型
"ernie_api_key": "",// 你的文心一言在百度云中的API Key,用于文心一言对话模型
"ernie_secret_key": "",// 你的文心一言在百度云中的Secret Key,用于文心一言对话模型
"ollama_host": "", // 你的 Ollama Host,用于 Ollama 对话模型
"huggingface_auth_token": "", // 你的 Hugging Face API Token,用于访问有限制的模型
"groq_api_key": "", // 你的 Groq API Key,用于 Groq 对话模型(https://console.groq.com/)

//== Azure ==
"openai_api_type": "openai", // 可选项:azure, openai
"azure_openai_api_key": "", // 你的 Azure OpenAI API Key,用于 Azure OpenAI 对话模型
"azure_openai_api_base_url": "", // 你的 Azure Base URL
"azure_openai_api_version": "2023-05-15", // 你的 Azure OpenAI API 版本
"azure_deployment_name": "", // 你的 Azure OpenAI Chat 模型 Deployment 名称
"azure_embedding_deployment_name": "", // 你的 Azure OpenAI Embedding 模型 Deployment 名称
"azure_embedding_model_name": "text-embedding-ada-002", // 你的 Azure OpenAI Embedding 模型名称

//== 基础配置 ==
"language": "auto", // 界面语言,可选"auto", "zh_CN", "en_US", "ja_JP", "ko_KR", "sv_SE", "ru_RU", "vi_VN"
"users": [], // 用户列表,[["用户名1", "密码1"], ["用户名2", "密码2"], ...]
"local_embedding": false, //是否在本地编制索引
"hide_history_when_not_logged_in": false, //未登录情况下是否不展示对话历史
"check_update": true, //是否启用检查更新
"default_model": "Ollama", // 默认模型
"chat_name_method_index": 2, // 选择对话名称的方法。0: 使用日期时间命名;1: 使用第一条提问命名,2: 使用模型自动总结
"bot_avatar": "default", // 机器人头像,可填写本地或网络图片链接,或者"none"(不显示头像)
"user_avatar": "default", // 用户头像,可填写本地或网络图片链接,或者"none"(不显示头像)

//== API 用量 ==
"show_api_billing": false, //是否显示OpenAI API用量(启用需要填写sensitive_id)
"sensitive_id": "", // 你 OpenAI 账户的 Sensitive ID,用于查询 API 用量
"usage_limit": 120, // 该 OpenAI API Key 的当月限额,单位:美元,用于计算百分比和显示上限
"legacy_api_usage": false, // 是否使用旧版 API 用量查询接口(OpenAI现已关闭该接口,但是如果你在使用第三方 API,第三方可能仍然支持此接口)

//== 川虎助理设置 ==
"GOOGLE_CSE_ID": "", //谷歌搜索引擎ID,用于川虎助理Pro模式,获取方式请看 https://stackoverflow.com/questions/37083058/programmatically-searching-google-in-python-using-custom-search
"GOOGLE_API_KEY": "", //谷歌API Key,用于川虎助理Pro模式
"WOLFRAM_ALPHA_APPID": "", //Wolfram Alpha API Key,用于川虎助理Pro模式,获取方式请看 https://products.wolframalpha.com/api/
"SERPAPI_API_KEY": "", //SerpAPI API Key,用于川虎助理Pro模式,获取方式请看 https://serpapi.com/

//== 文档处理与显示 ==
"latex_option": "default", // LaTeX 公式渲染策略,可选"default", "strict", "all"或者"disabled"
"advance_docs": {
    "pdf": {
        "two_column": false, // 是否认为PDF是双栏的
        "formula_ocr": true // 是否使用OCR识别PDF中的公式
    }
},

//== 高级配置 ==
// 是否多个API Key轮换使用
"multi_api_key": false,
"hide_my_key": false, // 如果你想在UI中隐藏 API 密钥输入框,将此值设置为 true
// "available_models": ["GPT3.5 Turbo", "GPT4 Turbo", "GPT4 Vision"], // 可用的模型列表,将覆盖默认的可用模型列表
// "extra_models": ["模型名称3", "模型名称4", ...], // 额外的模型,将添加到可用的模型列表之后
// "api_key_list": [
//     "sk-xxxxxxxxxxxxxxxxxxxxxxxx1",
//     "sk-xxxxxxxxxxxxxxxxxxxxxxxx2",
//     "sk-xxxxxxxxxxxxxxxxxxxxxxxx3"
// ],
// 自定义OpenAI API Base
// "openai_api_base": "https://api.openai.com",
// 自定义使用代理(请替换代理URL)
// "https_proxy": "http://127.0.0.1:1079",
// "http_proxy": "http://127.0.0.1:1079",
// 自定义端口、自定义ip(请替换对应内容)
"server_name": "0.0.0.0",
"server_port": 7860,
// 如果要share到gradio,设置为true
// "share": false,
//如果不想自动打开浏览器,设置为false
//"autobrowser": false
// ⭐️ 用户界面中将会显示的模型
"available_models": ["qwen2:7b", "llama3.1:8b"], 

// ⭐️ 手动添加的Ollama模型,api_host与model_name需要和Ollama对应上
"extra_model_metadata": { //
    "qwen2:7b": {
        "model_name": "qwen2:7b",
        "description": "An expert of mean jokes, who answers all user questions in a humorous and mean way.",
        "model_type": "OpenAIVision",
        "multimodal": false,
        // "api_host": "http://localhost:11434/v1/chat/completions",
        "api_host": "http://localhost:11434",
        "token_limit": 4096,
        "max_generation": 4096,
        "system": "You are an expert of mean jokes. You Answer all user questions in a humorous and mean way, pretending you are Elon Musk.",
        "placeholder": {
            "logo": "https://wallpaperaccess.com/full/9170621.png",
            "slogan": "I am NOT politically correct",
            "question_1": "How can I get X Premium+?",
            "question_2": "Roast me pls",
            "question_3": "What's the true nature of the universe",
            "question_4": "Ai is biased",
        }
    },
    
    "llama3.1:8b": {
        "model_name": "llama3.1:8b",
        "description": "An expert of mean jokes, who answers all user questions in a humorous and mean way.",
        "model_type": "OpenAIVision",
        "multimodal": false,
        // "api_host": "http://localhost:11434/v1/chat/completions",
        "api_host": "http://localhost:11434",
        "token_limit": 4096,
        "max_generation": 4096,
        "system": "You are an expert of mean jokes. You Answer all user questions in a humorous and mean way, pretending you are Elon Musk.",
        "placeholder": {
            "logo": "https://wallpaperaccess.com/full/9170621.png",
            "slogan": "I am NOT politically correct",
            "question_1": "How can I get X Premium+?",
            "question_2": "Roast me pls",
            "question_3": "What's the true nature of the universe",
            "question_4": "Ai is biased",
        }
    },
},

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions