免费 Llama3.1 405B 网站 (评论区已2api ) (评论区已部署现成服务)


一定要用英语问

1 个赞

感谢

1 个赞

潦草版 worker

/**
 * Welcome to Cloudflare Workers! This is your first worker.
 *
 * - Run "npm run dev" in your terminal to start a development server
 * - Open a browser tab at http://localhost:8787/ to see your worker in action
 * - Run "npm run deploy" to publish your worker
 *
 * Learn more at https://developers.cloudflare.com/workers/
 */



function convert(original) {
    const transformed = {
        body: {
            messages: [],
            // 如果最大4080
            max_tokens: original.max_tokens > 4080 ? 4080 : original.max_tokens,
            stop: ["<|eot_id|>"],
            stream: original.stream ?? true,
            stream_options: {
                include_usage: true
            },
            model: "llama3-405b"
        },
        env_type: "tp16405b"
    };
   // 添加用户和助手消息
   for (let i in original.messages) {
    const message = original.messages[i];
    if (message.role == "user") {
      const transformedMessage = {
          role: message.role,
          content: message.content,
          id: `${parseInt(i) + 1}-id`,
          ref: `${parseInt(i) + 1}-ref`,
          revision: 1,
          draft: false,
          status: "done",
          enableRealTimeChat: false,
          meta: null
      };
      transformed.body.messages.push(transformedMessage);
    }
    if (message.role == "assistant") {
      const transformedMessage = {
          role : message.role,
          content: message.content,
          meta: null,
          status: "done",
          id: `${parseInt(i) + 1}-id`,
          draft: false,
          revision: 1
      };
      transformed.body.messages.push(transformedMessage);
    }
  }
  return transformed;
}

export default {
  async fetch(request, env, ctx) {
    const url = new URL(request.url)
    if (url.pathname !== '/v1/chat/completions') {
        return new Response('Not Found', { status: 404 })
    }

    // 确保只处理POST请求
    if (request.method !== 'POST') {
        return new Response('Method Not Allowed', { status: 405 })
    }

    let reqBody = await request.json();
    const req_data = convert(reqBody);
    const resp = await fetch('https://fast.snova.ai/api/completion', {
      method: 'POST',
      headers: {
        'accept': 'text/event-stream',
        'accept-language': 'zh-CN,zh;q=0.9',
        'content-type': 'application/json',
        'origin': 'https://fast.snova.ai',
        'priority': 'u=1, i',
        'referer': 'https://fast.snova.ai/',
        'sec-ch-ua': '"Not)A;Brand";v="99", "Google Chrome";v="127", "Chromium";v="127"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"Windows"',
        'sec-fetch-dest': 'empty',
        'sec-fetch-mode': 'cors',
        'sec-fetch-site': 'same-origin',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36'
      },
      body: JSON.stringify(req_data)
    });
    return resp;
  }
};
16 个赞

太棒了,不愧是草台班子的福利

1 个赞

我也转成功了,整理一下发出来

Mark

整出来了!!!
Root URL: https://provider-52b3df3d.24a.fun
支持OpenAI格式,stream和非stream,实测可直接导入New-API
Key可以随便填
求个赞(
通过 CF Tunnel 跑在我的树莓派上,求各位佬别暴刷,我树莓派就在我卧室,我怕半夜睡觉突然被炸了(玩笑
模型只能填写llama-3.1-405b,不然会500

15 个赞

实试可用感谢

1 个赞

牛啊

牛哇

1 个赞

这个是真牛。

牛啊

牛的,mark一下,虽然还不太会用

这个应该很快会被薅穿

强啊佬

1 个赞

不会,没多少人用这玩意儿。

1 个赞

牛哇

1 个赞


米了


这个为啥不行呀。报错 500

1 个赞