Spaces:
Sleeping
Sleeping
Download app.py from dimadem/evidently_doc: direct link, hf CLI and curl.
- Browser
- Download file 5.39 kB
-
https://huggingface.co/spaces/dimadem/evidently_doc/resolve/main/app.py
- Command line
-
hf download hf://spaces/dimadem/evidently_doc/app.py
-
curl -L -o app.py https://huggingface.co/spaces/dimadem/evidently_doc/resolve/main/app.py
5.39 kB
| import gradio as gr | |
| import requests | |
| def get_data_definition(): | |
| """ | |
| To run evaluations, you must create a Dataset object with a DataDefinition. | |
| """ | |
| try: | |
| url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/data_definition.mdx" | |
| response = requests.get(url, timeout=10) | |
| response.raise_for_status() | |
| return response.text | |
| except requests.exceptions.RequestException as e: | |
| return str(e) | |
| def get_descriptors(): | |
| """ | |
| How to run evaluations for text data. | |
| """ | |
| try: | |
| url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/descriptors.mdx" | |
| response = requests.get(url, timeout=10) | |
| response.raise_for_status() | |
| return response.text | |
| except requests.exceptions.RequestException as e: | |
| return str(e) | |
| def get_evaluations(): | |
| """ | |
| Core eval workflow. | |
| """ | |
| try: | |
| url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/evaluations_overview.mdx" | |
| response = requests.get(url, timeout=10) | |
| response.raise_for_status() | |
| return response.text | |
| except requests.exceptions.RequestException as e: | |
| return str(e) | |
| def get_leftovers(): | |
| """ | |
| How to handle leftover content in your dataset. | |
| """ | |
| try: | |
| url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/leftover_content.mdx" | |
| response = requests.get(url, timeout=10) | |
| response.raise_for_status() | |
| return response.text | |
| except requests.exceptions.RequestException as e: | |
| return str(e) | |
| def get_metrics_generators(): | |
| """ | |
| How to generate multiple metrics at once. | |
| """ | |
| try: | |
| url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/metric_generator.mdx" | |
| response = requests.get(url, timeout=10) | |
| response.raise_for_status() | |
| return response.text | |
| except requests.exceptions.RequestException as e: | |
| return str(e) | |
| def get_output_formats(): | |
| """ | |
| How to export the evaluation results. | |
| """ | |
| try: | |
| url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/output_formats.mdx" | |
| response = requests.get(url, timeout=10) | |
| response.raise_for_status() | |
| return response.text | |
| except requests.exceptions.RequestException as e: | |
| return str(e) | |
| def get_overview(): | |
| """ | |
| Get Evidently actual overview documentation. | |
| description: | |
| Core concepts and components of the Evidently Python library. | |
| """ | |
| try: | |
| url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/overview.mdx" | |
| response = requests.get(url, timeout=10) | |
| response.raise_for_status() | |
| return response.text | |
| except requests.exceptions.RequestException as e: | |
| return str(e) | |
| def get_reports(): | |
| """ | |
| How to generate Report. | |
| """ | |
| try: | |
| url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/report.mdx" | |
| response = requests.get(url, timeout=10) | |
| response.raise_for_status() | |
| return response.text | |
| except requests.exceptions.RequestException as e: | |
| return str(e) | |
| def get_tags_and_metadata(): | |
| """ | |
| How to add metadata to evaluations. | |
| """ | |
| try: | |
| url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/tags_metadata.mdx" | |
| response = requests.get(url, timeout=10) | |
| response.raise_for_status() | |
| return response.text | |
| except requests.exceptions.RequestException as e: | |
| return str(e) | |
| def get_tests(): | |
| """ | |
| How to run conditional checks. | |
| """ | |
| try: | |
| url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/tests.mdx" | |
| response = requests.get(url, timeout=10) | |
| response.raise_for_status() | |
| return response.text | |
| except requests.exceptions.RequestException as e: | |
| return str(e) | |
| server = gr.TabbedInterface( | |
| [ | |
| gr.Interface(get_data_definition, inputs=[], outputs="text", title="Data Definition"), | |
| gr.Interface(get_descriptors, inputs=[], outputs="text", title="Descriptors"), | |
| gr.Interface(get_evaluations, inputs=[], outputs="text", title="Evaluations"), | |
| gr.Interface(get_leftovers, inputs=[], outputs="text", title="Leftovers"), | |
| gr.Interface(get_metrics_generators, inputs=[], outputs="text", title="Metrics Generators"), | |
| gr.Interface(get_output_formats, inputs=[], outputs="text", title="Output Formats"), | |
| gr.Interface(get_overview, inputs=[], outputs="text", title="Overview"), | |
| gr.Interface(get_reports, inputs=[], outputs="text", title="Reports"), | |
| gr.Interface(get_tags_and_metadata, inputs=[], outputs="text", title="Tags and Metadata"), | |
| gr.Interface(get_tests, inputs=[], outputs="text", title="Tests") | |
| ], | |
| [ | |
| "Data Definition", | |
| "Descriptors", | |
| "Evaluations", | |
| "Leftovers", | |
| "Metrics Generators", | |
| "Output Formats", | |
| "Overview", | |
| "Reports", | |
| "Tags and Metadata", | |
| "Tests" | |
| ], | |
| ) | |
| # Launch the interface and MCP server | |
| if __name__ == "__main__": | |
| server.launch(mcp_server=True) |