Repository navigation
Add HostedModel convenience API for OpenAI-compatible endpoints - #2630
johnjosephhorton wants to merge 4 commits into
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Greptile SummaryThis PR introduces
Confidence Score: 4/5The PR appears safe to merge, with a non-blocking input-normalization issue that should be corrected to avoid delayed endpoint and credential lookup failures. The factory otherwise follows the existing service, serialization, credential, and local-execution paths correctly; the sole finding concerns whitespace accepted during validation but retained for literal runtime use. Files Needing Attention: edsl/language_models/hosted_model.py
|
| Filename | Overview |
|---|---|
| edsl/language_models/hosted_model.py | Adds the convenience factory and validation; accepted connection strings are not normalized consistently before storage. |
| tests/language_models/test_hosted_model.py | Covers construction, serialization, credential lookup, and empty-field rejection, but not whitespace-padded connection values. |
| edsl/language_models/init.py | Correctly exposes the new function through the existing lazy-import mechanism. |
| edsl/init.py | Adds the factory to the package-level lazy export map. |
| docs/en/latest/local_openai_compatible.mdx | Documents direct Python construction and the credential-reference serialization contract. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[HostedModel arguments] --> B[Model factory]
B --> C[openai_compatible service]
C --> D[LanguageModel]
D --> E[Resolve credential from named environment variable]
D --> F[OpenAI-compatible client at base URL]
D --> G[Serialize service and connection reference]
F --> H[Hosted endpoint]
Reviews (1): Last reviewed commit: "Add HostedModel convenience factory" | Re-trigger Greptile
A merge dropped the "Partial remote results" section inside the YAML frontmatter fences (before title/description), breaking the Mintlify build with a frontmatter parse error. Restore valid frontmatter and move the section into the document body. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXYRohpJZAYnz54njHwB8v
Summary
HostedModelas a small convenience factory over the existingopenai_compatibleinference servicebase_urland the credential environment-variable name; never serialize a tokenWhy replace #2470
Current
mainalready provides the infrastructure that the original PR implemented independently: a registered OpenAI-compatible service, per-instance base URLs, connection serialization, CLI support, and endpoint-aware client caches. Building on those extension points makes the replacement substantially smaller and avoids the old PR's duplicate raw HTTP client and unrelated dependency-lock changes.This also addresses the Greptile review:
__new__factory class with misleadingisinstancebehavior;HostedModelis explicitly a convenience function returning a regularLanguageModelapi_tokenis assigned through a read-only property; credentials are resolved fromapi_key_envat call time@report_errors_asyncexecution methodTests
SurveyMessagehas no fixture intests/serialization/data/1.0.8.jsonSupersedes #2470.