| 50 | |
| 51 | |
| 52 | def _normalize_endpoint(endpoint: str) -> str: |
| 53 | endpoint = endpoint.strip().rstrip("/") |
| 54 | parsed = urlsplit(endpoint) |
| 55 | if parsed.scheme != "https" or not parsed.netloc: |
| 56 | msg = "Error: LANGSMITH_ENDPOINT / LANGCHAIN_ENDPOINT must be an HTTPS URL.\n" |
| 57 | sys.stderr.write(msg) |
| 58 | raise SystemExit(1) |
| 59 | if parsed.username or parsed.password: |
| 60 | msg = ( |
| 61 | "Error: LANGSMITH_ENDPOINT / LANGCHAIN_ENDPOINT must not include " |
| 62 | "userinfo.\n" |
| 63 | ) |
| 64 | sys.stderr.write(msg) |
| 65 | raise SystemExit(1) |
| 66 | return endpoint |
| 67 | |
| 68 | |
| 69 | class ApiClient: |