mirror of
https://github.com/hanzoai/agent.git
synced 2026-09-11 21:08:51 +00:00
The backend guide exported HANZO_ROUTER_URL and HANZO_API_KEY as a setup step, but the SDK takes its endpoint and key from the client it is given, and the openai client falls back to OPENAI_BASE_URL and OPENAI_API_KEY. Reading HANZO_ROUTER_URL as well would be a second way to set one thing, so the step is gone and the pooling example names https://api.hanzo.ai/v1. A test fails when the docs export a variable that neither package reads. Co-authored-by: Hanzo Dev <[email protected]>
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
"""The docs configure the SDK only through variables that code reads."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
from pathlib import Path
|
|
|
|
import openai
|
|
|
|
import agents
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def _names(package: Path) -> set[str]:
|
|
return {
|
|
name
|
|
for path in package.rglob("*.py")
|
|
for name in re.findall(r"\b[A-Z][A-Z0-9_]+\b", path.read_text(encoding="utf-8"))
|
|
}
|
|
|
|
|
|
def test_every_variable_the_docs_export_is_read() -> None:
|
|
# The SDK reads its own variables, and the openai client it builds reads OPENAI_API_KEY and
|
|
# OPENAI_BASE_URL.
|
|
read = _names(Path(agents.__file__).parent) | _names(Path(openai.__file__).parent)
|
|
exported = [
|
|
(str(doc.relative_to(ROOT)), name)
|
|
for doc in [ROOT / "README.md", *sorted(ROOT.glob("docs/**/*.md"))]
|
|
for name in re.findall(
|
|
r"^\s*export ([A-Z][A-Z0-9_]*)=", doc.read_text(encoding="utf-8"), re.MULTILINE
|
|
)
|
|
]
|
|
assert [item for item in exported if item[1] not in read] == []
|