Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 0 additions & 110 deletions README.en-US.md

This file was deleted.

85 changes: 39 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
# Azure OpenAI Proxy

[English](./README.en-US.md) | 简体中文
English | [简体中文](./README.zh-CN.md)

Azure OpenAI Proxy 是一个 OpenAI API 的代理工具,能将 OpenAI API 请求转为 Azure OpenAI API 请求,从而让只支持 OpenAI 的应用程序无缝使用 Azure OpenAI。
Azure OpenAI Proxy is a tool that transforms OpenAI API requests into Azure OpenAI API requests, allowing OpenAI-compatible applications to seamlessly use Azure Open AI.

## 使用条件
## Prerequisites

你需要有一个 Azure OpenAI 账户才能使用 Azure OpenAI Proxy
An Azure OpenAI account is required to use Azure OpenAI Proxy.

## Azure 部署
## Azure Deployment

[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fscalaone%2Fazure-openai-proxy%2Fmain%2Fdeploy%2Fazure-deploy.json)

请注意:
Remember to:

- 选择与你的 Azure OpenAI 资源相匹配的区域以获得最佳性能。
- 如果部署失败是因为 'proxywebapp' 名称已被占用,只需修改资源前缀再重新部署。
- 已部署的代理应用位于 B1 定价层级的 Azure 网页应用计划下,你可以在部署后在 Azure 门户中进行更新。
- Select the region that matches your Azure OpenAI resource for best performance.
- If deployment fails because the 'proxywebapp' name is already taken, change the resource prefix and redeploy.
- The deployed proxy app is part of a B1 pricing tier Azure web app plan, which can be modified in the Azure Portal after deployment.

## Docker 部署
## Docker Deployment

To deploy using Docker, execute the following command:

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

## 本地运行和测试,命令行方式
## Local Execution and Testing

1. 安装 NodeJS 18。
2. 克隆代码到命令行窗口。
3. 运行 `npm install` 安装依赖项。
4. 运行 `npm start` 启动应用程序。
5. 运行下面脚本测试,运行前需要把`AZURE_RESOURCE_ID`,`AZURE_MODEL_DEPLOYMENT`,`AZURE_API_KEY`和`AZURE_API_VERSION`替换,`AZURE_API_VERSION`参数可选,默认是`2023-05-15`。
Follow these steps:

<details>
<summary>测试脚本</summary>
1. Install NodeJS 18.
2. Clone the repository in the command line window.
3. Run `npm install` to install the dependencies.
4. Run `npm start` to start the application.
5. Use the script below for testing. Replace `AZURE_RESOURCE_ID`, `AZURE_MODEL_DEPLOYMENT`, and `AZURE_API_KEY` before running. The default value for `AZURE_API_VERSION` is `2023-05-15` and is optional.

<details>
<summary>Test script</summary>
```bash
curl -X "POST" "http://localhost:3000/v1/chat/completions" \
-H 'Authorization: AZURE_RESOURCE_ID:AZURE_MODEL_DEPLOYMENT:AZURE_API_KEY:AZURE_API_VERSION' \
Expand All @@ -55,52 +58,42 @@ curl -X "POST" "http://localhost:3000/v1/chat/completions" \
"stream": false
}'
```

</details>

## 已测试应用
## Tested Applications

以下应用已经过测试,确认可以与 azure-openai-proxy 一起工作:
The azure-openai-proxy has been tested and confirmed to work with the following applications:

