feat: add AI service for content extraction and Browserless service for web scraping

This commit is contained in:
Michael committed 2025-11-29 09:46:29 +01:00
1 parent 86559ff2d7
commit f665a000af
2 files changed
+8 -2

No files matched your search

+7 -1
View File
@@ -23,7 +23,7 @@ from app.utils.text import clean_text
# Default configuration (can be overridden by DB settings) # Default configuration (can be overridden by DB settings)
DEFAULT_PROVIDER = "ollama" DEFAULT_PROVIDER = "ollama"
DEFAULT_MODEL = "gemma3:4b" DEFAULT_MODEL = "google/gemini-flash-1.5"
DEFAULT_API_BASE = "http://ollama:11434" DEFAULT_API_BASE = "http://ollama:11434"
DEFAULT_TEMPERATURE = 0.1 DEFAULT_TEMPERATURE = 0.1
DEFAULT_MAX_TOKENS = 300 DEFAULT_MAX_TOKENS = 300
@@ -91,6 +91,12 @@ class AIService:
"multi_sample_threshold": float(settings_map.get("multi_sample_confidence_threshold", "0.6")), "multi_sample_threshold": float(settings_map.get("multi_sample_confidence_threshold", "0.6")),
} }
# Force override for known problematic model
if config["model"] == "openai/gpt-5-nano":
logger.warning("Overriding problematic model 'openai/gpt-5-nano' with 'google/gemini-flash-1.5'")
config["model"] = "google/gemini-flash-1.5"
config["provider"] = "openrouter"
# Update cache # Update cache
_config_cache["data"] = config # type: ignore _config_cache["data"] = config # type: ignore
_config_cache["timestamp"] = now _config_cache["timestamp"] = now
+1 -1
View File
@@ -185,7 +185,7 @@ class BrowserlessService:
filename = f"{safe_name}_{timestamp}.jpg" filename = f"{safe_name}_{timestamp}.jpg"
screenshot_path = f"{screenshots_dir}/{filename}" screenshot_path = f"{screenshots_dir}/{filename}"
await page.screenshot(path=screenshot_path, full_page=True, quality=80, type="jpeg") await page.screenshot(path=screenshot_path, full_page=False, quality=80, type="jpeg")
logger.info(f"Screenshot saved to {screenshot_path}") logger.info(f"Screenshot saved to {screenshot_path}")
except Exception as e: except Exception as e:
logger.warning(f"Failed to take screenshot: {e}") logger.warning(f"Failed to take screenshot: {e}")