Conversation
- Removed the dependency on 'mime' and 'node:fs/promises' for file handling. - Updated the upload methods to accept File or Blob objects directly. - Adjusted the upload logic to create FormData without needing to read files from the filesystem. - Cleaned up the download method in Files class, which was previously commented out. - Enhanced the LangflowClient to always return JSON responses. - Added unit tests for file uploads and user file handling. - Updated type definitions for request options to improve type safety.
There was a problem hiding this comment.
Pull Request Overview
Adds a new v2 Files API client, refactors existing file upload, removes unused dependencies, and tightens tests
- Introduce
Filesclass (v2) andUserFilemodel for file upload and listing - Refactor
Flow.uploadFileto acceptFile/Blobdirectly and dropmime/fs/pathdependencies - Update types to broaden header support, remove
mime, and convert tests to strict assertions with async handlers
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/user_file.ts | Add UserFile class to wrap upload responses |
| src/types.ts | Broaden RequestOptions.headers type and define response interface |
| src/files.ts | Implement Files class with upload and list methods |
| src/index.ts | Integrate Files into LangflowClient |
| src/flow.ts | Refactor uploadFile to use File/Blob directly |
| package.json | Remove unused mime dependency |
| README.md | Add docs for v1 images and v2 file uploads |
| src/test/utils.ts | Update createMockFetch for async spies and add blob comparisons |
| src/test/files.test.ts | Add end-to-end tests for the v2 Files API |
Comments suppressed due to low confidence (1)
src/files.ts:31
- Headers is not imported in this file, which will cause a runtime ReferenceError. Please import
Headersfrom 'undici' or the global fetch implementation.
const headers = new Headers();
- updates TypeScript to version 5.8.3 - always uses Headers from undici - Fix TypeScript compilation error by imporing AssertionError from node:assert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces the v2 files API to the Langflow clients, while also simplifying the existing upload API and making the tests more strict.
Enhancements to file upload functionality:
src/files.ts: Added a newFilesclass to support the Langflow v2 file upload API, including methods for uploading files and listing uploaded files.src/index.ts: Integrated the newFilesclass into theLangflowClientclass, enabling file upload and management features. [1] [2] [3]README.md: Updated documentation to include examples for file uploads using Langflow v1 and v2 APIs, along with usage instructions for image uploads and file tweaks. [1] [2]Refactoring and dependency cleanup:
package.json: Removed the unusedmimedependency as file type detection is no longer required.src/flow.ts: Refactored theuploadFilemethod to acceptFileorBlobobjects directly, eliminating the need formime,fs/promises, andpathimports. [1] [2] [3]Improvements to test coverage:
src/test/files.test.ts: Added comprehensive tests for the newFilesclass, covering file uploads and file listing functionality.src/test/flow.test.ts,src/test/index.test.ts, etc.): Updated assertions to usenode:assert/strictfor stricter checks and modified tests to align with the refactoreduploadFilemethod and asynchronous request handling. [1] [2] [3] [4]