forked from LlmKira/Openaibot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_receiver.py
69 lines (59 loc) ยท 2.4 KB
/
start_receiver.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# -*- coding: utf-8 -*-
import getopt
import os
import sys
from dotenv import load_dotenv
from loguru import logger
load_dotenv()
logger.remove()
logger.add(sys.stderr,
level="INFO" if os.getenv("LLMBOT_LOG_OUTPUT") != "DEBUG" else "DEBUG",
colorize=True,
enqueue=True
)
logger.add(sink='run.log',
format="{time} - {level} - {message}",
level="INFO",
rotation="100 MB",
enqueue=True
)
head = """
โโโ โโโ โโโโ โโโโโโโ โโโโโโโโโโโโโ โโโโโโ
โโโ โโโ โโโโโ โโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ
โโโ โโโ โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โโโ โโโ โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโ โโโ โโโโโโ โโโโโโโโโ โโโโโโ โโโ
โโโโโโโโโโโโโโโโโโโ โโโโโโ โโโโโโโโโ โโโโโโ โโโ
"""
logger.opt(record=False, exception=False, capture=False, colors=True).info(f"<cyan>{head}</cyan>")
# ๆฅๅฟ็ณป็ป
if os.getenv("SENTRY_DSN", None):
try:
import sentry_sdk
sentry_sdk.init(
dsn=os.getenv("SENTRY_DSN"),
traces_sample_rate=1.0,
profiles_sample_rate=1.0,
)
except Exception as e:
logger.error(f"SENTRY ERROR: {e}")
else:
logger.success("๐ Create Sentry Client Successfully!")
# ๆ็จ
SKIP_TUTORIAL = False
SKIP_EXISTING = True
opts, args = getopt.getopt(sys.argv[1:], "h", ["no_tutorial", "tutorial"])
for op, value in opts:
if op == "--no_tutorial": # ่ทๅๅฝไปค่กๅๆฐ็ --no_tutorial
SKIP_TUTORIAL = True
if op == "-h":
print("Usage: python start_receiver.py [--no_tutorial] [--tutorial]")
sys.exit()
if op == "--tutorial":
SKIP_EXISTING = False
if not SKIP_TUTORIAL:
from llmkira.tutorial import show_tutorial
show_tutorial(skip_existing=SKIP_EXISTING, pre_step_stop=4, database_key="01")
# ่ฟ่กไธป็จๅบ
from llmkira.receiver import app
app.run()