Spaces:
Sleeping
Sleeping
Download client.py from Akhilllll/data_quality_agent: direct link, hf CLI and curl.
- Browser
- Download file 2.6 kB
-
https://huggingface.co/spaces/Akhilllll/data_quality_agent/resolve/main/client.py
- Command line
-
hf download hf://spaces/Akhilllll/data_quality_agent/client.py
-
curl -L -o client.py https://huggingface.co/spaces/Akhilllll/data_quality_agent/resolve/main/client.py
2.6 kB
| """Data Quality Agent Environment Client.""" | |
| from typing import Dict | |
| from openenv.core import EnvClient | |
| from openenv.core.client_types import StepResult | |
| from openenv.core.env_server.types import State | |
| try: | |
| from .models import DataQualityAgentAction, DataQualityAgentObservation | |
| except ImportError: | |
| from models import DataQualityAgentAction, DataQualityAgentObservation | |
| class DataQualityAgentEnv( | |
| EnvClient[DataQualityAgentAction, DataQualityAgentObservation, State] | |
| ): | |
| """ | |
| Client for the Data Quality Agent Environment. | |
| Maintains a persistent WebSocket connection to the environment server. | |
| Example: | |
| >>> env = DataQualityAgentEnv(base_url="http://localhost:8000") | |
| >>> result = await env.reset() | |
| >>> print(result.observation.dashboard) | |
| >>> result = await env.step(DataQualityAgentAction(message="DESCRIBE")) | |
| """ | |
| def _step_payload(self, action: DataQualityAgentAction) -> Dict: | |
| return {"message": action.message} | |
| def _parse_result(self, payload: Dict) -> StepResult[DataQualityAgentObservation]: | |
| obs_data = payload.get("observation", {}) | |
| observation = DataQualityAgentObservation( | |
| dashboard=obs_data.get("dashboard", ""), | |
| step_number=obs_data.get("step_number", 0), | |
| total_steps=obs_data.get("total_steps", 40), | |
| dataset_name=obs_data.get("dataset_name", ""), | |
| num_rows=obs_data.get("num_rows", 0), | |
| num_columns=obs_data.get("num_columns", 0), | |
| issues_detected=obs_data.get("issues_detected", 0), | |
| issues_fixed=obs_data.get("issues_fixed", 0), | |
| total_issues=obs_data.get("total_issues", 0), | |
| quality_score=obs_data.get("quality_score", 0.0), | |
| completeness=obs_data.get("completeness", 0.0), | |
| consistency=obs_data.get("consistency", 0.0), | |
| accuracy=obs_data.get("accuracy", 0.0), | |
| phase=obs_data.get("phase", "inspection"), | |
| task_name=obs_data.get("task_name", ""), | |
| task_description=obs_data.get("task_description", ""), | |
| done=payload.get("done", False), | |
| reward=payload.get("reward"), | |
| metadata=obs_data.get("metadata", {}), | |
| ) | |
| return StepResult( | |
| observation=observation, | |
| reward=payload.get("reward"), | |
| done=payload.get("done", False), | |
| ) | |
| def _parse_state(self, payload: Dict) -> State: | |
| return State( | |
| episode_id=payload.get("episode_id"), | |
| step_count=payload.get("step_count", 0), | |
| ) | |