Skip to content

feat: add explain command #57

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

Merged
merged 11 commits into from
Apr 11, 2025
Merged

feat: add explain command #57

merged 11 commits into from
Apr 11, 2025

Conversation

gagik
Copy link
Collaborator

@gagik gagik commented Apr 10, 2025

Screenshot 2025-04-11 at 9 41 50 AM Screenshot 2025-04-11 at 9 43 05 AM

@gagik gagik force-pushed the gagik/add-explain branch from b608fc9 to 599a179 Compare April 11, 2025 08:33
@gagik gagik marked this pull request as ready for review April 11, 2025 10:12
Copy link
Collaborator

@nirinchev nirinchev left a comment

Choose a reason for hiding this comment

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

Nice!

import { ToolArgs } from "../../tool.js";

export const AggregateArgs = {
pipeline: z.array(z.object({}).passthrough()).describe("An array of aggregation stages to execute"),
limit: z.number().optional().default(10).describe("The maximum number of documents to return"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know you didn't change this, but I wonder if we should drop limit here? Considering the agg framework has a $limit stage, I wonder if that could conflict with a pipeline the model generates.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My concern is the toArray() call then. it's going to try to load all the documents from the aggregation result into memory

Copy link
Collaborator

Choose a reason for hiding this comment

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

True - just wonder if we might run into trouble if a user asks for give me the top 50 docs and the model generates a stage, but our limit kicks in. Haven't looked into it, but we could check if there's a way to stream the responses to the model.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll remove it and we can revisit with a solution

@gagik gagik force-pushed the gagik/null-assertions branch from 4de7d50 to 2a87387 Compare April 11, 2025 14:10
Base automatically changed from gagik/null-assertions to main April 11, 2025 14:54
@gagik gagik merged commit fe6d814 into main Apr 11, 2025
4 checks passed
@gagik gagik deleted the gagik/add-explain branch April 11, 2025 15:11
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.

2 participants