Spaces:
Runtime error
Runtime error
Upload 18 files
Browse files- app.py +5 -5
- llm_local.py +5 -5
app.py
CHANGED
|
@@ -82,12 +82,12 @@ def ui_explain_detail(ticker):
|
|
| 82 |
f"FACT LINE:\n{raw}")
|
| 83 |
if chain_core:
|
| 84 |
prompt += f"\n\nRULING CHAIN (translate & synthesize, don't quote):\n{chain_core}"
|
| 85 |
-
yield "🤖
|
| 86 |
final = ""
|
| 87 |
for acc in llm_local.chat_stream(prompt, max_tokens=260, temperature=0.2,
|
| 88 |
worker="translator"):
|
| 89 |
final = acc
|
| 90 |
-
yield "🤖 **AI
|
| 91 |
# capture (raw read → narrative) as a fine-tuning pair (🎯 Well-Tuned)
|
| 92 |
try:
|
| 93 |
import finetune_data
|
|
@@ -162,7 +162,7 @@ def _export_dataset():
|
|
| 162 |
if n == 0:
|
| 163 |
return ("⚠️ **0 training pairs captured yet.** Pairs are saved only when "
|
| 164 |
"the **Signals → AI summary** finishes with a model loaded. Steps: "
|
| 165 |
-
"1) Model tab — wait for the
|
| 166 |
"2) Signals — Run analysis, pick a ticker, click **AI summary**, "
|
| 167 |
"let it finish; repeat a few times; 3) come back and Export.",
|
| 168 |
gr.update(visible=False))
|
|
@@ -243,7 +243,7 @@ with gr.Blocks(title="Chan Compass · US", **_style_kw) as demo:
|
|
| 243 |
sig_table = gr.Dataframe(label="Tomorrow's plan — long-hold mode (sorted: BUY → SELL → HOLD → WAIT)",
|
| 244 |
interactive=False, wrap=True)
|
| 245 |
gr.Markdown("**Stock summary** — pick a ticker for a plain-English raw read, "
|
| 246 |
-
"then let the
|
| 247 |
elem_classes=["s2-footnote"])
|
| 248 |
with gr.Row():
|
| 249 |
detail_pick = gr.Dropdown(choices=[], label="Ticker", scale=2)
|
|
@@ -341,7 +341,7 @@ with gr.Blocks(title="Chan Compass · US", **_style_kw) as demo:
|
|
| 341 |
"and nothing leaves the machine. **First load installs the llama.cpp "
|
| 342 |
"runtime + downloads the GGUF (one-time, usually 1–3 min; worst case "
|
| 343 |
"~15 min if it has to compile).** Signals/rotation/news never depend on it.")
|
| 344 |
-
gr.Markdown("**Sub-agent pool:**
|
| 345 |
"fixed) handles Explain / rotation narrative / news briefs; "
|
| 346 |
"`deep` Analyst writes research reports. Each has its own lock — "
|
| 347 |
"they run in parallel. Pick the Analyst model below:")
|
|
|
|
| 82 |
f"FACT LINE:\n{raw}")
|
| 83 |
if chain_core:
|
| 84 |
prompt += f"\n\nRULING CHAIN (translate & synthesize, don't quote):\n{chain_core}"
|
| 85 |
+
yield "🤖 _Summary Sub-Agent (Chan-Tuned Qwen3-1.7B · llama.cpp) is summarizing…_"
|
| 86 |
final = ""
|
| 87 |
for acc in llm_local.chat_stream(prompt, max_tokens=260, temperature=0.2,
|
| 88 |
worker="translator"):
|
| 89 |
final = acc
|
| 90 |
+
yield "🤖 **AI Summary (Summary Sub-Agent · Chan-Tuned Qwen3-1.7B):**\n\n" + acc
|
| 91 |
# capture (raw read → narrative) as a fine-tuning pair (🎯 Well-Tuned)
|
| 92 |
try:
|
| 93 |
import finetune_data
|
|
|
|
| 162 |
if n == 0:
|
| 163 |
return ("⚠️ **0 training pairs captured yet.** Pairs are saved only when "
|
| 164 |
"the **Signals → AI summary** finishes with a model loaded. Steps: "
|
| 165 |
+
"1) Model tab — wait for the Summary sub-agent to show ✅; "
|
| 166 |
"2) Signals — Run analysis, pick a ticker, click **AI summary**, "
|
| 167 |
"let it finish; repeat a few times; 3) come back and Export.",
|
| 168 |
gr.update(visible=False))
|
|
|
|
| 243 |
sig_table = gr.Dataframe(label="Tomorrow's plan — long-hold mode (sorted: BUY → SELL → HOLD → WAIT)",
|
| 244 |
interactive=False, wrap=True)
|
| 245 |
gr.Markdown("**Stock summary** — pick a ticker for a plain-English raw read, "
|
| 246 |
+
"then let the Summary sub-agent write an AI Summary.",
|
| 247 |
elem_classes=["s2-footnote"])
|
| 248 |
with gr.Row():
|
| 249 |
detail_pick = gr.Dropdown(choices=[], label="Ticker", scale=2)
|
|
|
|
| 341 |
"and nothing leaves the machine. **First load installs the llama.cpp "
|
| 342 |
"runtime + downloads the GGUF (one-time, usually 1–3 min; worst case "
|
| 343 |
"~15 min if it has to compile).** Signals/rotation/news never depend on it.")
|
| 344 |
+
gr.Markdown("**Sub-agent pool:** Summary Sub-Agent (Chan-Tuned Qwen3-1.7B, "
|
| 345 |
"fixed) handles Explain / rotation narrative / news briefs; "
|
| 346 |
"`deep` Analyst writes research reports. Each has its own lock — "
|
| 347 |
"they run in parallel. Pick the Analyst model below:")
|
llm_local.py
CHANGED
|
@@ -4,7 +4,7 @@ llm_local.py — local sub-agent pool (llama.cpp runtime, no cloud APIs).
|
|
| 4 |
Two independent model instances ("sub-agents"), each with its own lock, so
|
| 5 |
features never block each other with "model busy":
|
| 6 |
|
| 7 |
-
fast ·
|
| 8 |
→ Explain-in-English, sector-rotation narrative, news briefs.
|
| 9 |
Small = quick CPU prefill, answers start streaming in seconds.
|
| 10 |
deep · Analyst — Qwen3-4B Q4_K_M by default (swappable in the Model tab)
|
|
@@ -25,7 +25,7 @@ from huggingface_hub import hf_hub_download
|
|
| 25 |
|
| 26 |
# name -> (HF repo, gguf filename)
|
| 27 |
MODEL_ZOO = {
|
| 28 |
-
"Chan-Tuned Qwen3-1.7B · my fine-tune
|
| 29 |
"ranranrunforit/chan-compass-qwen3-1.7b-gguf", "qwen3-1.7b.Q8_0.gguf"),
|
| 30 |
"Qwen3-1.7B · Tiny Titan (≤4B award class)": (
|
| 31 |
"Qwen/Qwen3-1.7B-GGUF", "Qwen3-1.7B-Q8_0.gguf"),
|
|
@@ -36,10 +36,10 @@ MODEL_ZOO = {
|
|
| 36 |
"Qwen3-14B · max quality (still far under 32B cap)": (
|
| 37 |
"Qwen/Qwen3-14B-GGUF", "Qwen3-14B-Q4_K_M.gguf"),
|
| 38 |
}
|
| 39 |
-
# Only the
|
| 40 |
# fine-tune; every other sub-agent stays on the stock models.
|
| 41 |
FAST_MODEL = "Qwen3-1.7B · Tiny Titan (≤4B award class)"
|
| 42 |
-
TRANSLATOR_MODEL = "Chan-Tuned Qwen3-1.7B · my fine-tune
|
| 43 |
DEFAULT_MODEL = "Qwen3-4B · default — fast + smart, still ≤4B"
|
| 44 |
|
| 45 |
_THINK_RE = re.compile(r"<think>.*?</think>", re.S)
|
|
@@ -50,7 +50,7 @@ _NCPU = max(2, (os.cpu_count() or 4))
|
|
| 50 |
# Three tiny 1.7B instances share ONE GGUF file on disk (~2 GB RAM each) and
|
| 51 |
# the 4B Analyst writes reports. Total ≈ 9 GB on a 32 GB Space.
|
| 52 |
WORKER_LABEL = {
|
| 53 |
-
"translator": "
|
| 54 |
"narrator": "Narrator sub-agent (Sector Rotation)",
|
| 55 |
"reporter": "Reporter sub-agent (News · Research support)",
|
| 56 |
"analyst": "Analyst sub-agent (Auto Research)",
|
|
|
|
| 4 |
Two independent model instances ("sub-agents"), each with its own lock, so
|
| 5 |
features never block each other with "model busy":
|
| 6 |
|
| 7 |
+
fast · Summary Sub-Agent (Chan-Tuned Qwen3-1.7B)
|
| 8 |
→ Explain-in-English, sector-rotation narrative, news briefs.
|
| 9 |
Small = quick CPU prefill, answers start streaming in seconds.
|
| 10 |
deep · Analyst — Qwen3-4B Q4_K_M by default (swappable in the Model tab)
|
|
|
|
| 25 |
|
| 26 |
# name -> (HF repo, gguf filename)
|
| 27 |
MODEL_ZOO = {
|
| 28 |
+
"Chan-Tuned Qwen3-1.7B · my fine-tune": (
|
| 29 |
"ranranrunforit/chan-compass-qwen3-1.7b-gguf", "qwen3-1.7b.Q8_0.gguf"),
|
| 30 |
"Qwen3-1.7B · Tiny Titan (≤4B award class)": (
|
| 31 |
"Qwen/Qwen3-1.7B-GGUF", "Qwen3-1.7B-Q8_0.gguf"),
|
|
|
|
| 36 |
"Qwen3-14B · max quality (still far under 32B cap)": (
|
| 37 |
"Qwen/Qwen3-14B-GGUF", "Qwen3-14B-Q4_K_M.gguf"),
|
| 38 |
}
|
| 39 |
+
# Only the Summary sub-agent (Signals · Explain) uses the published
|
| 40 |
# fine-tune; every other sub-agent stays on the stock models.
|
| 41 |
FAST_MODEL = "Qwen3-1.7B · Tiny Titan (≤4B award class)"
|
| 42 |
+
TRANSLATOR_MODEL = "Chan-Tuned Qwen3-1.7B · my fine-tune"
|
| 43 |
DEFAULT_MODEL = "Qwen3-4B · default — fast + smart, still ≤4B"
|
| 44 |
|
| 45 |
_THINK_RE = re.compile(r"<think>.*?</think>", re.S)
|
|
|
|
| 50 |
# Three tiny 1.7B instances share ONE GGUF file on disk (~2 GB RAM each) and
|
| 51 |
# the 4B Analyst writes reports. Total ≈ 9 GB on a 32 GB Space.
|
| 52 |
WORKER_LABEL = {
|
| 53 |
+
"translator": "Summary Sub-Agent (Chan-Tuned Qwen3-1.7B)",
|
| 54 |
"narrator": "Narrator sub-agent (Sector Rotation)",
|
| 55 |
"reporter": "Reporter sub-agent (News · Research support)",
|
| 56 |
"analyst": "Analyst sub-agent (Auto Research)",
|