Code Monkey home page Code Monkey logo

cf-openai-azure-proxy's Introduction

cf-openai-azure-proxy

English | 中文

大多数 OpenAI 客户端不支持 Azure OpenAI Service,但Azure OpenAI Service的申请和绑卡都非常简单,并且还提供了免费的额度。此脚本使用免费的 Cloudflare Worker 作为代理,使得支持 OpenAI 的客户端可以直接使用 Azure OpenAI Service。

项目说明:

  • 我没有服务器可以使用吗?
    • 这段脚本跑在Cloudflare Worker, 不需要服务器, 不需要绑卡, 每天10W次请求 免费
  • 我没有自己的域名可以使用吗?
  • 实现打印机模式:
    • Azure OpenAI Service's 回复是一段一段回复的
    • 返回给客户端的时候, 本项目拆出一条条的消息, 依次给, 达到打印机模式
  • 项目也支持 Docker 部署(基于 wrangler)

部署

代理 OpenAI 的请求到 Azure OpenAI Serivce,代码部署步骤:

  1. 注册并登录到 Cloudflare 账户
  2. 创建一个新的 Cloudflare Worker
  3. cf-openai-azure-proxy.js 复制并粘贴到 Cloudflare Worker 编辑器中
  4. 通过修改或环境变量调整 resourceName 和 deployment mapper 的值
  5. 保存并部署 Cloudflare Worker
  6. haibbo#3 可选绑定自定义域名: 在 Worker 详情页 -> Trigger -> Custom Domains 中为这个 Worker 添加一个自定义域名

使用说明

先得到 resourceName 和 deployment mapper, 登录到Azure的后台:

env

这里有两种做法:

  • 直接修改他们的值, 如:
// The name of your Azure OpenAI Resource.
const resourceName="codegpt"

// deployment model mapper
const mapper = {
     'gpt-3.5-turbo': 'gpt3',
     'gpt-4': 'gpt4' 
   };
其他的map规则直接按这样的格式续写即可
  • 或者通过 cloudflare worker 控制台, 进入 Workers script > Settings > Add variable under Environment Variables.

    env

客户端

以 OpenCat 为例: 自定义 API 域名填写 第六步绑定的域名:

opencat

我已经尝试了多种客户端, 如果遇到其他客户端有问题, 欢迎创建issue.

cf-openai-azure-proxy's People

Contributors

haibbo avatar casyalex avatar hbsgithub avatar invisprints avatar caixiaopig avatar ruochenlyu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.