be52af70
tangwang
first commit
|
1
|
"""
|
86d8358b
tangwang
config optimize
|
2
|
Compatibility accessors for infrastructure/runtime environment settings.
|
be52af70
tangwang
first commit
|
3
|
|
86d8358b
tangwang
config optimize
|
4
5
|
All values are derived from the unified application config. This module no
longer owns any independent loading or precedence rules.
|
be52af70
tangwang
first commit
|
6
7
|
"""
|
86d8358b
tangwang
config optimize
|
8
9
10
11
12
|
from __future__ import annotations
from typing import Any, Dict
from config.loader import get_app_config
|
daa2690b
tangwang
漏斗参数调优&呈现优化
|
13
|
from config.services_config import get_rerank_service_url
|
86d8358b
tangwang
config optimize
|
14
15
16
17
18
19
20
21
|
def _app():
return get_app_config()
def _runtime():
return _app().runtime
|
be52af70
tangwang
first commit
|
22
|
|
be52af70
tangwang
first commit
|
23
|
|
86d8358b
tangwang
config optimize
|
24
25
|
def _infra():
return _app().infrastructure
|
be52af70
tangwang
first commit
|
26
|
|
1852e3e3
tangwang
添加Base配置演示流程和数据库配置
|
27
|
|
86d8358b
tangwang
config optimize
|
28
29
30
31
32
33
34
|
def _elasticsearch_dict() -> Dict[str, Any]:
cfg = _infra().elasticsearch
return {
"host": cfg.host,
"username": cfg.username,
"password": cfg.password,
}
|
be52af70
tangwang
first commit
|
35
|
|
be52af70
tangwang
first commit
|
36
|
|
86d8358b
tangwang
config optimize
|
37
38
39
40
41
42
43
44
45
46
47
48
|
def _redis_dict() -> Dict[str, Any]:
cfg = _infra().redis
return {
"host": cfg.host,
"port": cfg.port,
"snapshot_db": cfg.snapshot_db,
"password": cfg.password,
"socket_timeout": cfg.socket_timeout,
"socket_connect_timeout": cfg.socket_connect_timeout,
"retry_on_timeout": cfg.retry_on_timeout,
"cache_expire_days": cfg.cache_expire_days,
"embedding_cache_prefix": cfg.embedding_cache_prefix,
|
86d8358b
tangwang
config optimize
|
49
|
}
|
be52af70
tangwang
first commit
|
50
|
|
be52af70
tangwang
first commit
|
51
|
|
86d8358b
tangwang
config optimize
|
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
92
93
|
def _db_dict() -> Dict[str, Any]:
cfg = _infra().database
return {
"host": cfg.host,
"port": cfg.port,
"database": cfg.database,
"username": cfg.username,
"password": cfg.password,
}
ES_CONFIG = _elasticsearch_dict()
REDIS_CONFIG = _redis_dict()
DB_CONFIG = _db_dict()
RUNTIME_ENV = _runtime().environment
ES_INDEX_NAMESPACE = _runtime().index_namespace
DEEPL_AUTH_KEY = _infra().secrets.deepl_auth_key
DASHSCOPE_API_KEY = _infra().secrets.dashscope_api_key
API_HOST = _runtime().api_host
API_PORT = _runtime().api_port
INDEXER_HOST = _runtime().indexer_host
INDEXER_PORT = _runtime().indexer_port
EMBEDDING_HOST = _runtime().embedding_host
EMBEDDING_PORT = _runtime().embedding_port
EMBEDDING_TEXT_HOST = _runtime().embedding_host
EMBEDDING_TEXT_PORT = _runtime().embedding_text_port
EMBEDDING_IMAGE_HOST = _runtime().embedding_host
EMBEDDING_IMAGE_PORT = _runtime().embedding_image_port
TRANSLATION_HOST = _runtime().translator_host
TRANSLATION_PORT = _runtime().translator_port
RERANKER_HOST = _runtime().reranker_host
RERANKER_PORT = _runtime().reranker_port
API_BASE_URL = f"http://localhost:{API_PORT}" if API_HOST == "0.0.0.0" else f"http://{API_HOST}:{API_PORT}"
INDEXER_BASE_URL = (
f"http://localhost:{INDEXER_PORT}" if INDEXER_HOST == "0.0.0.0" else f"http://{INDEXER_HOST}:{INDEXER_PORT}"
)
EMBEDDING_TEXT_SERVICE_URL = _app().services.embedding.get_provider_config().get("text_base_url")
EMBEDDING_IMAGE_SERVICE_URL = _app().services.embedding.get_provider_config().get("image_base_url")
|
daa2690b
tangwang
漏斗参数调优&呈现优化
|
94
|
RERANKER_SERVICE_URL = get_rerank_service_url()
|
86d8358b
tangwang
config optimize
|
95
|
|
be52af70
tangwang
first commit
|
96
|
|
86d8358b
tangwang
config optimize
|
97
98
|
def get_es_config() -> Dict[str, Any]:
return dict(ES_CONFIG)
|
be52af70
tangwang
first commit
|
99
|
|
be52af70
tangwang
first commit
|
100
|
|
86d8358b
tangwang
config optimize
|
101
102
|
def get_db_config() -> Dict[str, Any]:
return dict(DB_CONFIG)
|
be52af70
tangwang
first commit
|
103
|
|
1852e3e3
tangwang
添加Base配置演示流程和数据库配置
|
104
|
|
86d8358b
tangwang
config optimize
|
105
106
|
def get_redis_config() -> Dict[str, Any]:
return dict(REDIS_CONFIG)
|
be52af70
tangwang
first commit
|
107
108
|
|
86d8358b
tangwang
config optimize
|
109
110
111
|
def print_config() -> None:
config = _app().sanitized_dict()
print(config)
|