From 0d8aee63be9e7d016467fa92149bb7822cd04d62 Mon Sep 17 00:00:00 2001 From: ChemaVX Date: Mon, 4 May 2026 10:23:19 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20fase=201=20=E2=80=94=20top=5Fk=2030?= =?UTF-8?q?=E2=86=9280,=20pool=20100=E2=86=92300,=20sin=20truncado,=20max?= =?UTF-8?q?=5Ftokens=2016000?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/generator/generator.py | 9 ++------- src/processor/processor.py | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/generator/generator.py b/src/generator/generator.py index 0039d70..ba9a5fc 100644 --- a/src/generator/generator.py +++ b/src/generator/generator.py @@ -156,7 +156,7 @@ class OutputGenerator: # RAG: get most relevant context for this output type query = self._get_rag_query(output_type, topic) - context = await self.processor.rag_query(session_id, query, top_k=30) + context = await self.processor.rag_query(session_id, query, top_k=80) if not context: # Fallback: use raw top chunks @@ -166,11 +166,6 @@ class OutputGenerator: if not context: raise ValueError("No processed content available. Run /process first.") - # Truncate context to avoid Ollama context limits - context_words = context.split() - if len(context_words) > 6000: - context = " ".join(context_words[:6000]) + "\n\n[... additional material truncated ...]" - backend = "Claude Haiku" if settings.anthropic_api_key else "Ollama" if progress_callback: await progress_callback(f"✍️ Generando {output_type} con {backend}... (2-5 min)") @@ -201,7 +196,7 @@ class OutputGenerator: async def _generate_with_claude(self, prompt: str, system: str, output_type: OutputType, session_id: int | None = None) -> str: import anthropic - max_tokens = 4096 if output_type == OutputType.THREAD else 8192 + max_tokens = 4096 if output_type == OutputType.THREAD else 16000 try: client = anthropic.AsyncAnthropic(api_key=settings.anthropic_api_key) msg = await client.messages.create( diff --git a/src/processor/processor.py b/src/processor/processor.py index af7d8f3..bc4a526 100644 --- a/src/processor/processor.py +++ b/src/processor/processor.py @@ -285,7 +285,7 @@ class ContentProcessor: query_embedding = await self.ollama.embed(query) # Get top quality chunks - chunks = await self.db.get_top_chunks(session_id, limit=100) + chunks = await self.db.get_top_chunks(session_id, limit=300) if query_embedding and chunks: # Rank by embedding similarity