Spaces:
Runtime error
Runtime error
Download backend/apps/rag/search/main.py from olipericles/ChatBotando: direct link, hf CLI and curl.
- Browser
- Download file 547 Bytes
-
https://huggingface.co/spaces/olipericles/ChatBotando/resolve/main/backend/apps/rag/search/main.py
- Command line
-
hf download hf://spaces/olipericles/ChatBotando/backend/apps/rag/search/main.py
-
curl -L -o main.py https://huggingface.co/spaces/olipericles/ChatBotando/resolve/main/backend/apps/rag/search/main.py
547 Bytes
| from typing import Optional | |
| from urllib.parse import urlparse | |
| from pydantic import BaseModel | |
| def get_filtered_results(results, filter_list): | |
| if not filter_list: | |
| return results | |
| filtered_results = [] | |
| for result in results: | |
| domain = urlparse(result["url"]).netloc | |
| if any(domain.endswith(filtered_domain) for filtered_domain in filter_list): | |
| filtered_results.append(result) | |
| return filtered_results | |
| class SearchResult(BaseModel): | |
| link: str | |
| title: Optional[str] | |
| snippet: Optional[str] | |