|
232 | 232 | "# --- Configuration ---\n",
|
233 | 233 | "num_machines = 10 # Number of machines to simulate\n",
|
234 | 234 | "days = 30 # Number of days to simulate\n",
|
235 |
| - "freq_minutes = 10 # Frequency of readings (in minutes)\n", |
| 235 | + "freq_minutes = 15 # Frequency of readings (in minutes)\n", |
236 | 236 | "\n",
|
237 | 237 | "\n",
|
238 | 238 | "# --- Data Generation ---\n",
|
|
548 | 548 | "question = \"What was the average rotation for machine 3 the last week?\"\n",
|
549 | 549 | "# question = \"When was the last recorded anomaly?\"\n",
|
550 | 550 | "# question = \"How many readings had a vibration greater than 1.5?\"\n",
|
551 |
| - "# question = \"What was the number of anomalies per machine in last 48 hours?\"\n", |
| 551 | + "# question = \"What was the number of anomalies per machine in the last 48 hours?\"\n", |
552 | 552 | "\n",
|
553 | 553 | "# Convert to SQL\n",
|
554 | 554 | "sql_query = get_sql_from_llm(question)\n",
|
|
723 | 723 | " \"\"\"\n",
|
724 | 724 | " Due to a technicality, we need to translate between two different types of connection URLs.\n",
|
725 | 725 | " pandas was using a SQLAlchemy-style connection URL (crate://...),\n",
|
726 |
| - " while the MCP server uses an standard HTTP URL with basic auth.\n", |
| 726 | + " while the MCP server uses a standard HTTP URL with basic auth.\n", |
727 | 727 | " \"\"\"\n",
|
728 | 728 | "\n",
|
729 | 729 | " parsed = parse.urlparse(connection_string)\n",
|
|
749 | 749 | " server_params=StdioServerParameters(\n",
|
750 | 750 | " # The MCP server is a Python script that we installed earlier as part of `pip install`.\n",
|
751 | 751 | " # It got placed in the `bin` directory of our virtual environment.\n",
|
752 |
| - " command=f\"{os.environ['VIRTUAL_ENV']}/bin/cratedb-mcp\",\n", |
| 752 | + " command=\"cratedb-mcp\",\n", |
753 | 753 | " args=[\"serve\"],\n",
|
754 | 754 | " env={\n",
|
755 | 755 | " \"CRATEDB_CLUSTER_URL\": sqlalchemy_to_http(CONNECTION_STRING),\n",
|
|
759 | 759 | " )\n",
|
760 | 760 | "\n",
|
761 | 761 | " # The action group containing our MCP server.\n",
|
762 |
| - " # Other type of actions may be OpenAPI schemas or Python methods.\n", |
| 762 | + " # Other types of actions may be OpenAPI schemas or Python methods.\n", |
763 | 763 | " # https://docs.aws.amazon.com/bedrock/latest/userguide/action-define.html\n",
|
764 | 764 | " #\n",
|
765 | 765 | " # We stick to only CrateDB here for the sake of the workshop,\n",
|
|
772 | 772 | " return await InlineAgent(\n",
|
773 | 773 | " foundation_model=\"eu.amazon.nova-lite-v1:0\",\n",
|
774 | 774 | " instruction=f\"\"\"\n",
|
775 |
| - " You are a friendly assistant that receives information from CrateDB.\n", |
| 775 | + " You are a friendly assistant who receives information from CrateDB.\n", |
776 | 776 | " Your task is to translate questions into SQL queries, run them on CrateDB, and return back results.\n",
|
777 | 777 | " Try to generate SQL queries based on the known data model and don't ask questions back.\n",
|
778 | 778 | "\n",
|
779 | 779 | " You have the following tools available:\n",
|
780 | 780 | " 1. `query_sql`: Executes SQL queries on CrateDB\n",
|
781 | 781 | " 2. `get_cratedb_documentation`: Returns the table of contents for the CrateDB documentation. If in doubt about CrateDB-specific syntax, you can obtain the documentation here.\n",
|
782 |
| - " 3. `fetch_cratedb_docs`: One a specific link within the CrateDB documentation is identified, you can download its content here by providing the link.\n", |
| 782 | + " 3. `fetch_cratedb_docs`: Once a specific link within the CrateDB documentation is identified, you can download its content here by providing the link.\n", |
783 | 783 | " 4. `get_table_metadata`: This returns all metadata for tables in CrateDB.\n",
|
784 | 784 | "\n",
|
785 |
| - " Try to reason and give an interpretation about the result.\n", |
| 785 | + " Try to reason and give an interpretation of the result.\n", |
786 | 786 | "\n",
|
787 | 787 | " When asked about manuals, query the `manual` column of the `machine_manuals` table to retrieve the manual. Interpret its content to provide an answer.\n",
|
788 | 788 | "\n",
|
|
814 | 814 | "# fmt: off\n",
|
815 | 815 | "question = \"Is any of my machines behaving significantly different compared to others? I'm interested in vibration from motor_readings.\"\n",
|
816 | 816 | "# question = \"Did the vibration of machine 4 change between today and yesterday? Query the table motor_readings.\"\n",
|
817 |
| - "# question = \"How recent is my data in motor_readings? Is there any machine which lacks behind?\"\n", |
| 817 | + "# question = \"How recent is my data in motor_readings? Is there any machine that lacks behind?\"\n", |
818 | 818 | "# question = \"What was the highest temperature ever observed over all machines? Apply DATE_TRUNC to generate a weekly overview and include the week in your reply. The week is returned as a timestamp in millisecond, format it in a human-readable way.\"\n",
|
819 | 819 | "# fmt: on\n",
|
820 | 820 | "\n",
|
|
1017 | 1017 | "outputs": [],
|
1018 | 1018 | "source": [
|
1019 | 1019 | "# fmt: off\n",
|
1020 |
| - "question = \"Show me the maintenance steps for machine 5.\"\n", |
| 1020 | + "question = \"Show me the maintenance schedule for machine 5. Retrieve the manual column from the machine_manuals table and extract the maintenance schedule from its content.\"\n", |
1021 | 1021 | "# question = \"Is machine 4 overheating?\"\n",
|
1022 |
| - "# question = \"Give me the max and min vibration observed for machine 6 when rotations > 1600\"\n", |
| 1022 | + "# question = \"Give me the max and min vibration observed for machine 6 when rotations > 1600. Rotations are stored in the rotations column.\"\n", |
1023 | 1023 | "# question = \"What should I do if machine 2 has an anomaly?\"\n",
|
1024 | 1024 | "# question = \"What can be a reason for higher than usual values for the column vibration in motor_readings for machine 2?\"\n",
|
1025 | 1025 | "# question = \"Is machine 5's most recent temperature still ok according to the manual? Look up the most recent temperature from motor_readings.\"\n",
|
|
0 commit comments