| 应用名称 | E2E测试 Docker-compose 文件 |
| Application Name | Docker-compose File for E2E Test |
| --------------------------------------------------------------- | --------------------------------------------------------------- |
| [chatgpt-lite](https://github.com/blrchen/chatgpt-lite) | [docker-compose.yml](./e2e/chatgpt-lite/docker-compose.yml) |
| [chatgpt-next-web](https://github.com/Yidadaa/ChatGPT-Next-Web) | [docker-compose.yml](./e2e/chatgpt-next-web/docker-compose.yml) |
| [chatbot-ui](https://github.com/mckaywrigley/chatbot-ui) | [docker-compose.yml](./e2e/chatbot-ui/docker-compose.yml) |
| [chatgpt-web](https://github.com/Chanzhaoyu/chatgpt-web) | [docker-compose.yml](./e2e/chatgpt-web/docker-compose.yml) |
| [chatgpt-minimal](https://github.com/blrchen/chatgpt-minimal) | [docker-compose.yml](./e2e/chatgpt-minimal/docker-compose.yml) |

要在本地运行测试,请按照以下步骤操作:
To test locally, follow these steps:

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
1. Clone the repository in a command-line window.
2. Update the `OPENAI_API_KEY` environment variable with `AZURE_RESOURCE_ID:AZURE_MODEL_DEPLOYMENT:AZURE_API_KEY`. Alternatively, update the OPENAI_API_KEY value in the docker-compose.yml file directly.
3. Navigate to the directory containing the `docker-compose.yml` file for the application you want to test.
4. Execute the build command: `docker-compose build`.
5. Start the service: `docker-compose up -d`.
6. Access the application locally using the port defined in the docker-compose.yml file. For example, visit http://localhost:3000.

## 常见问题
## FAQs

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

![resource-and-model](./resource-and-model.jpg)

<summary>Q: What are `AZURE_RESOURCE_ID`,`AZURE_MODEL_DEPLOYMENT`, and `AZURE_API_KEY`?</summary>
A: These can be found in the Azure management portal. See the image below for reference:
![resource-and-model](./docs/images/resource-and-model.jpg)
</details>

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

<summary>Q: How can I use gpt-4 and gpt-4-32k models?</summary>
A: To use gpt-4 and gpt-4-32k models, follow the key format below:
`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`

</details>

# 贡献代码方式

欢迎提交各种 PR。

# 免责声明
## Contributing

此代码仅供演示和测试目的。
We welcome all PR submissions.
99 changes: 99 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Azure OpenAI Proxy

[English](./README.md) | 简体中文

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

## 使用条件

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

## Azure 部署

[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fscalaone%2Fazure-openai-proxy%2Fmain%2Fdeploy%2Fazure-deploy.json)

请注意:

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

## Docker 部署

要使用Docker进行部署,请执行以下命令:

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

## 本地运行和测试

遵循以下步骤:

1. 安装 NodeJS 18。
2. 克隆代码到命令行窗口。
3. 运行 `npm install` 安装依赖项。
4. 运行 `npm start` 启动应用程序。
5. 运行下面脚本测试,运行前需要把`AZURE_RESOURCE_ID`,`AZURE_MODEL_DEPLOYMENT`,`AZURE_API_KEY`和`AZURE_API_VERSION`替换,`AZURE_API_VERSION`参数可选,默认是`2023-05-15`。

<details>
<summary>测试脚本</summary>
```bash
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
}'
```
</details>

## 已测试应用

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

| 应用名称 | E2E测试 Docker-compose 文件 |
| --------------------------------------------------------------- | --------------------------------------------------------------- |
| [chatgpt-lite](https://github.com/blrchen/chatgpt-lite) | [docker-compose.yml](./e2e/chatgpt-lite/docker-compose.yml) |
| [chatgpt-next-web](https://github.com/Yidadaa/ChatGPT-Next-Web) | [docker-compose.yml](./e2e/chatgpt-next-web/docker-compose.yml) |
| [chatbot-ui](https://github.com/mckaywrigley/chatbot-ui) | [docker-compose.yml](./e2e/chatbot-ui/docker-compose.yml) |
| [chatgpt-web](https://github.com/Chanzhaoyu/chatgpt-web) | [docker-compose.yml](./e2e/chatgpt-web/docker-compose.yml) |
| [chatgpt-minimal](https://github.com/blrchen/chatgpt-minimal) | [docker-compose.yml](./e2e/chatgpt-minimal/docker-compose.yml) |

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

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

## 常见问题

<details>
<summary>Q:什么是`AZURE_RESOURCE_ID`,`AZURE_MODEL_DEPLOYMENT`,`AZURE_API_KEY`</summary>
A: 可以在Azure的管理门户里查找,具体见下图标注
![resource-and-model](./docs/images/resource-and-model.jpg)
</details>
<details>
<summary>Q: 如何使用gpt-4 and gpt-4-32k模型</summary>
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`
</details>

## 贡献代码方式

欢迎提交各种 PR。
10 changes: 2 additions & 8 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import type { Metadata } from 'next'
import React, { ReactNode } from 'react'
import { Inter } from 'next/font/google'

const inter = Inter({ subsets: ['latin'] })

export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app'
}

export default function RootLayout({ children }: { children: React.ReactNode }) {
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
Expand Down
7 changes: 1 addition & 6 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import Image from 'next/image'

export default function Home() {
return (
<main>
</main>
)
return <main></main>
}
2 changes: 1 addition & 1 deletion app/v1/models/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextRequest, NextResponse } from 'next/server'
import { NextResponse } from 'next/server'

export async function GET() {
const models = {
Expand Down
File renamed without changes