huggingface部署的openwebui,uptime等网站的保活方法

可能openwebui占用比较大的缘故

明白了,谢谢

有谁会我发的第三个问题吗??? :thinking:

我看到有人实现了,我想用在自己用的newapi网站上,实时检测各个模型能否使用

huggingface上部署的openwebui上监控也没用,也容易掉,你们又出现这种情况吗?

cf worker添加cron任务定时访问,不可能掉,我的已经快一个月了

addEventListener('scheduled', event => {
  event.waitUntil(handleScheduled(event));
})

async function handleScheduled(event) {
  const url = "https://xxx.hf.space/auth";  // 替换为你的 Hugging Face Space URL
  const response = await fetch(url);
  if (response.ok) {
    console.log("Space is active");
  } else {
    console.log(`Received unexpected status code ${response.status}`);
  }
}

设置-触发器-Cron 触发器里添加一个,频率随意

2 个赞

保活我是用的 dnspod​:eyes:
这个会换 ip 请求 :tieba_024:

URL填https://你的域名.com/v1/chat/completions

HTTP 选项
方法选择post
请求体选择json

请求体

{
    "model": "gpt-4o",
    "messages": [
        {
            "role": "user",
            "content": "Hi?"
        }
    ],
    "stream": false
}

请求头

{
    "Authorization": "Bearer api-key"
}
2 个赞

为啥我的不行哎,反代的网址是这个格式吗:
username-open-webui.hf.space
也可能我的worker代码不对

欧克,谢谢各位佬,问题全部已解决

我记得休眠的条件是长期不用啊

在Github仓库的 .github/workflows 中新建一个名为 auto-visit.yml 的文件,并修改 websites 变量的内容即可实现自动运行。

name: Auto Visit Websites

on:
  schedule:
    - cron: '0 */12 * * *'  # 每12小时执行一次
  workflow_dispatch:

jobs:
  auto-visit-websites:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: 3.x

    - name: Install requests library
      run: pip install requests

    - name: Auto Visit Websites
      run: |
        echo "
        import requests

        websites = [
            'https://jerryz.com.cn',
            'https://blog.jerryz.com.cn'
            # 添加更多网站
        ]

        def check_website(url):
            try:
                response = requests.get(url)
                if response.status_code == 200:
                    print(f'Website {url} is up.')
                else:
                    print(f'Website {url} returned status code {response.status_code}.')
            except requests.exceptions.RequestException as e:
                print(f'An error occurred while checking {url}: {e}')

        for website in websites:
            check_website(website)
        " > auto_visit_websites.py
        python auto_visit_websites.py

如果需要调整运行时间,可以修改 cron 表达式。例如,防止Huggingface休眠可以使用 0 */12 * * *,而防止Render休眠可以使用 */13 * * * *

在博客中阅读:通过GitHub Workflow实现网站防休眠 | Jerry Zhou的个人博客

是openwebui的锅,我部署其他的网站并不会这样

感谢

openwebui这么吃性能啊