feat: smart save_to with full path support and bug fix#85
feat: smart save_to with full path support and bug fix#85mikesoennichsen wants to merge 6 commits intomainfrom
Conversation
Previously, passing a raw markdown string to extract() or split() would treat the markdown content as a file path via Path(str).stem, producing garbage filenames. Now strings are only treated as file paths if they have a file extension. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
save_to now accepts either a directory path (auto-generates filename as
{input_file}_{method}_output.json) or a full file path ending in .json
(saves to that exact path). Parent directories are created automatically.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add save_to parameter to AsyncLandingAIADE.extract(), parse(), and split() methods, mirroring the sync client behavior. Supports both directory mode and full .json file path mode. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR enhances response saving ergonomics by allowing save_to to accept either an output directory (existing behavior) or an explicit .json file path (new behavior), and extends save_to support to async client methods. It also adjusts filename inference to avoid treating raw markdown strings as file paths.
Changes:
- Update
_save_responseto supportsave_toas either a directory or a full.jsonoutput path. - Refine
_get_input_filenamebehavior forstrinputs to reduce accidental filename derivation from raw markdown. - Add
save_tosupport to asyncextract,parse, andsplit, plus expanded test coverage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/landingai_ade/_client.py |
Implements full-path .json save support, updates filename inference, and adds async save_to handling. |
tests/test_save_to.py |
Adds tests for raw-markdown filename inference, full-path save behavior, and async save_to support. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Strings passed as file_input are always raw content (markdown), not file paths. The SDK sends strings to the API as content, not as file uploads. File inputs should use Path objects, tuples, or IO objects. This removes the unreliable Path(s).suffix heuristic that could misclassify strings containing periods (e.g. "example.com", "$10.50") as file paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When no input filename can be derived (e.g. raw markdown string), the
auto-generated name is now {method}_output.json instead of the redundant
output_{method}_output.json.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Update save_to docstrings on all 6 methods to describe the fallback naming when no input filename is available - Update _save_response docstring to mention the "output" special case - Handle os.PathLike inputs (not just Path) in _get_input_filename Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Three changes to the
save_toparameter:Bug fix: When
markdownis a raw string (e.g. chainingparse()→extract()), theoutput filename is now
output_extract_output.jsoninstead of garbage derived from themarkdown content. All string inputs are treated as content, not file paths — file inputs
should use
Pathobjects, tuples, or IO objects.Full path support:
save_tonow accepts a full file path ending in.jsonin additionto a directory. Directory mode auto-generates the filename as before.
Async support: Added
save_totoAsyncLandingAIADE.extract(),.parse(), and.split().Test plan
ruff checkcleanparse()→extract()with bothsave_tomodes🤖 Generated with Claude Code