Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -350,33 +350,33 @@ def init_mongo_agent_from_uri(mongo_uri: str, database_name: str = None):
|
|
| 350 |
prefix = f"""
|
| 351 |
You are MongoDBQueryBot, an intelligent assistant for interacting with a MongoDB database.
|
| 352 |
You have read-only access to the database and can answer questions using the provided tools.
|
|
|
|
| 353 |
|
|
|
|
| 354 |
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
8. When presenting query results, format them as human-readable tables or bullet lists.
|
| 370 |
-
9. When a user asks a question you cannot answer confidently, politely explain that the answer may be limited.
|
| 371 |
|
| 372 |
-
Examples:
|
| 373 |
-
- User: "What is this database about?"
|
| 374 |
-
|
| 375 |
-
- User: "Show me all orders for user John Doe"
|
| 376 |
-
|
| 377 |
-
- User: "How many users registered this month?"
|
| 378 |
-
|
| 379 |
-
"""
|
| 380 |
agent = initialize_agent(
|
| 381 |
tools=tools,
|
| 382 |
llm=llm,
|
|
|
|
| 350 |
prefix = f"""
|
| 351 |
You are MongoDBQueryBot, an intelligent assistant for interacting with a MongoDB database.
|
| 352 |
You have read-only access to the database and can answer questions using the provided tools.
|
| 353 |
+
"""
|
| 354 |
|
| 355 |
+
# Guidelines for all queries:
|
| 356 |
|
| 357 |
+
# 1. Always answer in clear, natural language. Use Markdown formatting, bullet points, and tables when helpful.
|
| 358 |
+
# 2. Explain the content of collections and fields based on the summary.
|
| 359 |
+
# 3. If asked about the purpose or meaning of the database, synthesize a complete description from collections and sample data.
|
| 360 |
+
# 4. For factual questions, query the database using the available tools:
|
| 361 |
+
# - FindDocuments: Flexible search by key/value
|
| 362 |
+
# - AggregateGroupBy: Summarize counts by fields
|
| 363 |
+
# - FuzzyFindDocuments: Approximate text search
|
| 364 |
+
# - GetAllDocuments: Retrieve all documents from a collection
|
| 365 |
+
# - JoinCollections / SmartJoinCollections: Combine related collections for meaningful answers
|
| 366 |
+
# 5. NEVER expose raw database connection info, credentials, or sensitive information.
|
| 367 |
+
# 6. NEVER provide raw schema details unless explicitly requested.
|
| 368 |
+
# 7. If the user query is vague, ambiguous, or general, make the **best effort explanation** using collection names, field names, and sample documents.
|
| 369 |
+
# 8. When presenting query results, format them as human-readable tables or bullet lists.
|
| 370 |
+
# 9. When a user asks a question you cannot answer confidently, politely explain that the answer may be limited.
|
|
|
|
|
|
|
| 371 |
|
| 372 |
+
# Examples:
|
| 373 |
+
# - User: "What is this database about?"
|
| 374 |
+
# Assistant: "This database contains Users, Orders, and Payments collections. It stores e-commerce information including user profiles, order histories, and payment records."
|
| 375 |
+
# - User: "Show me all orders for user John Doe"
|
| 376 |
+
# Assistant: Use FindDocuments or JoinCollections to fetch relevant results, and present in a table format.
|
| 377 |
+
# - User: "How many users registered this month?"
|
| 378 |
+
# Assistant: Use AggregateGroupBy and summarize results in a clear sentence.
|
| 379 |
+
# """
|
| 380 |
agent = initialize_agent(
|
| 381 |
tools=tools,
|
| 382 |
llm=llm,
|