-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathruntime_profile.py
More file actions
77 lines (59 loc) · 2.75 KB
/
Copy pathruntime_profile.py
File metadata and controls
77 lines (59 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
"""
Runtime profiles
为不同运行场景(本地、CI)提供轻量配置覆盖,避免 GitHub Actions 跑进重型内容管线。
"""
from __future__ import annotations
from copy import deepcopy
import os
from typing import Any, Dict
def get_runtime_profile(profile: str | None = None) -> str:
value = str(profile or os.environ.get("AI_STACK_RUNTIME_PROFILE") or "default").strip().lower()
return value or "default"
def apply_sources_runtime_profile(config: Dict[str, Any] | None, profile: str | None = None) -> Dict[str, Any]:
result: Dict[str, Any] = deepcopy(config or {})
if get_runtime_profile(profile) != "ci":
return result
search_fallback = result.setdefault("search_fallback", {})
search_fallback["enabled"] = False
search_fallback["timeout"] = 5
sources = result.setdefault("sources", {})
# CI still limits expensive LLM processing downstream, but the crawlers need
# a wider candidate pool so archive dedupe can move past a repeated headline.
# Keeping only Top 1 made every hourly run regenerate the same article.
for source_name in ["github_trending", "hacker_news", "arxiv_ai", "juejin", "blogs_podcasts"]:
source = sources.setdefault(source_name, {})
source["enabled"] = True
configured_limit = int(source.get("limit", 8) or 8)
source["limit"] = max(8, min(configured_limit, 12))
blogs = sources.setdefault("blogs_podcasts", {})
blogs["timeout"] = min(int(blogs.get("timeout", 30) or 30), 10)
reddit = sources.setdefault("reddit", {})
reddit["enabled"] = False
twitter = sources.setdefault("twitter", {})
twitter["enabled"] = False
return result
def apply_anthropic_runtime_profile(config: Dict[str, Any] | None, profile: str | None = None) -> Dict[str, Any]:
result: Dict[str, Any] = deepcopy(config or {})
if get_runtime_profile(profile) != "ci":
return result
result["llm_concurrency"] = 2
result["llm_max_retries"] = 1
result["disable_thinking"] = True
ai_filter = result.setdefault("ai_filter", {})
ai_filter["strict_mode"] = False
ai_filter["min_confidence"] = 0.5
generation = result.setdefault("generation", {})
generation["intro_length"] = 220
generation["comment_length"] = 500
generation["analysis_length"] = 900
generation["generate_code_examples"] = False
generation["generate_case_studies"] = False
generation["generate_faq"] = False
generation["generate_comparison"] = False
generation["generate_best_practices"] = False
generation["generate_performance_tips"] = False
generation["generate_learning_path"] = False
generation["generate_challenges"] = False
generation["add_recommendations"] = False
generation["quality_retries"] = 0
return result