Skip to content

Commit d9fc957

Browse files
authored
Add docker compose file and update README (#6)
1 parent 3977711 commit d9fc957

File tree

4 files changed

+136
-62
lines changed

4 files changed

+136
-62
lines changed

README.en-US.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Azure OpenAI Proxy
2+
3+
[English](./README.en-US.md) | Simplified Chinese
4+
5+
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.
6+
7+
## Usage Requirements
8+
9+
You must have an Azure OpenAI account to use the Azure OpenAI Proxy.
10+
11+
## Docker Deployment
12+
`docker run -d -p 3080:3080 scalaone/azure-openai-proxy`
13+
14+
## Local Running and Testing, Command Line Method
15+
16+
1. Install NodeJS 18.
17+
2. Clone the code in the command line window.
18+
3. Run `npm install` to install dependencies.
19+
4. Run `npm start` to start the application.
20+
5. Run the script below for testing, replacing `YOUR_RESOURCE_ID`, `YOUR_MODEL_DEPLOYMENT`, and `YOUR_API_KEY` before running it.
21+
```bash
22+
curl -X "POST" "http://localhost:3000/v1/chat/completions" \
23+
-H 'Authorization: YOUR_RESOURCE_ID:YOUR_MODEL_DEPLOYMENT:YOUR_API_KEY' \
24+
-H 'Content-Type: application/json; charset=utf-8' \
25+
-d $'{
26+
"messages": [
27+
{
28+
"role": "system",
29+
"content": "You are an AI assistant that helps people find information."
30+
},
31+
{
32+
"role": "user",
33+
"content": "hi."
34+
}
35+
],
36+
"temperature": 1,
37+
"model": "gpt-3.5-turbo",
38+
"stream": false
39+
}'
40+
```
41+
42+
## Local Running and Testing, Using WebChat for Streaming Test
43+
44+
1. Clone code in command line window
45+
2. Update environment variable of OPENAPI_API_KEY on line nine of docker-compose.yml file with `YOUR_RESOURCE_ID:YOUR_MODEL_DEPLOYMENT:YOUR_API_KEY`
46+
3. Execute build:run docker-compose build
47+
4. Start service:run docker-compose up -d
48+
5. Launch `http://localhost:3000`
49+
50+
Frequently Asked Questions
51+
52+
Q:What is `YOUR_RESOURCE_ID`,`YOUR_MODEL_DEPLOYMENT`,`YOUR_API_KEY`?
53+
54+
A:It can be found in azure management portal,see image below for details:
55+
56+
![resource-and-model](./resource-and-model.jpg)
57+
58+
Q:How do I support GPT-4?
59+
60+
A :To use GPT-4 , please use key format as follows:
61+
62+
`YOUR_RESOURCE_ID:gpt-3.5-turbo|YOUR_MODEL_DEPLOYMENT,gpt-4|YOUR_MODEL_DEPLOYMENT,gpt-4-32k|YOUR_MODEL_DEPLOYMENT:YOUR_API_KEY`
63+
64+
# How To Contribute Code?
65+
66+
Welcome to submit various PRs.
67+
68+
# Disclaimer
69+
70+
This code is for demonstration and testing purposes only.

README.md

Lines changed: 41 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,36 @@
1-
# Azure-OpenAI-Proxy
1+
# Azure OpenAI Proxy
22

3-
Azure-OpenAI-Proxy is an application that serves as a proxy for OpenAI's API. It enables users to request AI-generated text completions for specific prompts, using different models and parameters. The proxy supports GPT-4 models in addition to other available models. It simplifies the interaction with the OpenAI API and helps manage multiple deployments with ease for your AI-based text generation applications.
3+
[English](./README.en-US.md) | 简体中文
44

5-
## Installation
5+
一个 Azure OpenAI API 代理工具,能将 OpenAI API 请求转换为 Azure OpenAI API 请求,使仅支持 OpenAI 的应用程序可以无缝地使用 Azure Open AI。
66

7-
Follow these steps to set up Azure-OpenAI-Proxy:
7+
## 使用要求
88

9-
1. Clone the repository:
9+
必须拥有Azure OpenAI帐户才能使用 Azure OpenAI Proxy。
1010

11-
```
12-
git clone https://github.com/scalaone/azure-openai-proxy.git
13-
```
14-
15-
2. Navigate to the project directory:
16-
17-
```
18-
cd azure-openai-proxy
19-
```
20-
21-
3. Install the required dependencies:
22-
23-
```
24-
npm install
25-
```
11+
## Docker部署
12+
`docker run -d -p 3080:3080 scalaone/azure-openai-proxy`
2613

27-
4. Replace the placeholder values in the example request as mentioned in the [Usage section](#usage) with your actual resource ID, deployment IDs, model names, and API key.
14+
## 本地运行和测试,命令行方式
2815

29-
5. Run the application:
30-
31-
```
32-
npm run start
33-
```
34-
35-
The Azure-OpenAI-Proxy will be running on your server and listening for incoming requests.
36-
37-
## Usage
38-
39-
To send a request, use a `curl` command to POST the input data to the application's URL. Replace the placeholder values with your actual resource ID, deployment IDs, model names, and API key.
40-
41-
Example request:
42-
43-
```
44-
curl -X "POST" "https://openaiproxy2.azurewebsites.net/v1/chat/completions" \
45-
-H 'Authorization: Bearer YOUR_RESOURCE_ID:YOUR_MODEL_NAME_IDENTIFIERS:YOUR_API_KEY' \
46-
-H 'Content-Type: application/json; charset=utf-8' \
47-
-d $'{
16+
1. 安装 NodeJS 18。
17+
2. 克隆代码到命令行窗口。
18+
3. 运行 `npm install` 安装依赖项。
19+
4. 运行 `npm start` 启动应用程序。
20+
5. 运行下面脚本测试,运行前需要把`YOUR_RESOURCE_ID``YOUR_MODEL_DEPLOYMENT``YOUR_API_KEY`替换。
21+
```bash
22+
curl -X "POST" "http://localhost:3000/v1/chat/completions" \
23+
-H 'Authorization: YOUR_RESOURCE_ID:YOUR_MODEL_DEPLOYMENT:YOUR_API_KEY' \
24+
-H 'Content-Type: application/json; charset=utf-8' \
25+
-d $'{
4826
"messages": [
4927
{
50-
"content": "hi",
51-
"role": "user"
28+
"role": "system",
29+
"content": "You are an AI assistant that helps people find information."
30+
},
31+
{
32+
"role": "user",
33+
"content": "hi."
5234
}
5335
],
5436
"temperature": 1,
@@ -57,35 +39,32 @@ curl -X "POST" "https://openaiproxy2.azurewebsites.net/v1/chat/completions" \
5739
}'
5840
```
5941

60-
Replace the following placeholder values:
42+
## 本地运行和测试,使用WebChat测试streaming
6143

62-
- `YOUR_RESOURCE_ID` with the actual resource ID (e.g., `hai`).
63-
- `YOUR_MODEL_NAME_IDENTIFIERS` with the actual model and deployment ID mappings (e.g., `gpt-3.5-turbo|gpt-35-turbo,gpt-4|gpt-4,gpt-4-32k|gpt-4-32k`).
64-
- `YOUR_API_KEY` with your actual API key (e.g., `xxxxxx`).
44+
1. 克隆代码到命令行窗口
45+
2. 更新 `docker-compose.yml` 文件中第九行的 `OPENAI_API_KEY` 环境变量为`YOUR_RESOURCE_ID:YOUR_MODEL_DEPLOYMENT:YOUR_API_KEY`
46+
3. 执行构建:运行 `docker-compose build`
47+
4. 启动服务:运行 `docker-compose up -d`
48+
5. 运行`http://localhost:3000`
6549

66-
## Parameters
50+
常见问题
6751

68-
The request body contains the following parameters:
52+
Q:什么是`YOUR_RESOURCE_ID`,`YOUR_MODEL_DEPLOYMENT`,`YOUR_API_KEY`
6953

70-
- `messages`: An array of message objects containing `content` and `role` properties. The `content` represents the text input, and the `role` can be one of the following options: `'system'`, `'user'`, or `'assistant'`.
71-
- `temperature`: Controls the randomness of generated completions. Higher values (e.g., 1) result in more random responses, while lower values (e.g., 0.1) produce more focused and deterministic responses.
72-
- `model`: Specifies the AI model to be used for generating completions. In the example, it is set to `'gpt-3.5-turbo'`.
73-
- `stream`: A boolean value indicating whether the response should be streamed.
54+
A: 可以在Azure的管理门户里查找,具体见下图标注
7455

75-
## License
56+
![resource-and-model](./resource-and-model.jpg)
7657

77-
This project is licensed under the MIT License. See the [LICENSE](https://choosealicense.com/licenses/mit/) file for details.
58+
Q: 如何支持GPT-4
7859

79-
## Contributing
60+
A: 要使用GPT-4, 请使用下列格式的key:
8061

81-
Contributions to Azure-OpenAI-Proxy are greatly appreciated. To contribute, follow these steps:
62+
`YOUR_RESOURCE_ID:gpt-3.5-turbo|YOUR_MODEL_DEPLOYMENT,gpt-4|YOUR_MODEL_DEPLOYMENT,gpt-4-32k|YOUR_MODEL_DEPLOYMENT:YOUR_API_KEY`
8263

83-
1. Fork the repository and create your branch.
84-
2. Make changes or additions to the code.
85-
3. Commit your changes and raise a Pull Request.
64+
# 贡献代码方式
8665

87-
Please make sure to follow the project's coding standards and update documentation accordingly.
66+
欢迎提交各种PR。
8867

89-
For further information, check the [OpenAI API documentation](https://platform.openai.com/docs/api-reference/completions/create).
68+
# 免责声明
9069

91-
Thank you for your interest in contributing to Azure-OpenAI-Proxy. Your efforts will help improve the project and benefit the community.
70+
此代码仅供演示和测试目的。

docker-compose.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: '3.8'
2+
3+
services:
4+
gptlite:
5+
image: blrchen/gptlite:main
6+
ports:
7+
- 3000:3000
8+
environment:
9+
OPENAI_API_KEY: ${OPENAI_API_KEY}
10+
OPENAI_API_BASE_URL: http://azure-openai:3000
11+
depends_on:
12+
- azure-openai
13+
networks:
14+
- network
15+
16+
azure-openai:
17+
build:
18+
context: .
19+
networks:
20+
- network
21+
restart: unless-stopped
22+
23+
networks:
24+
network:
25+
driver: bridge

resource-and-model.jpg

169 KB
Loading

0 commit comments

Comments
 (0)