File tree 6 files changed +34
-6
lines changed 6 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,8 @@ All deployment configurations could be configured in the `.env` file or in **Env
103
103
| OPENAI_API_BASE_URL | api.openai.com | The default address of the requested api |
104
104
| DISCORD_SERVER_ID | - | Discord server id |
105
105
| DISCORD_CHANNEL_ID | - | Discord channel id |
106
- | DISCORD_TOKEN | - | Discord token |
106
+ | DISCORD_TOKEN | - | Discord token |
107
+ | DISCORD_IMAGE_PROXY | - | Discord image proxy url |
107
108
108
109
109
110
### Global Configurations
Original file line number Diff line number Diff line change 114
114
| OPENAI_API_BASE_URL | api.openai.com | 请求 api 的默认地址 |
115
115
| DISCORD_SERVER_ID | - | Discord 服务器 id |
116
116
| DISCORD_CHANNEL_ID | - | Discord 频道 id |
117
- | DISCORD_TOKEN | - | Discord token |
117
+ | DISCORD_TOKEN | - | Discord token |
118
+ | DISCORD_IMAGE_PROXY | - | Discord 返回图片代理地址 |
118
119
119
120
120
121
### 全局配置
Original file line number Diff line number Diff line change @@ -6,11 +6,13 @@ export const localConversationKey = 'LOCAL_CONVERSATION';
6
6
// From https://platform.openai.com/docs/models/model-endpoint-compatibility
7
7
export const supportedModels = [
8
8
'gpt-4' ,
9
- 'gpt-4-0314 ' ,
9
+ 'gpt-4-0613 ' ,
10
10
'gpt-4-32k' ,
11
- 'gpt-4-32k-0314 ' ,
11
+ 'gpt-4-32k-0613 ' ,
12
12
'gpt-3.5-turbo' ,
13
- 'gpt-3.5-turbo-0301' ,
13
+ 'gpt-3.5-turbo-0613' ,
14
+ 'gpt-3.5-turbo-16k' ,
15
+ 'gpt-3.5-turbo-16k-0613' ,
14
16
] as const ;
15
17
16
18
export type SupportedModel = ( typeof supportedModels ) [ number ] ;
Original file line number Diff line number Diff line change @@ -2,3 +2,5 @@ export const serverGlobalConfigs: { polling: number } = {
2
2
// load balancer polling step
3
3
polling : 0 ,
4
4
} ;
5
+
6
+ export const discordImageCdn = 'cdn.discordapp.com' ;
Original file line number Diff line number Diff line change 8
8
type MessageType ,
9
9
type MessageTypeProps ,
10
10
} from 'midjourney-fetch' ;
11
+ import { discordImageCdn } from '@configs/server' ;
11
12
import {
12
13
apiKeyStrategy ,
13
14
apiKeys ,
@@ -17,6 +18,7 @@ import {
17
18
dicordServerId ,
18
19
discordChannelId ,
19
20
discordToken ,
21
+ discordImageProxy ,
20
22
} from '.' ;
21
23
22
24
export { config } ;
@@ -88,7 +90,23 @@ export const get: APIRoute = async ({ request }) => {
88
90
const message = await midjourney . getMessage ( prompt , options ) ;
89
91
90
92
if ( message ) {
91
- return new Response ( JSON . stringify ( message ) , { status : 200 } ) ;
93
+ return new Response (
94
+ JSON . stringify (
95
+ discordImageProxy
96
+ ? {
97
+ ...message ,
98
+ attachments : message . attachments . map ( ( attachment ) => ( {
99
+ ...attachment ,
100
+ url : attachment . url . replace (
101
+ discordImageCdn ,
102
+ discordImageProxy
103
+ ) ,
104
+ } ) ) ,
105
+ }
106
+ : message
107
+ ) ,
108
+ { status : 200 }
109
+ ) ;
92
110
}
93
111
94
112
return new Response ( JSON . stringify ( { msg : 'No content found' } ) , {
Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ export const discordChannelId =
38
38
export const discordToken =
39
39
import . meta. env . DISCORD_TOKEN || process . env . DISCORD_TOKEN ;
40
40
41
+ export const discordImageProxy = (
42
+ import . meta. env . DISCORD_IMAGE_PROXY || process . env . DISCORD_IMAGE_PROXY
43
+ ) ?. replace ( / ^ h t t p s ? : \/ \/ / i, '' ) ;
44
+
41
45
/**
42
46
* https://vercel.com/docs/concepts/edge-network/regions#region-list
43
47
* disable hkg1 HongKong
You can’t perform that action at this time.
0 commit comments