Skip to content

Commit 1b3949f

Browse files
committed
Correct model associations and move to .env file configuration.
1 parent ac6edf6 commit 1b3949f

File tree

5 files changed

+33
-32
lines changed

5 files changed

+33
-32
lines changed

.env.example

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
CUSTOM_TOKEN=your_custom_token
2-
SYSTEM_TOKEN=your_poe_api_key
2+
SYSTEM_TOKEN=your_poe_api_key
3+
MODEL_MAPPING='{
4+
"gpt-3.5-turbo": "GPT-3.5-Turbo",
5+
"gpt-4o": "GPT-4o",
6+
"gpt-4-turbo": "GPT-4-Turbo"
7+
}'

README.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ cd poe_2_openai
5050

5151
3. Run the application
5252
```shell
53+
docker compose build
5354
docker compose up -d
5455
```
5556

@@ -59,13 +60,11 @@ docker compose up -d
5960
```
6061

6162
## Model Conversion Explanation
62-
```python
63-
model_mapping = {
64-
"gpt-3.5-turbo-16k": "ChatGPT-16k",
65-
"gpt-3.5-turbo": "ChatGPT",
66-
"gpt-4": "GPT-4",
67-
"gpt-4-turbo": "Claude-3-Opus",
68-
"gpt-4-vision-preview": "GPT-4-128k",
69-
"gpt-4-turbo-preview": "Claude-3-Opus-200k"
70-
}
63+
```shell
64+
# edit the .env file
65+
MODEL_MAPPING='{
66+
"gpt-3.5-turbo": "GPT-3.5-Turbo",
67+
"gpt-4o": "GPT-4o",
68+
"gpt-4-turbo": "GPT-4-Turbo"
69+
}'
7170
```

README_ZH.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,16 @@ cd poe_2_openai
5454

5555
3.运行
5656
```shell
57+
docker compose build
5758
docker compose up -d
5859
```
5960

6061
## 模型转换说明
61-
```python
62-
model_mapping = {
63-
"gpt-3.5-turbo-16k": "ChatGPT-16k",
64-
"gpt-3.5-turbo": "ChatGPT",
65-
"gpt-4": "GPT-4",
66-
"gpt-4-turbo": "Claude-3-Opus",
67-
"gpt-4-vision-preview": "GPT-4-128k",
68-
"gpt-4-turbo-preview": "Claude-3-Opus-200k"
69-
}
62+
```shell
63+
# 请在 .env 文件自定义编辑
64+
MODEL_MAPPING='{
65+
"gpt-3.5-turbo": "GPT-3.5-Turbo",
66+
"gpt-4o": "GPT-4o",
67+
"gpt-4-turbo": "GPT-4-Turbo"
68+
}'
7069
```

docker-compose.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ services:
77
- "39527:39527"
88
environment:
99
CUSTOM_TOKEN: sk-your-own-custom-token
10-
SYSTEM_TOKEN: your-poe-api-key
10+
SYSTEM_TOKEN: your-poe-api-key
11+
MODEL_MAPPING: '{
12+
"gpt-3.5-turbo": "GPT-3.5-Turbo",
13+
"gpt-4o": "GPT-4o",
14+
"gpt-4-turbo": "GPT-4-Turbo"
15+
}'

poe_api.py

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import json
12
import logging
3+
import os
24

35
from fastapi import WebSocket, Form
46
from fastapi.responses import JSONResponse
@@ -11,16 +13,6 @@
1113

1214
client_dict = {}
1315

14-
model_mapping = {
15-
"gpt-3.5-turbo-16k": "ChatGPT-16k",
16-
"gpt-3.5-turbo": "ChatGPT",
17-
"gpt-4": "GPT-4",
18-
"gpt-4-turbo": "Claude-3-Opus",
19-
"gpt-4-vision-preview": "GPT-4-128k",
20-
"gpt-4-turbo-preview": "Claude-3-Opus-200k"
21-
}
22-
23-
2416
async def get_responses(api_key, prompt=[], bot="gpt-4"):
2517
bot_name = get_bot(bot)
2618
# "system", "user", "bot"
@@ -45,7 +37,7 @@ async def stream_get_responses(api_key, prompt, bot):
4537
bot_name = get_bot(bot)
4638
messages = openai_message_to_poe_message(prompt)
4739
async for partial in get_bot_response(messages=messages, bot_name=bot_name, api_key=api_key,
48-
skip_system_prompt=False):
40+
skip_system_prompt=True):
4941
yield partial.text
5042

5143

@@ -96,7 +88,8 @@ async def websocket_endpoint(websocket: WebSocket):
9688

9789

9890
def get_bot(model):
99-
return model_mapping.get(model, "ChatGPT-16k")
91+
model_mapping = json.loads(os.environ.get("MODEL_MAPPING", "{}"))
92+
return model_mapping.get(model, "GPT-4o")
10093

10194

10295
def openai_message_to_poe_message(messages=[]):

0 commit comments

Comments
 (0)