genai_service / dependencies.py
ahmed-eisa's picture
talk to web page app
6d73c15
raw
history blame contribute delete
463 Bytes
from fastapi import Body
from loguru import logger
from schemas import TextModelRequest
from scraper import extract_urls, fetch_all
async def get_urls_content(body: TextModelRequest ) -> str:
urls = extract_urls(body.prompt)
if urls:
try:
urls_content = await fetch_all(urls)
return urls_content
except Exception as e:
logger.warning(f"Failed to fetch one or several URls - Error: {e}")
return ""