fix:domain map
This commit is contained in:
@@ -554,6 +554,16 @@ class InputParser:
|
||||
except (FileNotFoundError, json.JSONDecodeError) as e:
|
||||
self.logger.warning(f"Could not load or parse domain map file '{domain_mapping_path}'. Using default domain. Error: {e}")
|
||||
DOMAIN_MAP = {}
|
||||
|
||||
# 🔧 构建关键词到领域ID的映射表
|
||||
keyword_to_domain_id = {}
|
||||
for domain_id, domain_info in DOMAIN_MAP.items():
|
||||
if isinstance(domain_info, dict) and 'keywords' in domain_info:
|
||||
keywords = domain_info['keywords']
|
||||
if isinstance(keywords, list):
|
||||
for keyword in keywords:
|
||||
keyword_to_domain_id[keyword] = domain_id
|
||||
self.logger.debug(f"映射关键词 '{keyword}' -> 领域ID '{domain_id}'")
|
||||
|
||||
list_url = urljoin(base_url, "/api/schema/manage/schema")
|
||||
self.logger.info(f"Fetching API list from: {list_url}")
|
||||
@@ -591,7 +601,22 @@ class InputParser:
|
||||
self.logger.warning(f"Skipping an item in API list because it's missing 'domain', 'name', or 'id': {item}")
|
||||
continue
|
||||
|
||||
instance_code = DOMAIN_MAP.get(domain_name, domain_name)
|
||||
# 🔧 改进领域映射:支持精确匹配和前缀匹配
|
||||
instance_code = keyword_to_domain_id.get(domain_name)
|
||||
if instance_code:
|
||||
self.logger.info(f"通过精确关键词匹配:'{domain_name}' -> '{instance_code}'")
|
||||
else:
|
||||
# 尝试前缀匹配(如wb_cd匹配wb)
|
||||
for keyword, domain_id in keyword_to_domain_id.items():
|
||||
if domain_name.startswith(keyword + '_'): # wb_cd以wb_开头
|
||||
instance_code = domain_id
|
||||
self.logger.info(f"通过前缀关键词匹配:'{domain_name}' -> '{instance_code}' (匹配关键词: '{keyword}')")
|
||||
break
|
||||
|
||||
if not instance_code:
|
||||
# Fallback到原有的直接映射
|
||||
instance_code = DOMAIN_MAP.get(domain_name, domain_name)
|
||||
self.logger.info(f"使用直接映射:'{domain_name}' -> '{instance_code}'")
|
||||
model_url = urljoin(base_url, f"/api/schema/manage/schema/{model_id}")
|
||||
self.logger.info(f"Fetching model for '{name}' from: {model_url}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user