Skip to content

Add HostedModel convenience API for OpenAI-compatible endpoints - #2630

Draft
johnjosephhorton wants to merge 4 commits into
mainfrom
feature/hosted-model-v2
Draft

johnjosephhorton wants to merge 4 commits into
mainfrom
feature/hosted-model-v2

Conversation

@johnjosephhorton

Copy link
Copy Markdown
Collaborator

Summary

  • add HostedModel as a small convenience factory over the existing openai_compatible inference service
  • reuse the standard OpenAI-compatible execution, telemetry, client caching, cleanup, and serialization paths
  • persist only base_url and the credential environment-variable name; never serialize a token
  • document the Python API and add focused construction, credential-resolution, validation, and round-trip tests

Why replace #2470

Current main already 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:

  • there is no __new__ factory class with misleading isinstance behavior; HostedModel is explicitly a convenience function returning a regular LanguageModel
  • no api_token is assigned through a read-only property; credentials are resolved from api_key_env at call time
  • deserialization uses the standard inference-service registry and preserves the environment-variable reference
  • hosted calls inherit the existing @report_errors_async execution method

Tests

  • focused suite: 14 passed, 1 opt-in live integration test skipped
  • Ruff lint and format checks pass
  • full suite reached 1,714 passed / 30 skipped before stopping on an unrelated current-main serialization coverage failure: SurveyMessage has no fixture in tests/serialization/data/1.0.8.json

Supersedes #2470.

@mintlify

mintlify Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
expectedparrot 🟢 Ready View Preview Sep 4, 2026, 3:28 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces HostedModel, a public convenience factory for constructing arbitrary models served by OpenAI-compatible endpoints while reusing the existing model registry, execution, credential, serialization, and cleanup paths.

  • Exports the factory from edsl and edsl.language_models.
  • Preserves endpoint and credential-environment references through model serialization without persisting tokens.
  • Documents direct Python usage and adds focused construction, validation, credential-resolution, and round-trip tests.
  • One input-normalization inconsistency can defer accepted whitespace errors until client creation or authentication.

Confidence Score: 4/5

The 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

Important Files Changed

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]
Loading

Reviews (1): Last reviewed commit: "Add HostedModel convenience factory" | Re-trigger Greptile

Comment thread edsl/language_models/hosted_model.py Outdated
johnjosephhorton and others added 2 commits September 4, 2026 11:38
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

This branch was successfully deployed

1 active (outdated) deployment
staging - docs — 09ace577 Deployed Sep 5, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants