fix: nombre de archivo .md usa topic del output, no del session pre-cacheado
Build & Deploy ResearchOwl / build-and-push (push) Successful in 6s
Build & Deploy ResearchOwl / build-and-push (push) Successful in 6s
El session dict se obtiene antes de generator.generate() y puede contener datos de la sesión anterior. Ahora se extrae el topic directamente de la línea "Topic:" del header del output generado, que siempre refleja la sesión actual usada en la generación. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+6
-1
@@ -341,6 +341,7 @@ async def cmd_generate(update: Update, ctx: ContextTypes.DEFAULT_TYPE):
|
|||||||
# Send as file if very long
|
# Send as file if very long
|
||||||
if len(output) > 8000:
|
if len(output) > 8000:
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import re as _re
|
||||||
ext_map = {
|
ext_map = {
|
||||||
OutputType.PODCAST: "script.md",
|
OutputType.PODCAST: "script.md",
|
||||||
OutputType.BLOG: "post.md",
|
OutputType.BLOG: "post.md",
|
||||||
@@ -350,7 +351,11 @@ async def cmd_generate(update: Update, ctx: ContextTypes.DEFAULT_TYPE):
|
|||||||
OutputType.BLOG_EXTENDED: "blog_extended.md",
|
OutputType.BLOG_EXTENDED: "blog_extended.md",
|
||||||
OutputType.PODCAST_EXTENDED: "script_extended.md",
|
OutputType.PODCAST_EXTENDED: "script_extended.md",
|
||||||
}
|
}
|
||||||
filename = f"researchowl_{session['topic'][:30].replace(' ', '_')}_{ext_map[output_type]}"
|
# Use the topic from the output header (written at generation time)
|
||||||
|
# instead of the pre-fetched session dict which may be stale.
|
||||||
|
_m = _re.search(r'^Topic:\s*(.+)$', output[:500], _re.MULTILINE)
|
||||||
|
_topic = _m.group(1).strip() if _m else session["topic"]
|
||||||
|
filename = f"researchowl_{_topic[:30].replace(' ', '_')}_{ext_map[output_type]}"
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile(mode="w", suffix=".md", delete=False) as f:
|
with tempfile.NamedTemporaryFile(mode="w", suffix=".md", delete=False) as f:
|
||||||
f.write(output)
|
f.write(output)
|
||||||
|
|||||||
Reference in New Issue
Block a user