fix(models): point AsyncDottxt's missing-model error to from_dottxt() by BlueX888 · Pull Request #2075 · dottxt-ai/outlines · GitHub
Skip to content

fix(models): point AsyncDottxt's missing-model error to from_dottxt() - #2075

Open
BlueX888 wants to merge 1 commit into
dottxt-ai:mainfrom
BlueX888:fix/prep-async-dottxt-error-references-nonexistent-from-dottxt-async
Open

BlueX888 wants to merge 1 commit into
dottxt-ai:mainfrom
BlueX888:fix/prep-async-dottxt-error-references-nonexistent-from-dottxt-async

Conversation

@BlueX888

Copy link
Copy Markdown

Summary

AsyncDottxt.generate's "missing model identifier" error told users to pass the model to from_dottxt_async(), a function that does not exist in outlines. The message now points to from_dottxt(), which is the only Dottxt factory and handles both sync and async clients.

Why

When AsyncDottxt.generate is called without a model= keyword argument and the model was created without an identifier, it raises (src/outlines/models/dottxt.py:235-239):

A model identifier is required. Pass it to from_dottxt_async() or as a model= keyword argument at generation time.

from_dottxt_async does not exist anywhere in the codebase. outlines exports only from_dottxt (src/outlines/models/__init__.py:13, listed in __all__ at line 65), which dispatches on the client type and returns an AsyncDottxt for a dottxt.AsyncDotTxt client (src/outlines/models/dottxt.py:285-303). The sync Dottxt.generate branch already said from_dottxt() (src/outlines/models/dottxt.py:139-143); the async branch had drifted.

Changes

  • src/outlines/models/dottxt.py: in AsyncDottxt.generate's error message, from_dottxt_async() → from_dottxt().
  • tests/models/test_dottxt.py: add test_dottxt_async_missing_model_error_names_existing_factory, which fails if the error names anything other than from_dottxt().

Testing

  • New test on the unpatched tree (fails before the fix):
AssertionError: Regex pattern did not match.
Expected regex: 'Pass it to `from_dottxt\(\)`'
Actual message: 'A model identifier is required. Pass it to `from_dottxt_async()` or as a `model=` keyword argument at generation time.'
  • pytest tests/models/test_dottxt.py -m "not api_call" → 7 passed, 12 deselected (deselected tests are marked api_call and require a live Dottxt API key).
  • pre-commit run --all-files → all hooks passed (check-merge-conflict, debug-statements, end-of-file-fixer, trailing-whitespace, mypy, ruff).

Checklist

  • We should be able to understand what the PR does from its title only;
  • There is a high-level description of the changes;
  • If I add a new feature, there is an issue discussing it already; (n/a — bug fix)
  • There are links to all the relevant issues, discussions and PRs; (no existing issue or discussion covers this)
  • The branch is rebased on the latest main commit;
  • Commit messages follow these guidelines;
  • One commit per logical change;
  • The code respects the current naming conventions;
  • Docstrings follow the numpy style guide; (no docstrings changed)
  • pre-commit is installed and configured on your machine, and you ran it before opening the PR;
  • There are tests covering the changes;
  • The documentation is up-to-date; (no documentation references from_dottxt_async)

This branch has not been deployed

No deployments
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.

1 participant