Spaces:
Runtime error
Runtime error
Download app/utils.py from MitchelHsu/cleric-agent-ui: direct link, hf CLI and curl.
- Browser
- Download file 816 Bytes
-
https://huggingface.co/spaces/MitchelHsu/cleric-agent-ui/resolve/main/app/utils.py
- Command line
-
hf download hf://spaces/MitchelHsu/cleric-agent-ui/app/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/MitchelHsu/cleric-agent-ui/resolve/main/app/utils.py
816 Bytes
| import requests | |
| import validators | |
| from typing import List | |
| def load_logs(log_paths: List) -> str: | |
| logs = "" | |
| for i, path in enumerate(log_paths): | |
| with open(path, 'r') as f: | |
| logs += f"Log {i}:\n" + f.read() + '\n' | |
| return logs | |
| def get_url_list(call_log_urls: str) -> List[str]: | |
| return call_log_urls.split('\n') | |
| def read_documents(documents: List[str]) -> List[str]: | |
| logs = [] | |
| for url in documents: | |
| response = requests.get(url) | |
| response.raise_for_status() | |
| logs.append(response.text) | |
| return logs | |
| def preprocess_logs(logs: List[str]) -> str: | |
| return '\n'.join(logs) | |
| def validate_request_logs(urls: List[str]): | |
| for url in urls: | |
| if not validators.url(url): | |
| raise ValueError(f'The following URL is invalid: {url}') | |