Переглянути джерело

added tag-generator with ollama

Pablo 2 тижнів тому
батько
коміт
8f3919d207
3 змінених файлів з 6 додано та 3 видалено
  1. 3 0
      AGENTS.md
  2. 1 1
      package.json
  3. 2 2
      src/utils/tag-generator.ts

+ 3 - 0
AGENTS.md

@@ -194,6 +194,9 @@ Each news portal follows this structure:
 - Limit message length to 400 characters
 - Format: `${EMOJI} Title\n\nContent\n\n${HASHTAGS}\n\n${LINK}`
 - Handle special cases (subscriber-only content, publirreportajes)
+- Hashtags are generated dynamically using an Ollama LLM model based on article title and content
+- Generated tags replace any static hashtags defined in the portal configuration
+- If Ollama is unavailable, disabled, or fails, the system falls back to the portal's static hashtags
 
 ## Development Notes
 

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "bot-noticias",
-  "version": "0.0.9",
+  "version": "0.0.11",
   "description": "Bot que busca noticias y las replica en mastodon.cl",
   "main": "dist/index.js",
   "scripts": {

+ 2 - 2
src/utils/tag-generator.ts

@@ -19,7 +19,7 @@ export default class TagGenerator {
   }
 
   private buildPrompt(title: string, content: string): string {
-    return `A partir del siguiente título y contenido de una noticia de un medio digital chileno, sugiere exactamente 3 hashtags relevantes y concisos para publicar en Mastodon.
+    return `A partir del siguiente título y contenido de una noticia de un medio digital chileno, sugiere como máximo 5 hashtags relevantes y concisos para publicar en Mastodon. Pueden ser menos de 3 si no aplica más.
 
 Reglas:
 - Responde ÚNICAMENTE con un array JSON de strings.
@@ -50,7 +50,7 @@ Respuesta:`;
       const parsed = JSON.parse(cleaned);
       if (Array.isArray(parsed)) {
         return parsed
-          .slice(0, 3)
+          .slice(0, 5)
           .map((tag: unknown) => this.cleanTag(String(tag)))
           .filter((tag) => tag !== "");
       }