Giter VIP home page Giter VIP logo

fivelucky / azure-openai Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scalaone/azure-openai-proxy

0.0 0.0 0.0 674 KB

一个 Azure OpenAI API 代理工具,能将 OpenAI API 请求转换为 Azure OpenAI API 请求,使仅支持 OpenAI 的应用程序可以无缝地使用 Azure Open AI。An Azure OpenAI API proxy tool that can convert OpenAI API requests into Azure OpenAI API requests, allowing applications that only support OpenAI to seamlessly use Azure Open AI.

Home Page: https://gptlite.vercel.app

License: MIT License

JavaScript 0.41% TypeScript 96.67% Dockerfile 2.92%

azure-openai's Introduction

Azure OpenAI Proxy

English | 简体中文

Azure OpenAI Proxy 是一个 OpenAI API 的代理工具,能将 OpenAI API 请求转为 Azure OpenAI API 请求,从而让只支持 OpenAI 的应用程序无缝使用 Azure OpenAI。

使用条件

你需要有一个 Azure OpenAI 账户才能使用 Azure OpenAI Proxy。

Azure 部署

Deploy to Azure

请注意:

  • 选择与你的 Azure OpenAI 资源相匹配的区域以获得最佳性能。
  • 如果部署失败是因为 'proxywebapp' 名称已被占用,只需修改资源前缀再重新部署。
  • 已部署的代理应用位于 B1 定价层级的 Azure 网页应用计划下,你可以在部署后在 Azure 门户中进行更新。

Docker 部署

docker run -d -p 3000:3000 scalaone/azure-openai-proxy

本地运行和测试,命令行方式

  1. 安装 NodeJS 18。
  2. 克隆代码到命令行窗口。
  3. 运行 npm install 安装依赖项。
  4. 运行 npm start 启动应用程序。
  5. 运行下面脚本测试,运行前需要把AZURE_RESOURCE_IDAZURE_MODEL_DEPLOYMENTAZURE_API_KEYAZURE_API_VERSION替换,AZURE_API_VERSION参数可选,默认是2023-05-15
测试脚本
curl -X "POST" "http://localhost:3000/v1/chat/completions" \
-H 'Authorization: AZURE_RESOURCE_ID:AZURE_MODEL_DEPLOYMENT:AZURE_API_KEY:AZURE_API_VERSION' \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
  "messages": [
    {
      "role": "system",
      "content": "You are an AI assistant that helps people find information."
    },
    {
      "role": "user",
      "content": "hi."
    }
  ],
  "temperature": 1,
  "model": "gpt-3.5-turbo",
  "stream": false
}'

已测试应用

以下应用已经过测试,确认可以与 azure-openai-proxy 一起工作:

应用名称 E2E测试 Docker-compose 文件
chatgpt-lite docker-compose.yml
chatgpt-next-web docker-compose.yml
chatbot-ui docker-compose.yml
chatgpt-web docker-compose.yml
chatgpt-minimal docker-compose.yml

要在本地运行测试,请按照以下步骤操作:

  1. 在命令行窗口中克隆代码。
  2. 更新环境变量OPENAPI_API_KEY的值为AZURE_RESOURCE_ID:AZURE_MODEL_DEPLOYMENT:AZURE_API_KEY。或者,直接在docker-compose.yml文件中更新OPENAPI_API_KEY值。
  3. 导航到包含要测试的应用程序的docker-compose.yml文件所在的目录。
  4. 执行构建命令:docker-compose build
  5. 启动服务:docker-compose up -d
  6. 根据docker-compose.yml文件中定义的公开端口,启动应用以在本地进行测试。例如,访问 http://localhost:3000。

常见问题

Q:什么是`AZURE_RESOURCE_ID`,`AZURE_MODEL_DEPLOYMENT`,`AZURE_API_KEY` A: 可以在Azure的管理门户里查找,具体见下图标注

resource-and-model

Q: 如何使用gpt-4 and gpt-4-32k模型 A: 要使用gpt-4 and gpt-4-32k模型,请使用下列格式的key:

AZURE_RESOURCE_ID:gpt-3.5-turbo|AZURE_MODEL_DEPLOYMENT,gpt-4|AZURE_MODEL_DEPLOYMENT,gpt-4-32k|AZURE_MODEL_DEPLOYMENT:AZURE_API_KEY:AZURE_API_VERSION

贡献代码方式

欢迎提交各种 PR。

免责声明

此代码仅供演示和测试目的。

azure-openai's People

Contributors

blrchen avatar fivelucky avatar haha1903 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.