Skip to content

Update prompt.py #162

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions libs/langchain-mongodb/langchain_mongodb/agent_toolkit/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,25 @@
MONGODB_FUNCTIONS_SUFFIX = """I should look at the collections in the database to see what I can query. Then I should query the schema of the most relevant collections."""


MONGODB_QUERY_CHECKER = """
MONGODB_QUERY_CHECKER = MONGODB_QUERY_CHECKER = """
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this change unintentional?

{query}

Double check the MongoDB query above for common mistakes, including:
- Missing content in the aggegregation pipeline
- Improperly quoting identifiers
- Improperly quoting operators
- The content in the aggregation pipeline is not valid JSON

- The query must be using pymongo syntax, so make sure the syntax is correct.
Example:
```python
db.CollectionName.aggregate([
{{ "$match": {{ "field": "value" }} }},
{{ "$group": {{ "_id": "$field", "count": {{ "$sum": 1 }} }} }},
{{ "$sort": {{ "count": -1 }} }}
])
```
If there are any of the above mistakes, rewrite the query. If there are no mistakes, just reproduce the original query.

Output the final MongoDB query only.

MongoDB Query: """