-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathconstant.py
91 lines (69 loc) · 2.53 KB
/
constant.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import os
from dotenv import load_dotenv
import platform
# utils:
load_dotenv() # 加载.env文件
def str_to_bool(value):
"""convert string to bool"""
true_values = {'true', 'yes', '1', 'on', 't', 'y'}
false_values = {'false', 'no', '0', 'off', 'f', 'n'}
if isinstance(value, bool):
return value
if value == None:
return None
value = str(value).lower().strip()
if value in true_values:
return True
if value in false_values:
return False
return True # default return True
DOCKER_WORKPLACE_NAME = os.getenv('DOCKER_WORKPLACE_NAME', 'workplace')
GITHUB_AI_TOKEN = os.getenv('GITHUB_AI_TOKEN', None)
AI_USER = os.getenv('AI_USER', "tjb-tech")
LOCAL_ROOT = os.getenv('LOCAL_ROOT', os.getcwd())
DEBUG = str_to_bool(os.getenv('DEBUG', False))
DEFAULT_LOG = str_to_bool(os.getenv('DEFAULT_LOG', False))
LOG_PATH = os.getenv('LOG_PATH', None)
EVAL_MODE = str_to_bool(os.getenv('EVAL_MODE', False))
BASE_IMAGES = os.getenv('BASE_IMAGES', None)
def get_architecture():
machine = platform.machine().lower()
if 'x86' in machine or 'amd64' in machine or 'i386' in machine:
return "tjbtech1/metachain:amd64_latest"
elif 'arm' in machine:
return "tjbtech1/metachain:latest"
else:
return "tjbtech1/metachain:latest"
if BASE_IMAGES is None:
BASE_IMAGES = get_architecture()
COMPLETION_MODEL = os.getenv('COMPLETION_MODEL', "claude-3-5-sonnet-20241022")
EMBEDDING_MODEL = os.getenv('EMBEDDING_MODEL', "text-embedding-3-small")
MC_MODE = str_to_bool(os.getenv('MC_MODE', True))
# add Env for function call and non-function call
FN_CALL = str_to_bool(os.getenv('FN_CALL', None))
API_BASE_URL = os.getenv('API_BASE_URL', None)
ADD_USER = str_to_bool(os.getenv('ADD_USER', None))
NOT_SUPPORT_SENDER = ["mistral", "groq"]
MUST_ADD_USER = ["deepseek-reasoner", "o1-mini", "deepseek-r1"]
NOT_SUPPORT_FN_CALL = ["o1-mini", "deepseek-reasoner", "deepseek-r1", "llama", "grok-2"]
NOT_USE_FN_CALL = [ "deepseek-chat"] + NOT_SUPPORT_FN_CALL
if ADD_USER is None:
ADD_USER = False
for model in MUST_ADD_USER:
if model in COMPLETION_MODEL:
ADD_USER = True
break
if FN_CALL is None:
FN_CALL = True
for model in NOT_USE_FN_CALL:
if model in COMPLETION_MODEL:
FN_CALL = False
break
NON_FN_CALL = False
for model in NOT_SUPPORT_FN_CALL:
if model in COMPLETION_MODEL:
NON_FN_CALL = True
break
if EVAL_MODE:
DEFAULT_LOG = False
# print(FN_CALL, NON_FN_CALL, ADD_USER)