Spaces:
Sleeping
Sleeping
Commit ·
2bdb2db
1
Parent(s): 1ee34a1
add: all functions for library
Browse files- .vscode/mcp.json +7 -0
- app.py +179 -9
.vscode/mcp.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"servers": {
|
| 3 |
+
"evidently doc": {
|
| 4 |
+
"url": "https://dimadem-evidently-doc.hf.space/gradio_api/mcp/sse"
|
| 5 |
+
}
|
| 6 |
+
}
|
| 7 |
+
}
|
app.py
CHANGED
|
@@ -1,28 +1,198 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
def get_tests():
|
| 5 |
"""
|
| 6 |
Get Evidently actual documentation about tests.
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
"""
|
| 9 |
try:
|
| 10 |
-
url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/
|
| 11 |
response = requests.get(url, timeout=10)
|
| 12 |
response.raise_for_status()
|
| 13 |
return response.text
|
| 14 |
except requests.exceptions.RequestException as e:
|
| 15 |
return str(e)
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
)
|
| 25 |
|
| 26 |
# Launch the interface and MCP server
|
| 27 |
if __name__ == "__main__":
|
| 28 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
| 4 |
+
def get_data_definition():
|
| 5 |
+
"""
|
| 6 |
+
Get Evidently actual documentation about Data definition.
|
| 7 |
+
|
| 8 |
+
description:
|
| 9 |
+
How to map the input data.
|
| 10 |
+
To run evaluations, you must create a Dataset object with a DataDefinition, which maps:
|
| 11 |
+
Column types (e.g., categorical, numerical, text).
|
| 12 |
+
Column roles (e.g., id, prediction, target).
|
| 13 |
+
This allows Evidently to process the data correctly.
|
| 14 |
+
Some evaluations need specific columns and will fail if they're missing.
|
| 15 |
+
You can define the mapping using the Python API or by assigning columns visually when uploading data to the Evidently platform.
|
| 16 |
+
"""
|
| 17 |
+
try:
|
| 18 |
+
url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/data_definition.mdx"
|
| 19 |
+
response = requests.get(url, timeout=10)
|
| 20 |
+
response.raise_for_status()
|
| 21 |
+
return response.text
|
| 22 |
+
except requests.exceptions.RequestException as e:
|
| 23 |
+
return str(e)
|
| 24 |
+
|
| 25 |
+
def get_descriptors():
|
| 26 |
+
"""
|
| 27 |
+
Get Evidently actual documentation about descriptors.
|
| 28 |
+
|
| 29 |
+
description:
|
| 30 |
+
How to run evaluations for text data.
|
| 31 |
+
To evaluate text data, like LLM inputs and outputs, you create Descriptors.
|
| 32 |
+
This is a universal interface for all evals - from text statistics to LLM judges.
|
| 33 |
+
Each descriptor computes a score or label per row of your dataset.
|
| 34 |
+
You can combine multiple descriptors and set optional pass/fail conditions.
|
| 35 |
+
You can use built-in descriptors or create custom ones using LLM prompts or Python.
|
| 36 |
+
"""
|
| 37 |
+
try:
|
| 38 |
+
url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/descriptors.mdx"
|
| 39 |
+
response = requests.get(url, timeout=10)
|
| 40 |
+
response.raise_for_status()
|
| 41 |
+
return response.text
|
| 42 |
+
except requests.exceptions.RequestException as e:
|
| 43 |
+
return str(e)
|
| 44 |
+
|
| 45 |
+
def get_evaluations():
|
| 46 |
+
"""
|
| 47 |
+
Get Evidently actual documentation about evaluations.
|
| 48 |
+
|
| 49 |
+
description:
|
| 50 |
+
This page shows the core eval workflow with the Evidently library and links to guides.
|
| 51 |
+
"""
|
| 52 |
+
try:
|
| 53 |
+
url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/evaluations_overview.mdx"
|
| 54 |
+
response = requests.get(url, timeout=10)
|
| 55 |
+
response.raise_for_status()
|
| 56 |
+
return response.text
|
| 57 |
+
except requests.exceptions.RequestException as e:
|
| 58 |
+
return str(e)
|
| 59 |
+
|
| 60 |
+
def get_leftovers():
|
| 61 |
+
"""
|
| 62 |
+
Get Evidently actual documentation about leftovers.
|
| 63 |
+
description:
|
| 64 |
+
Description of your new file.
|
| 65 |
+
"""
|
| 66 |
+
try:
|
| 67 |
+
url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/leftover_content.mdx"
|
| 68 |
+
response = requests.get(url, timeout=10)
|
| 69 |
+
response.raise_for_status()
|
| 70 |
+
return response.text
|
| 71 |
+
except requests.exceptions.RequestException as e:
|
| 72 |
+
return str(e)
|
| 73 |
+
|
| 74 |
+
def get_metrics_generators():
|
| 75 |
+
"""
|
| 76 |
+
Get Evidently actual documentation about metrics generators.
|
| 77 |
+
description:
|
| 78 |
+
How to generate multiple metrics at once.
|
| 79 |
+
Sometimes you need to generate multiple column-level Tests or Metrics.
|
| 80 |
+
To simplify this, you can use metric generator helper functions.
|
| 81 |
+
"""
|
| 82 |
+
try:
|
| 83 |
+
url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/metric_generator.mdx"
|
| 84 |
+
response = requests.get(url, timeout=10)
|
| 85 |
+
response.raise_for_status()
|
| 86 |
+
return response.text
|
| 87 |
+
except requests.exceptions.RequestException as e:
|
| 88 |
+
return str(e)
|
| 89 |
+
|
| 90 |
+
def get_output_formats():
|
| 91 |
+
"""
|
| 92 |
+
Get Evidently actual documentation about output formats.
|
| 93 |
+
|
| 94 |
+
description:
|
| 95 |
+
How to export the evaluation results.
|
| 96 |
+
"""
|
| 97 |
+
try:
|
| 98 |
+
url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/output_formats.mdx"
|
| 99 |
+
response = requests.get(url, timeout=10)
|
| 100 |
+
response.raise_for_status()
|
| 101 |
+
return response.text
|
| 102 |
+
except requests.exceptions.RequestException as e:
|
| 103 |
+
return str(e)
|
| 104 |
+
|
| 105 |
+
def get_overview():
|
| 106 |
+
"""
|
| 107 |
+
Get Evidently actual overview documentation.
|
| 108 |
+
description:
|
| 109 |
+
Core concepts and components of the Evidently Python library.
|
| 110 |
+
"""
|
| 111 |
+
try:
|
| 112 |
+
url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/overview.mdx"
|
| 113 |
+
response = requests.get(url, timeout=10)
|
| 114 |
+
response.raise_for_status()
|
| 115 |
+
return response.text
|
| 116 |
+
except requests.exceptions.RequestException as e:
|
| 117 |
+
return str(e)
|
| 118 |
+
|
| 119 |
+
def get_reports():
|
| 120 |
+
"""
|
| 121 |
+
Get Evidently actual documentation about reports.
|
| 122 |
+
|
| 123 |
+
description:
|
| 124 |
+
How to generate Report.
|
| 125 |
+
"""
|
| 126 |
+
try:
|
| 127 |
+
url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/report.mdx"
|
| 128 |
+
response = requests.get(url, timeout=10)
|
| 129 |
+
response.raise_for_status()
|
| 130 |
+
return response.text
|
| 131 |
+
except requests.exceptions.RequestException as e:
|
| 132 |
+
return str(e)
|
| 133 |
+
|
| 134 |
+
def get_tags_and_metadata():
|
| 135 |
+
"""
|
| 136 |
+
Get Evidently actual documentation about tags and metadata.
|
| 137 |
+
|
| 138 |
+
description:
|
| 139 |
+
How to add metadata to evaluations.
|
| 140 |
+
This is relevant when you logging Reports to the Platform.
|
| 141 |
+
Tags help you associate each Report with a specific model / prompt version, time period, or other context.
|
| 142 |
+
"""
|
| 143 |
+
try:
|
| 144 |
+
url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/tags_metadata.mdx"
|
| 145 |
+
response = requests.get(url, timeout=10)
|
| 146 |
+
response.raise_for_status()
|
| 147 |
+
return response.text
|
| 148 |
+
except requests.exceptions.RequestException as e:
|
| 149 |
+
return str(e)
|
| 150 |
+
|
| 151 |
def get_tests():
|
| 152 |
"""
|
| 153 |
Get Evidently actual documentation about tests.
|
| 154 |
|
| 155 |
+
description:
|
| 156 |
+
How to run conditional checks.
|
| 157 |
+
Tests let you validate specific conditions and get Pass/Fail results on the dataset level.
|
| 158 |
+
Tests are an add-on to the Report and appear in a separate tab.
|
| 159 |
"""
|
| 160 |
try:
|
| 161 |
+
url = "https://raw.githubusercontent.com/evidentlyai/docs/refs/heads/main/docs/library/tests.mdx"
|
| 162 |
response = requests.get(url, timeout=10)
|
| 163 |
response.raise_for_status()
|
| 164 |
return response.text
|
| 165 |
except requests.exceptions.RequestException as e:
|
| 166 |
return str(e)
|
| 167 |
|
| 168 |
+
|
| 169 |
+
server = gr.TabbedInterface(
|
| 170 |
+
[
|
| 171 |
+
gr.Interface(get_data_definition, inputs=[], outputs="text", title="Data Definition"),
|
| 172 |
+
gr.Interface(get_descriptors, inputs=[], outputs="text", title="Descriptors"),
|
| 173 |
+
gr.Interface(get_evaluations, inputs=[], outputs="text", title="Evaluations"),
|
| 174 |
+
gr.Interface(get_leftovers, inputs=[], outputs="text", title="Leftovers"),
|
| 175 |
+
gr.Interface(get_metrics_generators, inputs=[], outputs="text", title="Metrics Generators"),
|
| 176 |
+
gr.Interface(get_output_formats, inputs=[], outputs="text", title="Output Formats"),
|
| 177 |
+
gr.Interface(get_overview, inputs=[], outputs="text", title="Overview"),
|
| 178 |
+
gr.Interface(get_reports, inputs=[], outputs="text", title="Reports"),
|
| 179 |
+
gr.Interface(get_tags_and_metadata, inputs=[], outputs="text", title="Tags and Metadata"),
|
| 180 |
+
gr.Interface(get_tests, inputs=[], outputs="text", title="Tests")
|
| 181 |
+
],
|
| 182 |
+
[
|
| 183 |
+
"Data Definition",
|
| 184 |
+
"Descriptors",
|
| 185 |
+
"Evaluations",
|
| 186 |
+
"Leftovers",
|
| 187 |
+
"Metrics Generators",
|
| 188 |
+
"Output Formats",
|
| 189 |
+
"Overview",
|
| 190 |
+
"Reports",
|
| 191 |
+
"Tags and Metadata",
|
| 192 |
+
"Tests"
|
| 193 |
+
],
|
| 194 |
)
|
| 195 |
|
| 196 |
# Launch the interface and MCP server
|
| 197 |
if __name__ == "__main__":
|
| 198 |
+
server.launch(mcp_server=True)
|