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

type.constructor(input, config) #68

Merged
merged 15 commits into from
Mar 3, 2025
Merged

type.constructor(input, config) #68

merged 15 commits into from
Mar 3, 2025

Conversation

sroussey
Copy link
Owner

@sroussey sroussey commented Mar 2, 2025

No description provided.

Copy link

netlify bot commented Mar 2, 2025

Deploy Preview for ellmers-web ready!

Name Link
🔨 Latest commit 402a185
🔍 Latest deploy log https://app.netlify.com/sites/ellmers-web/deploys/67c4f6c257387a00088b3ef2
😎 Deploy Preview https://deploy-preview-68--ellmers-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Owner Author

@sroussey sroussey left a comment

Choose a reason for hiding this comment

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

Very early, typescript, and particularly arrays are very unhappy. tests run fine though. not so sure about examples

sroussey added 9 commits March 2, 2025 09:23
- Rename `createTask` to `createTaskFromJSON` for clarity
- Add validation to prevent subgraph creation for non-CompoundTasks
- Improve type safety and error handling in task creation
- Use type checking with `instanceof` for CompoundTask subgraph assignment
tests run 100% and building packages does not fail. Examples are next...

- Update task interfaces and constructors to support more precise typing
- Modify ArrayTask factory to handle more complex task type scenarios
- Improve TaskRegistry registration with stronger type constraints
- Add more robust error handling in task validation methods
- Update compound task output type definitions
- Enhance ITask and ICompoundTask interfaces with more generic type parameters
- Remove @ts-ignore and @ts-expect-error comments in multiple files
- Enhance type casting and type safety in task and repository classes
- Add explicit type annotations to improve type inference
- Update type handling in Workflow and task creation methods
- Add detailed documentation for TaskBase class properties and methods
- Improve type annotations and add explicit type definitions
- Enhance input/output handling with more robust validation
- Add comprehensive comments explaining task lifecycle and event handling
- Remove unnecessary type imports and clean up type definitions
@sroussey sroussey force-pushed the rework-task-constructors branch from 812b9ea to 02d5617 Compare March 2, 2025 22:16
@sroussey sroussey force-pushed the rework-task-constructors branch from 02d5617 to fa5a4a1 Compare March 2, 2025 22:18
sroussey added 3 commits March 2, 2025 14:28
- Update progress event signatures to support optional message and details
- Modify event emission in tasks to pass additional context
- Enhance type definitions for task progress events
- Simplify progress handling across different task types
@sroussey sroussey changed the title [WIP] type.constructor(input, config) type.constructor(input, config) Mar 3, 2025
@sroussey sroussey marked this pull request as ready for review March 3, 2025 00:36
@sroussey sroussey requested a review from Copilot March 3, 2025 00:36
@sroussey sroussey self-assigned this Mar 3, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR refactors several task and repository classes to adopt TypeScript generics and improve type safety while also updating workflow and storage integration. Key changes include:

  • Converting task classes (SimilarityTask, TextSummaryTask, TextQuestionAnswerTask, etc.) to use generics for input, output, and config.
  • Updating array task factory calls and workflow definitions to support the new generic parameters.
  • Adjusting repository storage queries and test setups for improved type support.

Reviewed Changes

File Description
packages/ai/src/task/SimilarityTask.ts Converted class to use generics and updated input validation casting.
packages/ai/src/task/TextSummaryTask.ts Updated constructor signature for improved clarity.
packages/ai/src/task/TextTranslationTask.ts Updated task factory call with generics; cast to any introduced.
packages/ai/src/task/DownloadModelTask.ts Refactored class to use generics and adjusted progress reporting.
packages/ai/src/task/DocumentSplitterTask.ts Revised class declaration to use generics for consistency.
packages/storage/src/tabular/SqliteTabularRepository.ts Enclosed table names in backticks for SQL safety.
packages/storage/src/tabular/PostgresTabularRepository.ts Adjusted index search with TS error suppression comment.
packages/job-queue/src/job/JobQueue.ts Updated waitFor return type casting to improve type inference.
examples/web/src/RunGraphFlow.tsx Updated task type check from property to instance check for compound tasks.
(Other files) Similar updates have been applied for improved type safety and consistency.

Copilot reviewed 60 out of 60 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

packages/storage/src/tabular/PostgresTabularRepository.ts:223

  • The use of '@ts-expect-error' here suggests an underlying type mismatch. Consider revisiting the type definitions for validColumns and searchKeys to eliminate the need for error suppression.
// @ts-expect-error

@sroussey sroussey merged commit 43de646 into main Mar 3, 2025
8 checks passed
@sroussey sroussey deleted the rework-task-constructors branch March 3, 2025 17:51
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