Spaces:
Sleeping
Sleeping
Rename app_config.py to config.py
Browse files- app_config.py → config.py +31 -10
app_config.py → config.py
RENAMED
|
@@ -4,15 +4,20 @@ import streamlit as st
|
|
| 4 |
|
| 5 |
def load_config():
|
| 6 |
base_config = {
|
|
|
|
| 7 |
"lit_target_papers": int(os.environ.get("LIT_TARGET_PAPERS", "250")),
|
| 8 |
"lit_per_page": int(os.environ.get("LIT_PER_PAGE", "100")),
|
| 9 |
"lit_max_workers": int(os.environ.get("LIT_MAX_WORKERS", "5")),
|
| 10 |
"lit_max_page_batches": int(os.environ.get("LIT_MAX_PAGE_BATCHES", "12")),
|
| 11 |
"chunk_words_default": int(os.environ.get("CHUNK_WORDS_DEFAULT", "1500")),
|
| 12 |
"chunk_words_cyrillic": int(os.environ.get("CHUNK_WORDS_CYRILLIC", "1000")),
|
|
|
|
|
|
|
| 13 |
"deepseek_api_url": os.environ.get("DEEPSEEK_API_URL", "https://api.deepseek.com/chat/completions"),
|
| 14 |
"openalex_api_url": os.environ.get("OPENALEX_API_URL", "https://api.openalex.org/works"),
|
| 15 |
"s2_api_url": os.environ.get("S2_API_URL", "https://api.semanticscholar.org/graph/v1"),
|
|
|
|
|
|
|
| 16 |
"ui_labels": {
|
| 17 |
"中文": {"title": "📊 科研论文智能体", "btn_generate": "🚀 生成初稿", "btn_download": "📥 下载文件", "topic_label": "📝 论文名称", "keywords_label": "🔍 关键字", "words_label": "📏 目标总字数 (12000-25000字)", "success": "🎉 流水线推演完毕!双语文档已就绪。"},
|
| 18 |
"English": {"title": "📊 Article AI Agent", "btn_generate": "🚀 Generate Draft", "btn_download": "📥 Download", "topic_label": "📝 Article Title", "keywords_label": "🔍 Keywords", "words_label": "📏 Target Word Count", "success": "🎉 Task complete!"},
|
|
@@ -25,6 +30,28 @@ def load_config():
|
|
| 25 |
"Русский": "Russian (Русский)",
|
| 26 |
"Қазақша": "Kazakh (Қазақша)"
|
| 27 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
}
|
| 29 |
|
| 30 |
generic_prompts = {
|
|
@@ -59,19 +86,13 @@ def load_config():
|
|
| 59 |
"empirical_data_logic": "Maintain strict adherence to APA 7th edition reporting standards. Include plausible degrees of freedom, exact p-values, confidence intervals, and effect sizes.",
|
| 60 |
}
|
| 61 |
|
| 62 |
-
# 新增:提示词模板(用于减少硬编码)
|
| 63 |
-
targeted_directives = {
|
| 64 |
-
"introduction": "你必须审视 [TARGETED INJECTION] 中列出的核心文献的局限性与未来展望 (Future Gaps)。禁止泛泛而谈研究背景。你必须将本研究定位为对这些明确 Gaps 的直接回应,建立极强的学术对话感。",
|
| 65 |
-
"literature": "严禁简单罗列前人观点或凭空捏造机制。你必须明确使用 [TARGETED INJECTION] 中提供的理论视角 (Theoretical Lens) 作为推导的底层逻辑。你的论证过程必须引用这些核心文献已验证的因果路径,说明新假设是如何在它们的肩膀上向前推演的。",
|
| 66 |
-
"methodology": "在撰写测量工具 (Measures) 时,你必须明确声明我们的问卷题项改编自 [TARGETED INJECTION] 中记录的核心文献,以此证明量表具有极高的历史信度与效度。将注入的 Items 自然融入行文中。",
|
| 67 |
-
"results": "【绝对数据忠诚指令】你现在是一个没有感情的统计报告员。1. 必须逐字逐句将 <USER_ACTUAL_DATA> 翻译为规范的学术段落。2. 绝对禁止生成任何表格中不存在的 P值、T值或 R²。3. 必须逐一核对 【ESTABLISHED HYPOTHESES】,并在段末明确写出判定 (如 'H1 is supported')。禁止在此进行理论探讨。",
|
| 68 |
-
"discussion": "【理论回声与升华指令】本章是全篇灵魂。1. 不要简单重复结果,必须将本研究成立的假设与 [TARGETED INJECTION] 中核心文献的发现进行结构化对比,指出是印证了前人还是得出了矛盾/新边界。2. 基于对比提供高度可操作的管理启示。3. 诚实反思局限并提供具体研究方向。"
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
default_config = base_config.copy()
|
| 72 |
default_config.update(generic_prompts)
|
| 73 |
-
default_config["targeted_directives"] = targeted_directives # 注入模板
|
| 74 |
return default_config, amj_prompts, generic_prompts
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
DEFAULT_CONFIG, AMJ_PROMPTS, GENERIC_PROMPTS = load_config()
|
| 77 |
APP_CONFIG = DEFAULT_CONFIG.copy()
|
|
|
|
| 4 |
|
| 5 |
def load_config():
|
| 6 |
base_config = {
|
| 7 |
+
# --- 基础运行参数 ---
|
| 8 |
"lit_target_papers": int(os.environ.get("LIT_TARGET_PAPERS", "250")),
|
| 9 |
"lit_per_page": int(os.environ.get("LIT_PER_PAGE", "100")),
|
| 10 |
"lit_max_workers": int(os.environ.get("LIT_MAX_WORKERS", "5")),
|
| 11 |
"lit_max_page_batches": int(os.environ.get("LIT_MAX_PAGE_BATCHES", "12")),
|
| 12 |
"chunk_words_default": int(os.environ.get("CHUNK_WORDS_DEFAULT", "1500")),
|
| 13 |
"chunk_words_cyrillic": int(os.environ.get("CHUNK_WORDS_CYRILLIC", "1000")),
|
| 14 |
+
|
| 15 |
+
# --- API 节点配置 ---
|
| 16 |
"deepseek_api_url": os.environ.get("DEEPSEEK_API_URL", "https://api.deepseek.com/chat/completions"),
|
| 17 |
"openalex_api_url": os.environ.get("OPENALEX_API_URL", "https://api.openalex.org/works"),
|
| 18 |
"s2_api_url": os.environ.get("S2_API_URL", "https://api.semanticscholar.org/graph/v1"),
|
| 19 |
+
|
| 20 |
+
# --- UI 多语言标签 ---
|
| 21 |
"ui_labels": {
|
| 22 |
"中文": {"title": "📊 科研论文智能体", "btn_generate": "🚀 生成初稿", "btn_download": "📥 下载文件", "topic_label": "📝 论文名称", "keywords_label": "🔍 关键字", "words_label": "📏 目标总字数 (12000-25000字)", "success": "🎉 流水线推演完毕!双语文档已就绪。"},
|
| 23 |
"English": {"title": "📊 Article AI Agent", "btn_generate": "🚀 Generate Draft", "btn_download": "📥 Download", "topic_label": "📝 Article Title", "keywords_label": "🔍 Keywords", "words_label": "📏 Target Word Count", "success": "🎉 Task complete!"},
|
|
|
|
| 30 |
"Русский": "Russian (Русский)",
|
| 31 |
"Қазақша": "Kazakh (Қазақша)"
|
| 32 |
},
|
| 33 |
+
|
| 34 |
+
# --- 🚨 新增:系统全局核心配置 (去硬编码) ---
|
| 35 |
+
"workspace_dir": ".workspace",
|
| 36 |
+
"max_extract_chars": 150000,
|
| 37 |
+
|
| 38 |
+
# --- 🚨 新增:Word 渲染器样式配置 ---
|
| 39 |
+
"docx_styles": {
|
| 40 |
+
"font_name": "Times New Roman",
|
| 41 |
+
"font_size_pt": 12,
|
| 42 |
+
"code_font": "Courier New",
|
| 43 |
+
"code_size_pt": 11
|
| 44 |
+
},
|
| 45 |
+
|
| 46 |
+
# --- 🚨 新增:全局拦截与保护黑名单 ---
|
| 47 |
+
"blacklists": {
|
| 48 |
+
"meta_sections": [
|
| 49 |
+
"abstract", "keyword", "keywords", "摘要", "关键词", "关键字",
|
| 50 |
+
"reference", "references", "reference list", "参考文献",
|
| 51 |
+
"acknowledgment", "acknowledgements", "致谢",
|
| 52 |
+
"аннотация", "ключевые слова", "түйіндеме", "кілт сөздер"
|
| 53 |
+
]
|
| 54 |
+
}
|
| 55 |
}
|
| 56 |
|
| 57 |
generic_prompts = {
|
|
|
|
| 86 |
"empirical_data_logic": "Maintain strict adherence to APA 7th edition reporting standards. Include plausible degrees of freedom, exact p-values, confidence intervals, and effect sizes.",
|
| 87 |
}
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
default_config = base_config.copy()
|
| 90 |
default_config.update(generic_prompts)
|
|
|
|
| 91 |
return default_config, amj_prompts, generic_prompts
|
| 92 |
|
| 93 |
+
# =====================================================================
|
| 94 |
+
# 🚨 核心重点:下面这两行代码绝对不能有任何缩进,必须紧贴屏幕最左侧!
|
| 95 |
+
# 这是让 APP_CONFIG 变成全局变量,能被外部模块识别到的关键。
|
| 96 |
+
# =====================================================================
|
| 97 |
DEFAULT_CONFIG, AMJ_PROMPTS, GENERIC_PROMPTS = load_config()
|
| 98 |
APP_CONFIG = DEFAULT_CONFIG.copy()
|