|
1 | 1 | import json
|
2 | 2 | import logging
|
3 |
| -from typing import Any, Literal |
| 3 | +from typing import Any, Literal, Optional |
4 | 4 |
|
5 | 5 | from fastmcp.server import FastMCP
|
6 | 6 | from pydantic import Field, ValidationError
|
@@ -322,6 +322,70 @@ def list_example_data_models() -> dict[str, Any]:
|
322 | 322 | "total_examples": len(examples),
|
323 | 323 | "usage": "Use the get_example_data_model tool with any of the example names above to get a specific data model",
|
324 | 324 | }
|
| 325 | + |
| 326 | + @mcp.prompt(title="Create New Data Model") |
| 327 | + def create_new_data_model(data_context: str = Field(..., description="A description of the data and any specific details the agent should focus on."), |
| 328 | + use_cases: str = Field(..., description="A list of use cases for the data model to address."), |
| 329 | + desired_nodes: str = "", |
| 330 | + desired_relationships: str = "" |
| 331 | + ) -> str: |
| 332 | + """ |
| 333 | + Guide the agent in creating a new graph data model. |
| 334 | + You should provide the sample data alongside this prompt. |
| 335 | + Be as descriptive as possible when providing data context and use cases. These will be used to effectively shape your data model. |
| 336 | + If you have an idea of what your data model should look like, you may optionally provide desired nodes and relationships. |
| 337 | +
|
| 338 | + Parameters: |
| 339 | + * data_context: A description of the data and any specific details the agent should focus on. |
| 340 | + * use_cases: A list of use cases for the data model to address. |
| 341 | + * desired_nodes (optional): A list of node labels that you would like to be included in the data model. |
| 342 | + * desired_relationships (optional): A list of relationship types that you would like to be included in the data model. |
| 343 | + """ |
| 344 | + |
| 345 | + prompt = f"""Please use the following context and the provided sample data to generate a new graph data model. |
| 346 | +
|
| 347 | +Here is the data context: |
| 348 | +{data_context} |
| 349 | +
|
| 350 | +Here are the use cases: |
| 351 | +{use_cases} |
| 352 | +""" |
| 353 | + |
| 354 | + if desired_nodes: |
| 355 | + prompt += f""" |
| 356 | +Here are the desired nodes: |
| 357 | +{desired_nodes} |
| 358 | +""" |
| 359 | + |
| 360 | + if desired_relationships: |
| 361 | + prompt += f""" |
| 362 | +Here are the desired relationships: |
| 363 | +{desired_relationships} |
| 364 | +""" |
| 365 | + |
| 366 | + prompt += """ |
| 367 | +Additional Instructions: |
| 368 | +* Ensure that if you know the source information for Properties, you include it in the data model. |
| 369 | +* If you deviate from the user's requests, you must clearly explain why you did so. |
| 370 | +* Only use data from the provided sample data to create the data model (Unless explicitly stated otherwise). |
| 371 | +* If the user requests use cases that are outside the scope of the provided sample data, you should explain why you cannot create a data model for those use cases. |
| 372 | +
|
| 373 | +Process: |
| 374 | +1. Analysis |
| 375 | + 1a. Analyze the sample data |
| 376 | + 1b. Use the `list_example_data_models` tool to check if there are any relevant examples that you can use to guide your data model |
| 377 | + 1c. Use the `get_example_data_model` tool to get any relevant example data models |
| 378 | +2. Generation |
| 379 | + 2a. Generate a new data model based on your analysis, the provided context and any examples |
| 380 | + 2b. Use the `get_mermaid_config_str` tool to validate the data model and get a Mermaid visualization configuration |
| 381 | + 2c. If necessary, correct any validation errors and repeat step 2b |
| 382 | +3. Final Response |
| 383 | + 3a. Show the user the visualization with Mermaid, if possible |
| 384 | + 3b. Explain the data model and any gaps between the requested use cases |
| 385 | + 3c. Request feedback from the user (remember that data modeling is an iterative process) |
| 386 | +""" |
| 387 | + |
| 388 | + return prompt |
325 | 389 |
|
326 | 390 | return mcp
|
327 | 391 |
|
|
0 commit comments