Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support binary files #975

Merged
merged 5 commits into from
Jan 4, 2025
Merged

support binary files #975

merged 5 commits into from
Jan 4, 2025

Conversation

pelikhan
Copy link
Member

@pelikhan pelikhan commented Jan 4, 2025

Files are passed as base64 encoded content from the playground view.


Here's a high-level summary of the changes made to the codebase:

  • Added workspace parameter to PromptParametersForm & RunButton
  • Updated TypeScript types to use newer language features (e.g., record, readonly, etc.)
    • 🔄 Changed union types to intersection types for better type encapsulation
    • 🔄 Made parameters and return types strictly non-nullable
  • Refactored ApiState properties:
    • Moved files importedFiles to a single array for simpler management
    • Removed unused properties (totalResults, selectedScriptid, etc.)
    • 👾 Encapsulated multiple state pieces into one
    • Added type definitions for script-related properties in ApiState
    • ⚙️ Simplified file representation with new WorkspaceFile interface
  • Updated FileItem to use React JSX, allowing the passing of arbitrary props directly.
    • Removed conditional rendering and instead rely on parent component logic
    • 🔄 Used dynamic imports for lazy loading
  • 👶 Introduced utility functions in "packages/core/utils.ts" for better code reuse:
    • Added functions for converting file objects to WorkspaceFile
    • Updated API state manipulation functions
  • Refactored the React components hierarchy, especially concerning form-related structures.
    • Removed redundant and verbose JSX elements
    • Separated concerns into smaller components
  • ➕ Introduced a new component FilesView for displaying files and allowing interaction with them.
    • Simplified file loading logic
  • Updated the package structure and dependencies:
    • Added react-refresh as a dev dependency

AI-generated content by pr-describe may be incorrect

Copy link

github-actions bot commented Jan 4, 2025

LGTM 🚀

The changes appear to improve the handling of binary data in various parts of the codebase. Here are the key points that make this an improvement:

  1. Binary Data Encapsulation: The introduction of encoding and content fields in WorkspaceFile ensures that all file contents, whether binary or text, are uniformly represented. This enhances clarity and consistency across the system.

  2. Base64 Encoding for Binary Files: The change to encode binary files as Base64 strings instead of raw byte arrays is a practical approach. It simplifies storage and transmission while maintaining data integrity.

  3. Mime Type Handling: The binary module now provides functions like isBinaryMimeType, which improves the modularity and readability of code by centralizing mime type checks.

  4. ZIP File Processing: The unzip function now handles binary file extraction more effectively, ensuring that all files, regardless of type, are returned with their correct encoding.

Overall, these changes enhance the robustness and flexibility of handling different types of file data in your application. They make it easier to manage mixed content and simplify potential issues related to binary data processing.

AI-generated content by pr-review may be incorrect

Copy link

github-actions bot commented Jan 4, 2025

Investigator report

AI-generated content by gai may be incorrect

@pelikhan pelikhan merged commit b6ffa83 into main Jan 4, 2025
12 of 13 checks passed
@pelikhan pelikhan deleted the inmemoryfiles branch January 4, 2025 23:05
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