-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
fix: type typo and getTools w custom action #1121
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Reviewed everything up to f88c3ec in 13 seconds
More details
- Looked at
22
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. js/src/sdk/models/actions.ts:142
- Draft comment:
Update the JSDoc comment to use the corrected type name.
* @param {ActionExecuteParam} data The data for the request.
- Reason this comment was not posted:
Comment was not on a valid diff hunk.
Workflow ID: wflow_Ydg74zZoRqQKFvYz
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
WalkthroughThis update addresses a typographical error in the Changes
🔗 Related PRs
Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts belowEmoji Descriptions:
Interact with the Bot:
|
This comment was generated by github-actions[bot]! JS SDK Coverage Report📊 Coverage report for JS SDK can be found at the following URL: 📁 Test report folder can be found at the following URL: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Incremental review on 53ad9d0 in 21 seconds
More details
- Looked at
175
lines of code in7
files - Skipped
0
files when reviewing. - Skipped posting
5
drafted comments based on config settings.
1. js/examples/e2e/demo.mjs:32
- Draft comment:
Add a newline at the end of the file for consistency and to adhere to best practices. - Reason this comment was not posted:
Confidence changes required:10%
The code indemo.mjs
anddemo.ts
is missing a newline at the end of the file. This is a minor issue but it's a good practice to end files with a newline to avoid potential issues with some tools and to adhere to POSIX standards.
2. js/examples/e2e/demo.ts:32
- Draft comment:
Add a newline at the end of the file for consistency and to adhere to best practices. - Reason this comment was not posted:
Confidence changes required:10%
The code indemo.mjs
anddemo.ts
is missing a newline at the end of the file. This is a minor issue but it's a good practice to end files with a newline to avoid potential issues with some tools and to adhere to POSIX standards.
3. js/src/frameworks/langchain.ts:72
- Draft comment:
The default value forfilters
ingetTools
is a good practice to prevent runtime errors. Ensure similar methods have consistent default values. - Reason this comment was not posted:
Confidence changes required:10%
ThegetTools
method inlangchain.ts
has been updated to provide a default value forfilters
. This change is beneficial as it prevents potential runtime errors whenfilters
is not provided. However, the change should be consistent across all similar methods.
4. js/src/sdk/actionRegistry.ts:138
- Draft comment:
Ensureaction
is defined before destructuringaction.metadata
to prevent potential runtime errors. - Reason this comment was not posted:
Confidence changes required:20%
Theaction.metadata
is being destructured without checking ifaction
is defined. This could lead to runtime errors ifaction
is undefined. Adding a fallback or a check would prevent such errors.
5. js/src/sdk/base.toolset.ts:144
- Draft comment:
Ensureaction
is defined before destructuringaction.metadata
to prevent potential runtime errors. This issue is also present inactionRegistry.ts
. - Reason this comment was not posted:
Confidence changes required:20%
Theaction.metadata
is being destructured without checking ifaction
is defined. This could lead to runtime errors ifaction
is undefined. Adding a fallback or a check would prevent such errors. This issue is also present inbase.toolset.ts
.
Workflow ID: wflow_2qzxtVpT6c3HJVdY
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
js/examples/e2e/demo.mjs
Outdated
@@ -1,24 +1,32 @@ | |||
import { Composio, LangchainToolSet } from "composio-core"; | |||
import { z } from "zod"; | |||
|
|||
const toolset = new LangchainToolSet(); | |||
const toolset = new LangchainToolSet({apiKey: "hwcxlkwxm3me2z6ll0ydf"}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@himanshu-dixit Should we load the API key from the env file?
53ad9d0
to
8108dd2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Incremental review on 8108dd2 in 21 seconds
More details
- Looked at
175
lines of code in7
files - Skipped
0
files when reviewing. - Skipped posting
5
drafted comments based on config settings.
1. js/examples/e2e/demo.mjs:32
- Draft comment:
Add a newline at the end of the file for consistency and to adhere to best practices. - Reason this comment was not posted:
Confidence changes required:10%
The code injs/examples/e2e/demo.mjs
andjs/examples/e2e/demo.ts
is missing a newline at the end of the file. This is a minor issue but it's a good practice to end files with a newline to avoid potential issues with some tools and to adhere to POSIX standards.
2. js/examples/e2e/demo.ts:32
- Draft comment:
Add a newline at the end of the file for consistency and to adhere to best practices. - Reason this comment was not posted:
Confidence changes required:10%
The code injs/examples/e2e/demo.mjs
andjs/examples/e2e/demo.ts
is missing a newline at the end of the file. This is a minor issue but it's a good practice to end files with a newline to avoid potential issues with some tools and to adhere to POSIX standards.
3. js/src/frameworks/langchain.ts:73
- Draft comment:
Consider providing a default value forentityId
to maintain consistency with other methods and improve code readability. - Reason this comment was not posted:
Confidence changes required:20%
ThegetTools
method injs/src/frameworks/langchain.ts
has a default parameter forfilters
but not forentityId
. It would be more consistent to also provide a default value forentityId
, similar to how it's done in theComposioToolSet
class.
4. js/src/sdk/actionRegistry.ts:138
- Draft comment:
Good use ofaction.metadata || {}
to safely destructurecallback
andtoolName
. - Reason this comment was not posted:
Confidence changes required:0%
Injs/src/sdk/actionRegistry.ts
, theexecuteAction
method usesaction.metadata || {}
to destructurecallback
andtoolName
. This is a good practice to avoid runtime errors ifmetadata
is undefined.
5. js/src/sdk/base.toolset.ts:141
- Draft comment:
Consider providing a default value for thefilters
parameter to enhance robustness and prevent potential issues ifundefined
is passed. - Reason this comment was not posted:
Confidence changes required:20%
Injs/src/sdk/base.toolset.ts
, thegetToolsSchema
method uses optional chaining and nullish coalescing operators effectively. However, thefilters
parameter is not given a default value, which could lead to issues ifundefined
is passed. Providing a default value would enhance robustness.
Workflow ID: wflow_GZPa42NWis89IGnn
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
const toolsWithCustomActions = ( | ||
await this.userActionRegistry.getAllActions() | ||
).filter((action) => { | ||
const { actionName, toolName } = action.metadata; | ||
const { name: actionName, toolName } = action.metadata || {}; | ||
return ( | ||
(!filters.actions || | ||
filters.actions.some( | ||
(name) => name.toLowerCase() === actionName!.toLowerCase() | ||
(name) => name.toLowerCase() === actionName?.toLowerCase() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug Fix: The current code introduces a potential logical error by using optional chaining with destructuring. This can lead to undefined values being destructured if action.metadata
is null or undefined, potentially causing runtime errors.
Actionable Suggestions:
- Ensure
action.metadata
is checked for null or undefined before destructuring. - Alternatively, provide default values during destructuring to prevent runtime errors.
This will ensure that the code handles cases where action.metadata
might not be present, thus avoiding unexpected behavior or crashes.
🔧 Suggested Code Diff:
- const { name: actionName, toolName } = action.metadata || {};
+ const { name: actionName = '', toolName = '' } = action.metadata || {};
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const toolsWithCustomActions = ( | |
await this.userActionRegistry.getAllActions() | |
).filter((action) => { | |
const { actionName, toolName } = action.metadata; | |
const { name: actionName, toolName } = action.metadata || {}; | |
return ( | |
(!filters.actions || | |
filters.actions.some( | |
(name) => name.toLowerCase() === actionName!.toLowerCase() | |
(name) => name.toLowerCase() === actionName?.toLowerCase() | |
const toolsWithCustomActions = (await this.userActionRegistry.getAllActions()).filter((action) => { | |
const { name: actionName = '', toolName = '' } = action.metadata || {}; | |
return ( | |
(!filters.actions || | |
filters.actions.some( | |
(name) => name.toLowerCase() === actionName.toLowerCase() || | |
name.toLowerCase() === toolName.toLowerCase() | |
) | |
) | |
); | |
}); |
}), | ||
response: z.record(z.any()), | ||
metadata: z.object({ | ||
actionName: z.string(), | ||
toolName: z.string(), | ||
name: z.string(), | ||
toolName: z.string().optional(), | ||
}), | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential Issue: The change from actionName
to name
and making toolName
optional can introduce logical errors if not handled properly across the codebase. This could lead to inconsistencies, especially if other parts of the code expect these fields to be present and named as before.
Actionable Steps:
- Codebase Review: Conduct a thorough review of the codebase to identify all instances where
actionName
andtoolName
are used. Update these references to align with the new structure. - Update Logic: Ensure that any logic relying on
toolName
being present is updated to handle cases where it might be undefined. Consider using default values or conditional checks. - Testing: Implement comprehensive testing to verify that the changes do not break existing functionality and that all edge cases are handled.
Code Suggestion:
Consider adding comments or documentation to highlight these changes for future reference and to aid other developers in understanding the new structure.
🔍 Review Summary
Release Note
Purpose:
Changes:
ActionxExecuteParam
toActionExecuteParam
inactions.ts
.Impact:
Original Description