-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.py
More file actions
31 lines (25 loc) · 763 Bytes
/
server.py
File metadata and controls
31 lines (25 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import logging
import os
import redis
from app import create_app
from app.prompt.gpt_chat_manager import GptChatManager
import app as app2
app = create_app(debug=True)
# 通过环境变量设定 REDIS_URL
redis_url = os.environ.get("REDIS_URL", "")
if redis_url:
# 初始化 redis 配置
app2.the_redis = redis.from_url(redis_url)
# 设定初始值
app2.the_redis['aid'] = 1
app2.the_redis['eid'] = 1
app2.the_redis['fid'] = 1
app2.the_redis['rid'] = 1
print("init Redis ok")
# 通过环境变量设定 API_KEY,初始化 the_chat_manager
api_key = os.environ.get("OPENAI_API_KEY", "")
if api_key:
app2.the_chat_manager = GptChatManager(api_key=api_key)
print("init GPT ok")
if __name__ == "__main__":
app.run()