Skip to content

Conversation

@Khurdhula-Harshavardhan
Copy link
Collaborator

@Khurdhula-Harshavardhan Khurdhula-Harshavardhan commented Sep 13, 2025

Refactor how file uploads and multipart form data are handled across several modules, standardizing the approach for both synchronous and asynchronous requests. The main changes involve introducing a files parameter to request constructors, updating request logic to handle multipart forms properly, and simplifying header/content-type management. Additionally, some redundant imports and unnecessary code have been removed for clarity.

File upload and multipart form improvements:

  • Added a files parameter to both Request and AsyncRequest classes, and updated their constructors and request logic to handle multipart file uploads in a consistent way. This includes proper management of form fields, content types, and file data. [1] [2] [3] [4] [5] [6] [7] [8]

  • Refactored API methods in audio.py, embedding.py, embedding_v2.py, and translate.py to use the new files parameter for file uploads, replacing previous ad-hoc handling of Content-Type headers and file data. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]

Code cleanup and simplification:

  • Removed unnecessary imports of build_path and redundant code for building paths and setting content types, as these are now handled more cleanly via the new files logic. [1] [2] [3]

Refactors the JigsawStack client to consistently use base_url and headers instead of the previous api_url and request logging flags. It also improves multipart file upload handling, simplifies request configuration, and updates the initialization and usage patterns for both sync and async clients and their modules. Additionally, a new test file is added to the CI workflow.

Client configuration and initialization refactor:

  • Updated the main JigsawStack and AsyncJigsawStack classes in jigsawstack/__init__.py to use base_url and headers for API configuration, removing api_url and request logging flags. All submodules now receive these parameters for consistent initialization. [1] [2] [3]
  • Refactored ClientConfig and related config classes in jigsawstack/_config.py to use base_url and headers, removing legacy parameters.

Request handling improvements:

  • Modified AsyncRequestConfig and AsyncRequest in jigsawstack/async_request.py to support base_url and headers, and improved multipart file upload logic by handling files and content-type correctly. [1] [2] [3] [4] [5] [6] [7]

Module-level changes for audio:

  • Updated Audio and AsyncAudio classes in jigsawstack/audio.py to use the new config pattern and improved the speech_to_text method to handle file uploads using the new multipart logic. [1] [2] [3] [4]

Testing and CI:

  • Added a new test file test_vocr.py to the CI workflow in .github/workflows/ci.yml for improved test coverage.

Testing:

  • Added test_vocr.py to the CI workflow to ensure new and existing file upload functionality is tested.

@Khurdhula-Harshavardhan Khurdhula-Harshavardhan added bug Something isn't working enhancement New feature or request bug-fix labels Sep 13, 2025
@Khurdhula-Harshavardhan Khurdhula-Harshavardhan marked this pull request as ready for review September 13, 2025 02:30
@winzamark123
Copy link
Collaborator

pushed the small fix following the review. if looks good go ahead and merge @Khurdhula-Harshavardhan !

Copy link
Collaborator

@winzamark123 winzamark123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for your hard work

@winzamark123 winzamark123 merged commit e43131c into main Sep 16, 2025
18 checks passed
@winzamark123 winzamark123 deleted the fix/multipart-form-uploads branch September 16, 2025 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working bug-fix enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants