Jim Deng

Jim Deng

解决huggingface部署notdiamond2api的奇葩接口

image 
原贴使用 Dockerfile 文件部署 notdiamond2api(支持 huggingface) - 资源荟萃 / 资源荟萃,Lv2 - LINUX DO
参考 GitHub-Models - 使用指南 - 文档共建 - LINUX DO
用 cloudflare worker 还能实现自定义域名

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  const url = new URL(request.url)

  if (url.pathname.startsWith('/v1')) {
    const newUrl = new URL(request.url)
    newUrl.hostname = '你的域名'
    newUrl.pathname = newUrl.pathname.replace('/v1', '//v1',) 

    const newRequest = new Request(newUrl, {
      method: request.method,
      headers: request.headers,
      body: request.body
    })

    return fetch(newRequest)
  }

  return fetch(request)
}
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.