Spaces:
Paused
Paused
Download src/telemetry.py from zaid646/llm-evaluator: direct link, hf CLI and curl.
- Browser
- Download file 779 Bytes
-
https://huggingface.co/spaces/zaid646/llm-evaluator/resolve/main/src/telemetry.py
- Command line
-
hf download hf://spaces/zaid646/llm-evaluator/src/telemetry.py
-
curl -L -o telemetry.py https://huggingface.co/spaces/zaid646/llm-evaluator/resolve/main/src/telemetry.py
779 Bytes
| import os | |
| from langsmith import Client as LangSmithClient | |
| _client: LangSmithClient | None = None | |
| def _get_client() -> LangSmithClient | None: | |
| global _client | |
| if _client is None and os.getenv("LANGSMITH_API_KEY"): | |
| _client = LangSmithClient() | |
| return _client | |
| def create_run( | |
| name: str, | |
| inputs: dict, | |
| outputs: dict | None = None, | |
| error: str | None = None, | |
| tags: list[str] | None = None, | |
| metadata: dict | None = None, | |
| ): | |
| client = _get_client() | |
| if client is None: | |
| return None | |
| run_type = "chain" | |
| client.create_run( | |
| name=name, | |
| inputs=inputs, | |
| outputs=outputs or {}, | |
| error=error, | |
| run_type=run_type, | |
| tags=tags or [], | |
| extra={"metadata": metadata or {}}, | |
| ) | |