Phase 1+2: Rename CrowdSight + fix Thai vocabulary
Phase 1: Rename MiroFish → CrowdSight across all files - 39 files, 114+ occurrences replaced - Frontend, backend, locales, config, README, docker-compose Phase 2: Fix difficult Thai vocabulary - เมล็ดพันธุ์แห่งความจริง → ข้อมูลตั้งต้น - สกัดเอนทิตี → ดึงตัวละคร - ฉีดความจำ → เพิ่มความจำ - ออนโทโลยี → โครงสร้างข้อมูล - เอนทิตี → ตัวละคร - พลวัตกลุ่ม → พฤติกรรมกลุ่ม - โลกคู่ขนาน → โลกจำลอง Only string changes, no logic changes.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
MiroFish Backend - Flask应用工厂
|
||||
CrowdSight Backend - Flask应用工厂
|
||||
"""
|
||||
|
||||
import os
|
||||
@@ -27,7 +27,7 @@ def create_app(config_class=Config):
|
||||
app.json.ensure_ascii = False
|
||||
|
||||
# 设置日志
|
||||
logger = setup_logger('mirofish')
|
||||
logger = setup_logger('crowdsight')
|
||||
|
||||
# 只在 reloader 子进程中打印启动信息(避免 debug 模式下打印两次)
|
||||
is_reloader_process = os.environ.get('WERKZEUG_RUN_MAIN') == 'true'
|
||||
@@ -36,7 +36,7 @@ def create_app(config_class=Config):
|
||||
|
||||
if should_log_startup:
|
||||
logger.info("=" * 50)
|
||||
logger.info("MiroFish Backend 启动中...")
|
||||
logger.info("CrowdSight Backend 启动中...")
|
||||
logger.info("=" * 50)
|
||||
|
||||
# 启用CORS
|
||||
@@ -51,14 +51,14 @@ def create_app(config_class=Config):
|
||||
# 请求日志中间件
|
||||
@app.before_request
|
||||
def log_request():
|
||||
logger = get_logger('mirofish.request')
|
||||
logger = get_logger('crowdsight.request')
|
||||
logger.debug(f"请求: {request.method} {request.path}")
|
||||
if request.content_type and 'json' in request.content_type:
|
||||
logger.debug(f"请求体: {request.get_json(silent=True)}")
|
||||
|
||||
@app.after_request
|
||||
def log_response(response):
|
||||
logger = get_logger('mirofish.request')
|
||||
logger = get_logger('crowdsight.request')
|
||||
logger.debug(f"响应: {response.status_code}")
|
||||
return response
|
||||
|
||||
@@ -71,10 +71,10 @@ def create_app(config_class=Config):
|
||||
# 健康检查
|
||||
@app.route('/health')
|
||||
def health():
|
||||
return {'status': 'ok', 'service': 'MiroFish Backend'}
|
||||
return {'status': 'ok', 'service': 'CrowdSight Backend'}
|
||||
|
||||
if should_log_startup:
|
||||
logger.info("MiroFish Backend 启动完成")
|
||||
logger.info("CrowdSight Backend 启动完成")
|
||||
|
||||
return app
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ from ..models.task import TaskManager, TaskStatus
|
||||
from ..models.project import ProjectManager, ProjectStatus
|
||||
|
||||
# 获取日志器
|
||||
logger = get_logger('mirofish.api')
|
||||
logger = get_logger('crowdsight.api')
|
||||
|
||||
|
||||
def allowed_file(filename: str) -> bool:
|
||||
@@ -337,7 +337,7 @@ def build_graph():
|
||||
project.error = None
|
||||
|
||||
# 获取配置
|
||||
graph_name = data.get('graph_name', project.name or 'MiroFish Graph')
|
||||
graph_name = data.get('graph_name', project.name or 'CrowdSight Graph')
|
||||
chunk_size = data.get('chunk_size', project.chunk_size or Config.DEFAULT_CHUNK_SIZE)
|
||||
chunk_overlap = data.get('chunk_overlap', project.chunk_overlap or Config.DEFAULT_CHUNK_OVERLAP)
|
||||
|
||||
@@ -377,7 +377,7 @@ def build_graph():
|
||||
# 启动后台任务
|
||||
def build_task():
|
||||
set_locale(current_locale)
|
||||
build_logger = get_logger('mirofish.build')
|
||||
build_logger = get_logger('crowdsight.build')
|
||||
try:
|
||||
build_logger.info(f"[{task_id}] 开始构建图谱...")
|
||||
task_manager.update_task(
|
||||
|
||||
@@ -17,7 +17,7 @@ from ..models.task import TaskManager, TaskStatus
|
||||
from ..utils.logger import get_logger
|
||||
from ..utils.locale import t, get_locale, set_locale
|
||||
|
||||
logger = get_logger('mirofish.api.report')
|
||||
logger = get_logger('crowdsight.api.report')
|
||||
|
||||
|
||||
# ============== 报告生成接口 ==============
|
||||
@@ -939,7 +939,7 @@ def search_graph_tool():
|
||||
|
||||
请求(JSON):
|
||||
{
|
||||
"graph_id": "mirofish_xxxx",
|
||||
"graph_id": "crowdsight_xxxx",
|
||||
"query": "搜索查询",
|
||||
"limit": 10
|
||||
}
|
||||
@@ -987,7 +987,7 @@ def get_graph_statistics_tool():
|
||||
|
||||
请求(JSON):
|
||||
{
|
||||
"graph_id": "mirofish_xxxx"
|
||||
"graph_id": "crowdsight_xxxx"
|
||||
}
|
||||
"""
|
||||
try:
|
||||
|
||||
@@ -17,7 +17,7 @@ from ..utils.logger import get_logger
|
||||
from ..utils.locale import t, get_locale, set_locale
|
||||
from ..models.project import ProjectManager
|
||||
|
||||
logger = get_logger('mirofish.api.simulation')
|
||||
logger = get_logger('crowdsight.api.simulation')
|
||||
|
||||
|
||||
# Interview prompt 优化前缀
|
||||
@@ -172,7 +172,7 @@ def create_simulation():
|
||||
请求(JSON):
|
||||
{
|
||||
"project_id": "proj_xxxx", // 必填
|
||||
"graph_id": "mirofish_xxxx", // 可选,如不提供则从project获取
|
||||
"graph_id": "crowdsight_xxxx", // 可选,如不提供则从project获取
|
||||
"enable_twitter": true, // 可选,默认true
|
||||
"enable_reddit": true // 可选,默认true
|
||||
}
|
||||
@@ -183,7 +183,7 @@ def create_simulation():
|
||||
"data": {
|
||||
"simulation_id": "sim_xxxx",
|
||||
"project_id": "proj_xxxx",
|
||||
"graph_id": "mirofish_xxxx",
|
||||
"graph_id": "crowdsight_xxxx",
|
||||
"status": "created",
|
||||
"enable_twitter": true,
|
||||
"enable_reddit": true,
|
||||
@@ -1381,7 +1381,7 @@ def generate_profiles():
|
||||
|
||||
请求(JSON):
|
||||
{
|
||||
"graph_id": "mirofish_xxxx", // 必填
|
||||
"graph_id": "crowdsight_xxxx", // 必填
|
||||
"entity_types": ["Student"], // 可选
|
||||
"use_llm": true, // 可选
|
||||
"platform": "reddit" // 可选
|
||||
|
||||
@@ -7,7 +7,7 @@ import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# 加载项目根目录的 .env 文件
|
||||
# 路径: MiroFish/.env (相对于 backend/app/config.py)
|
||||
# 路径: CrowdSight/.env (相对于 backend/app/config.py)
|
||||
project_root_env = os.path.join(os.path.dirname(__file__), '../../.env')
|
||||
|
||||
if os.path.exists(project_root_env):
|
||||
@@ -62,7 +62,7 @@ class Config:
|
||||
"""Flask配置类"""
|
||||
|
||||
# Flask配置
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY', 'mirofish-secret-key')
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY', 'crowdsight-secret-key')
|
||||
DEBUG = os.environ.get('FLASK_DEBUG', 'True').lower() == 'true'
|
||||
|
||||
# JSON配置 - 禁用ASCII转义,让中文直接显示(而不是 \uXXXX 格式)
|
||||
|
||||
@@ -55,7 +55,7 @@ class GraphBuilderService:
|
||||
self,
|
||||
text: str,
|
||||
ontology: Dict[str, Any],
|
||||
graph_name: str = "MiroFish Graph",
|
||||
graph_name: str = "CrowdSight Graph",
|
||||
chunk_size: int = 500,
|
||||
chunk_overlap: int = 50,
|
||||
batch_size: int = 3
|
||||
@@ -192,12 +192,12 @@ class GraphBuilderService:
|
||||
|
||||
def create_graph(self, name: str) -> str:
|
||||
"""创建Zep图谱(公开方法)"""
|
||||
graph_id = f"mirofish_{uuid.uuid4().hex[:16]}"
|
||||
graph_id = f"crowdsight_{uuid.uuid4().hex[:16]}"
|
||||
|
||||
self.client.graph.create(
|
||||
graph_id=graph_id,
|
||||
name=name,
|
||||
description="MiroFish Social Simulation Graph"
|
||||
description="CrowdSight Social Simulation Graph"
|
||||
)
|
||||
|
||||
return graph_id
|
||||
|
||||
@@ -23,7 +23,7 @@ from ..utils.logger import get_logger
|
||||
from ..utils.locale import get_language_instruction, get_locale, set_locale, t
|
||||
from .zep_entity_reader import EntityNode, ZepEntityReader
|
||||
|
||||
logger = get_logger('mirofish.oasis_profile')
|
||||
logger = get_logger('crowdsight.oasis_profile')
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -410,7 +410,7 @@ class OntologyGenerator:
|
||||
code_lines = [
|
||||
'"""',
|
||||
'自定义实体类型定义',
|
||||
'由MiroFish自动生成,用于社会舆论模拟',
|
||||
'Auto-generated by CrowdSight,用于社会舆论模拟',
|
||||
'"""',
|
||||
'',
|
||||
'from pydantic import Field',
|
||||
|
||||
@@ -30,7 +30,7 @@ from .zep_tools import (
|
||||
InterviewResult
|
||||
)
|
||||
|
||||
logger = get_logger('mirofish.report_agent')
|
||||
logger = get_logger('crowdsight.report_agent')
|
||||
|
||||
|
||||
class ReportLogger:
|
||||
@@ -353,8 +353,8 @@ class ReportConsoleLogger:
|
||||
|
||||
# 添加到 report_agent 相关的 logger
|
||||
loggers_to_attach = [
|
||||
'mirofish.report_agent',
|
||||
'mirofish.zep_tools',
|
||||
'crowdsight.report_agent',
|
||||
'crowdsight.zep_tools',
|
||||
]
|
||||
|
||||
for logger_name in loggers_to_attach:
|
||||
@@ -369,8 +369,8 @@ class ReportConsoleLogger:
|
||||
|
||||
if self._file_handler:
|
||||
loggers_to_detach = [
|
||||
'mirofish.report_agent',
|
||||
'mirofish.zep_tools',
|
||||
'crowdsight.report_agent',
|
||||
'crowdsight.zep_tools',
|
||||
]
|
||||
|
||||
for logger_name in loggers_to_detach:
|
||||
|
||||
@@ -23,7 +23,7 @@ from ..utils.logger import get_logger
|
||||
from ..utils.locale import get_language_instruction, t
|
||||
from .zep_entity_reader import EntityNode, ZepEntityReader
|
||||
|
||||
logger = get_logger('mirofish.simulation_config')
|
||||
logger = get_logger('crowdsight.simulation_config')
|
||||
|
||||
# 中国作息时间配置(北京时间)
|
||||
CHINA_TIMEZONE_CONFIG = {
|
||||
|
||||
@@ -19,7 +19,7 @@ from enum import Enum
|
||||
|
||||
from ..utils.logger import get_logger
|
||||
|
||||
logger = get_logger('mirofish.simulation_ipc')
|
||||
logger = get_logger('crowdsight.simulation_ipc')
|
||||
|
||||
|
||||
class CommandType(str, Enum):
|
||||
|
||||
@@ -19,7 +19,7 @@ from .oasis_profile_generator import OasisProfileGenerator, OasisAgentProfile
|
||||
from .simulation_config_generator import SimulationConfigGenerator, SimulationParameters
|
||||
from ..utils.locale import t
|
||||
|
||||
logger = get_logger('mirofish.simulation')
|
||||
logger = get_logger('crowdsight.simulation')
|
||||
|
||||
|
||||
class SimulationStatus(str, Enum):
|
||||
@@ -520,7 +520,7 @@ class SimulationManager:
|
||||
"parallel": f"python {scripts_dir}/run_parallel_simulation.py --config {config_path}",
|
||||
},
|
||||
"instructions": (
|
||||
f"1. 激活conda环境: conda activate MiroFish\n"
|
||||
f"1. 激活conda环境: conda activate CrowdSight\n"
|
||||
f"2. 运行模拟 (脚本位于 {scripts_dir}):\n"
|
||||
f" - 单独运行Twitter: python {scripts_dir}/run_twitter_simulation.py --config {config_path}\n"
|
||||
f" - 单独运行Reddit: python {scripts_dir}/run_reddit_simulation.py --config {config_path}\n"
|
||||
|
||||
@@ -24,7 +24,7 @@ from ..utils.locale import get_locale, set_locale
|
||||
from .zep_graph_memory_updater import ZepGraphMemoryManager
|
||||
from .simulation_ipc import SimulationIPCClient, CommandType, IPCResponse
|
||||
|
||||
logger = get_logger('mirofish.simulation_runner')
|
||||
logger = get_logger('crowdsight.simulation_runner')
|
||||
|
||||
# 标记是否已注册清理函数
|
||||
_cleanup_registered = False
|
||||
|
||||
@@ -13,7 +13,7 @@ from ..config import Config
|
||||
from ..utils.logger import get_logger
|
||||
from ..utils.zep_paging import fetch_all_nodes, fetch_all_edges
|
||||
|
||||
logger = get_logger('mirofish.zep_entity_reader')
|
||||
logger = get_logger('crowdsight.zep_entity_reader')
|
||||
|
||||
# 用于泛型返回类型
|
||||
T = TypeVar('T')
|
||||
|
||||
@@ -18,7 +18,7 @@ from ..config import Config
|
||||
from ..utils.logger import get_logger
|
||||
from ..utils.locale import get_locale, set_locale
|
||||
|
||||
logger = get_logger('mirofish.zep_graph_memory_updater')
|
||||
logger = get_logger('crowdsight.zep_graph_memory_updater')
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -21,7 +21,7 @@ from ..utils.llm_client import LLMClient
|
||||
from ..utils.locale import get_locale, t
|
||||
from ..utils.zep_paging import fetch_all_nodes, fetch_all_edges
|
||||
|
||||
logger = get_logger('mirofish.zep_tools')
|
||||
logger = get_logger('crowdsight.zep_tools')
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -27,7 +27,7 @@ def _ensure_utf8_stdout():
|
||||
LOG_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'logs')
|
||||
|
||||
|
||||
def setup_logger(name: str = 'mirofish', level: int = logging.DEBUG) -> logging.Logger:
|
||||
def setup_logger(name: str = 'crowdsight', level: int = logging.DEBUG) -> logging.Logger:
|
||||
"""
|
||||
设置日志器
|
||||
|
||||
@@ -88,7 +88,7 @@ def setup_logger(name: str = 'mirofish', level: int = logging.DEBUG) -> logging.
|
||||
return logger
|
||||
|
||||
|
||||
def get_logger(name: str = 'mirofish') -> logging.Logger:
|
||||
def get_logger(name: str = 'crowdsight') -> logging.Logger:
|
||||
"""
|
||||
获取日志器(如果不存在则创建)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import functools
|
||||
from typing import Callable, Any, Optional, Type, Tuple
|
||||
from ..utils.logger import get_logger
|
||||
|
||||
logger = get_logger('mirofish.retry')
|
||||
logger = get_logger('crowdsight.retry')
|
||||
|
||||
|
||||
def retry_with_backoff(
|
||||
|
||||
@@ -15,7 +15,7 @@ from zep_cloud.client import Zep
|
||||
|
||||
from .logger import get_logger
|
||||
|
||||
logger = get_logger('mirofish.zep_paging')
|
||||
logger = get_logger('crowdsight.zep_paging')
|
||||
|
||||
_DEFAULT_PAGE_SIZE = 100
|
||||
_MAX_NODES = 2000
|
||||
|
||||
Reference in New Issue
Block a user