Files
assist/src/config/__pycache__/unified_config.cpython-310.pyc

85 lines
9.3 KiB
Plaintext
Raw Normal View History

o
<00><>5iJ'<00>@s<>dZddlZddlZddlZddlmZmZmZddlm Z m
Z
ddl m Z e<03> e<0E>Ze Gdd<07>d<07><02>Ze Gdd <09>d <09><02>Ze Gd
d <0B>d <0B><02>Ze Gd d <0A>d <0A><02>Ze Gdd<0F>d<0F><02>Ze Gdd<11>d<11><02>ZGdd<13>d<13>Zdadefdd<16>Zdd<18>ZdS)uK
统一配置管理模块
整合所有配置,提供统一的配置接口
<EFBFBD>N)<03>Dict<63>Any<6E>Optional)<02> dataclass<73>asdict)<01>Pathc@sNeZdZUdZdZeed<dZeed<dZ eed<dZ
eed <d
Z eed <d S) <0A>DatabaseConfigu数据库配置zRmysql+pymysql://tsp_assistant:password@jeason.online/tsp_assistant?charset=utf8mb4<62>url<72>
<00> pool_size<7A><00> max_overflow<6F><00> pool_timeout<75><00> pool_recycleN) <0C>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r <00>str<74>__annotations__r <00>intr rr<00>rr<00>)/root/assist/src/config/unified_config.pyr<00>
    rc@sfeZdZUdZdZeed<dZeed<dZeed<dZ eed <d
Z
e ed <d Z e ed <dZe ed<dS)<11> LLMConfigu LLM配置<E9858D>qwen<65>providerz#sk-c0dbefa1718d46eaa897199135066f00<30>api_keyz1https://dashscope.aliyuncs.com/compatible-mode/v1<76>base_urlzqwen-plus-latest<73>modelgffffff<66>?<3F> temperaturei<65><00>
max_tokensr<00>timeoutN)rrrrrrrrr r!r"<00>floatr#rr$rrrrr<00>
      rc@sNeZdZUdZdZeed<dZeed<dZ eed<dZ
e ed <d
Z eed <d S) <0A> ServerConfigu服务器配置z0.0.0.0<EFBFBD>hosti<74><00>porti="<00>websocket_portF<74>debug<75>INFO<46> log_levelN) rrrrr(rrr)rr*r+<00>boolr-rrrrr'&rr'c@sfeZdZUdZdZeed<dZeed<dZeed<dZ eed<dZ
eed<d Z e ed
<d Z e ed <d S)<0E> FeishuConfigu 飞书配置<E9858D><00>app_id<69>
app_secret<EFBFBD> app_token<65>table_id<69>active<76>statusr
<00>
sync_limitr<00>auto_sync_intervalN)rrrrr1rrr2r3r4r6r7rr8rrrrr//r&r/c@sreZdZUdZdZeed<dZeed<dZeed<dZ eed<dZ
eed <d
Z e ed <d
Z e ed <d
Ze ed <dS)<0F>AIAccuracyConfiguAI准确率配置gffffff<66>?<3F>auto_approve_thresholdg<64><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?<3F>use_human_resolution_thresholdg<64><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?<3F>manual_review_threshold<6C>ai_suggestion_confidence<63>human_resolution_confidenceT<65>prefer_human_when_low_accuracy<63>enable_auto_approval<61>enable_human_fallbackN)rrrrr:r%rr;r<r=r>r?r.r@rArrrrr9:s
       r9c@sZeZdZUdZdZeed<dZeed<dZ eed<dZ
eed<d Z eed
<dZ eed <d S) <0A> SystemConfigu 系统配置T<E7BDAE>backup_enabled<65><00>backup_interval<61><00>max_backup_files<65> cache_enabledr<00> cache_ttl<74>monitoring_enabledN) rrrrrCr.rrErrGrHrIrJrrrrrBFs
     rBc@seZdZdZd$defdd<05>Zdefdd<08>Zd d
<EFBFBD>Zd d <0C>Z d d<0E>Z
defdd<10>Z de ee ffdd<12>Zde ee ffdd<14>Zde ee ffdd<16>Zde ee ffdd<18>Zde ee ffdd<1A>Zdede ee ffdd<1E>Zdefdd <20>Zde ee ffd!d"<22>Zd#S)%<25> UnifiedConfigu统一配置管理器<E79086>config<69>
config_dircCsTt|<01>|_|jd|_t<03>|_|<00><05>|_t<07>|_t <09>|_
t <0B>|_ t <0A>|_|<00><0F>dS)Nzunified_config.json)rrM<00> config_filer<00>database<73>_load_default_llm_config<69>llmr'<00>serverr/<00>feishur9<00> ai_accuracyrB<00>system<65> load_config)<02>selfrMrrr<00>__init__Ss
 
 zUnifiedConfig.__init__<5F>returnc
Csjzddlm}t|j|j|j|j|j|jd<03>WSt y4}zt
<EFBFBD> d|<02><00><02>t<02>WYd}~Sd}~ww)u加载默认LLM配置r)<01>DEFAULT_CONFIG)rrr r!r"r#u5无法加载默认LLM配置使用内置默认值: N) <0C>config.llm_configrZrrrr r!r"r#<00> Exception<6F>logger<65>warning)rWrZ<00>errrrPbs <08><08><02>z&UnifiedConfig._load_default_llm_configc
CsLz<>|j<00><01>rt|jddd<03><03> }t<03>|<01>}Wd<00>n1swYd|vr1tdi|d<00><01>|_d|vr?tdi|d<00><01>|_d|vrMt di|d<00><01>|_
d|vr[t di|d<00><01>|_ d |vrit di|d <00><01>|_d
|vrwtdi|d
<00><01>|_t<11>d <0B>WdSt<11>d <0C>|<00><13>WdSty<>}zt<11>d |<03><00><02>WYd}~dSd}~ww)u加载配置文件<E69687>r<>utf-8<><01>encodingNrOrQrRrSrTrUu配置文件加载成功u*配置文件不存在使用默认配置u加载配置文件失败: r)rN<00>exists<74>open<65>json<6F>loadrrOrrQr'rRr/rSr9rTrBrUr]<00>info<66> save_configr\<00>error)rW<00>f<> config_datar_rrrrVss0
 <1C>
