feat: add detect_all() for multi-variant detection

This commit is contained in:
Edgar I.
2025-10-24 17:32:32 +04:00
parent 38ebc66749
commit e123de9055
2 changed files with 48 additions and 1 deletions

View File

@@ -2,7 +2,7 @@
# ABOUTME: Supports llms-full.txt, llms.txt, and llms-small.txt variants
import requests
from typing import Optional, Dict
from typing import Optional, Dict, List
from urllib.parse import urlparse
class LlmsTxtDetector:
@@ -35,6 +35,28 @@ class LlmsTxtDetector:
return None
def detect_all(self) -> List[Dict[str, str]]:
"""
Detect all available llms.txt variants.
Returns:
List of dicts with 'url' and 'variant' keys for each found variant
"""
found_variants = []
for filename, variant in self.VARIANTS:
parsed = urlparse(self.base_url)
root_url = f"{parsed.scheme}://{parsed.netloc}"
url = f"{root_url}/{filename}"
if self._check_url_exists(url):
found_variants.append({
'url': url,
'variant': variant
})
return found_variants
def _check_url_exists(self, url: str) -> bool:
"""Check if URL returns 200 status"""
try: