Skip to content

Commit

Permalink
Quick fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
feaselkl committed Nov 21, 2024
1 parent 942432b commit d96720c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
74 changes: 37 additions & 37 deletions docs/03_implement_vector_search_in_cosmos_db_nosql/03_02.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,40 +311,40 @@ Use the Data Explorer to populate the `MaintenanceRequests` container with data
1. Observe the files being processed in the Log Stream and review documents in the Cosmos DB Data Explorer to confirm the function correctly populated the `request_vector` field for newly added documents.
2. Execute a query to find documents similar to "air conditioning malfunction" using the `VectorDistance()` function via Cosmos DB Data Explorer. You can find the vector embeddings for "air conditioning malfunction" in the `Query_Vector.txt` file in the [src\data folder](https://github.com/microsoft/TechExcel-Integrating-Azure-PaaS-and-AI-Services-for-AI-Design-Wins/tree/main/src/data).

<details markdown="block">
<summary><strong>Expand this section to view the solution</strong></summary>

To execute a query using the `VectorDistance()` function for "air conditioning malfunction":

1. In the [Azure portal](https://portal.azure.com), navigate to your Cosmos DB resource and select **Data Explorer** in the left-hand menu.
2. In the Data Explorer, expand the **ContosoSuites** database and the **MaintenanceRequests** container, then select **Items**.
3. On the toolbar, select **New SQL Query**.

![The New SQL Query button on the Data Explorer Items toolbar is highlighted.](../../media/Solution/0302-azure-cosmos-db-data-explorer-items-new-sql-query.png)

4. In the new query window, paste in the following query:

```sql
SELECT c.hotel_id, c.hotel, c.details, VectorDistance(c.request_vector, <QUERY_VECTOR>) AS SimilarityScore
FROM c
```

5. Replace the `<QUERY_VECTOR>` token in the query with the vectorized representation of "air conditioning malfunction," which you can find in the `Query_Vector.txt` file in the [src\data folder](https://github.com/microsoft/TechExcel-Integrating-Azure-PaaS-and-AI-Services-for-AI-Design-Wins/tree/main/src/data). Copy the entire contents of the file, and paste it into the query in place of `<QUERY_VECTOR>`.
6. Select **Execute Query** on the toolbar and observe the output in the **Results** panel. You should see a list of results similar to the following (abbreviated for brevity):

```json
{
"hotel_id": 1,
"hotel": "Oceanview Inn",
"details": "The air conditioning (A/C) unit in room 227 is malfunctioning and making a loud noise. Customer will be out of the room between 5:00 and 8:30 PM this evening. This needs immediate maintenance attention. If the issue cannot be resolved, we will need to move the customer to a new room.",
"SimilarityScore": 0.847799148429741
},
{
"hotel_id": 12,
"hotel": "The Downtown Plaza Hotel",
"details": "The thermostat does not appear to be working in room 328, and the air conditioning (A/C) unit will not turn on to cool down the room.",
"SimilarityScore": 0.838297398035295
}
```

</details>
<details markdown="block">
<summary><strong>Expand this section to view the solution</strong></summary>

To execute a query using the `VectorDistance()` function for "air conditioning malfunction":

1. In the [Azure portal](https://portal.azure.com), navigate to your Cosmos DB resource and select **Data Explorer** in the left-hand menu.
2. In the Data Explorer, expand the **ContosoSuites** database and the **MaintenanceRequests** container, then select **Items**.
3. On the toolbar, select **New SQL Query**.

![The New SQL Query button on the Data Explorer Items toolbar is highlighted.](../../media/Solution/0302-azure-cosmos-db-data-explorer-items-new-sql-query.png)

4. In the new query window, paste in the following query:

```sql
SELECT c.hotel_id, c.hotel, c.details, VectorDistance(c.request_vector, <QUERY_VECTOR>) AS SimilarityScore
FROM c
```

5. Replace the `<QUERY_VECTOR>` token in the query with the vectorized representation of "air conditioning malfunction," which you can find in the `Query_Vector.txt` file in the [src\data folder](https://github.com/microsoft/TechExcel-Integrating-Azure-PaaS-and-AI-Services-for-AI-Design-Wins/tree/main/src/data). Copy the entire contents of the file, and paste it into the query in place of `<QUERY_VECTOR>`.
6. Select **Execute Query** on the toolbar and observe the output in the **Results** panel. You should see a list of results similar to the following (abbreviated for brevity):

```json
{
"hotel_id": 1,
"hotel": "Oceanview Inn",
"details": "The air conditioning (A/C) unit in room 227 is malfunctioning and making a loud noise. Customer will be out of the room between 5:00 and 8:30 PM this evening. This needs immediate maintenance attention. If the issue cannot be resolved, we will need to move the customer to a new room.",
"SimilarityScore": 0.847799148429741
},
{
"hotel_id": 12,
"hotel": "The Downtown Plaza Hotel",
"details": "The thermostat does not appear to be working in room 328, and the air conditioning (A/C) unit will not turn on to cool down the room.",
"SimilarityScore": 0.838297398035295
}
```

</details>
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ To inspect the token consumption metrics emitted by the APIM policy in Applicati

</details>

## Bonus Task (if time allows)
## Bonus Tasks (if time allows)

This bonus task allows you to explore API Management's support of backend pools when you want to implement multiple backends for an API and load-balance requests across those backends. You will implement a load-balanced pool to distribute the LLM workload across two instances of Azure OpenAI.

Expand Down

0 comments on commit d96720c

Please sign in to comment.