<08><02>zUnifiedConfig.load_configc
Cs<>zK|jjdd<02>t|j<03>t|j<04>t|j<05>t|j<06>t|j<07>t|j<08>d<03>}t |j
ddd<06><03>}t j ||ddd <09>Wd
<00>n1s?wYt <0A>d <0B>Wd
Styf}zt <0A>d |<03><00><02>WYd
}~d
Sd
}~ww) u保存配置文件T)<01>exist_ok<6F>rOrQrRrSrTrU<00>wrarb<00>F)<02>indent<6E> ensure_asciiNu配置文件保存成功u保存配置文件失败: )rM<00>mkdirrrOrQrRrSrTrUrerNrf<00>dumpr]rhr\rj)rWrlrkr_rrrri<00>s"<06> <1C><08><02>zUnifiedConfig.save_configcCs<>t<00>d<01>r t<00>d<01>|j_t<00>d<02>rt<00>d<02>|j_t<00>d<03>r$t<00>d<03>|j_t<00>d<04>r0t<00>d<04>|j_t<00>d<05>r>tt<00>d<05><01>|j _
t<00>d<06>rJt<00>d<06>|j _ t<00>d<07>rVt<00>d<07>|j _ t<00>d<08>rbt<00>d<08>|j _t<00>d <09>rnt<00>d <09>|j _t<00>d
<EFBFBD>r|t<00>d
<EFBFBD>|j _d Sd S) u从环境变量加载配置<E9858D> DATABASE_URL<52> LLM_PROVIDER<45> LLM_API_KEY<45> LLM_MODEL<45> SERVER_PORT<52> LOG_LEVEL<45> FEISHU_APP_ID<49>FEISHU_APP_SECRET<45>FEISHU_APP_TOKEN<45>FEISHU_TABLE_IDN)<11>os<6F>getenvrOr rQrrr!rrRr)r-rSr1r2r3r4<00>rWrrr<00> load_from_env<6E>s*









<04>zUnifiedConfig.load_from_envcCs|jjS)u获取数据库连接URL)rOr r<>rrr<00>get_database_url<72>szUnifiedConfig.get_database_urlcC<00>
t|j<01>S)u获取LLM配置)rrQr<>rrr<00>get_llm_config<69><00>
zUnifiedConfig.get_llm_configcCr<>)u获取服务器配置)rrRr<>rrr<00>get_server_config<69>r<>zUnifiedConfig.get_server_configcCr<>)u获取飞书配置)rrSr<>rrr<00>get_feishu_config<69>r<>zUnifiedConfig.get_feishu_configcCr<>)u获取AI准确率配置)rrTr<>rrr<00>get_ai_accuracy_config<69>r<>z$UnifiedConfig.get_ai_accuracy_configcCr<>)u获取系统配置)rrUr<>rrr<00>get_system_config<69>r<>zUnifiedConfig.get_system_config<69>sectionrlc
Cs<>ze|dkrtd i|<02><01>|_nH|dkrtd i|<02><01>|_n;|dkr(td i|<02><01>|_n.|dkr5td i|<02><01>|_n!|dkrBtd i|<02><01>|_ n|dkrOt
d i|<02><01>|_ nt d|<01><00><02><01>|<00> <0A>t<0E>d|<01>d <09><03>Wd Styz}z t<0E>d
|<03><00><02><00>d }~ww) u 更新配置rOrQrRrSrTrUu未知的配置节: u
配置节 u 更新成功u更新配置失败: Nr)rrOrrQr'rRr/rSr9rTrBrU<00>
ValueErrorrir]rhr\rj)rWr<>rlr_rrr<00> update_config<69>s*<08><02>zUnifiedConfig.update_configc
Cs<>z8|jjs t<02>d<01>WdS|jjst<02>d<03>|jjdkr1t |jj
|jj |jj |jj g<04>s1t<02>d<05>t<02>d<06>WdStyS}zt<02>d|<01><00><02>WYd }~dSd }~ww)
u验证配置有效性u数据库URL未配置FuLLM API密钥未配置r5u飞书配置不完整u配置验证通过Tu配置验证失败: N)rOr r]rjrQrr^rSr6<00>allr1r2r3r4rhr\)rWr_rrr<00>validate_config<69>s$

  <06>

<08><02>zUnifiedConfig.validate_configcCs6t|j<01>t|j<02>t|j<03>t|j<04>t|j<05>t|j<06>d<01>S)u获取所有配置rn)rrOrQrRrSrTrUr<>rrr<00>get_all_configs<06>zUnifiedConfig.get_all_configN)rL)rrrrrrXrrPrVrir<>r<>rrr<>r<>r<>r<>r<>r<>r.r<>r<>rrrrrKPs rKrYcCstdur t<01>at<00><02>tS)u获取全局配置实例N)<03>_config_instancerKr<>rrrr<00>
get_configsr<>cCs
dat<01>S)u重新加载配置N)r<>r<>rrrr<00> reload_config$sr<>)rrrf<00>logging<6E>typingrrr<00> dataclassesrr<00>pathlibr<00> getLoggerrr]rrr'r/r9rBrKr<>r<>r<>rrrr<00><module>s2 


  K