Skip to content

Commit 82bfc1f

Browse files
committed
fix script to add/search restaurant data on cosmosdb
1 parent d6da750 commit 82bfc1f

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

docs/index.md

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,49 @@
11
# template-fastapi
22

3+
## MCP
4+
5+
- [FastAPI-MCP](https://github.com/tadata-org/fastapi_mcp)
6+
- [FastAPI で作成した API エンドポイントをモデル コンテキスト プロトコル (MCP) ツールとして公開してみる](https://dev.classmethod.jp/articles/fastapi-api-mcp/)
7+
- [MCP Inspector > docs](https://modelcontextprotocol.io/docs/tools/inspector)
8+
- [MCP Inspector > codes](https://github.com/modelcontextprotocol/inspector)
9+
310
## FastAPI
411

512
- [FastAPI](https://fastapi.tiangolo.com/)
613
- [Settings and Environment Variables](https://fastapi.tiangolo.com/advanced/settings/)
714

8-
## Azure Functions
15+
## OpenTelemetry
16+
17+
- [Docs > Language APIs & SDKs > Python > Getting Started](https://opentelemetry.io/docs/languages/python/getting-started/)
18+
19+
## Azure
20+
21+
### Azure Functions
922

1023
- [Azure Functions で OpenTelemetry を使用する](https://learn.microsoft.com/ja-jp/azure/azure-functions/opentelemetry-howto?tabs=app-insights&pivots=programming-language-python)
1124
- [Using FastAPI Framework with Azure Functions](https://learn.microsoft.com/en-us/samples/azure-samples/fastapi-on-azure-functions/fastapi-on-azure-functions/)
1225
- [ks6088ts-labs/azure-functions-python](https://github.com/ks6088ts-labs/azure-functions-python)
1326

14-
## MCP
27+
### Azure Cosmos DB
1528

16-
- [FastAPI-MCP](https://github.com/tadata-org/fastapi_mcp)
17-
- [FastAPI で作成した API エンドポイントをモデル コンテキスト プロトコル (MCP) ツールとして公開してみる](https://dev.classmethod.jp/articles/fastapi-api-mcp/)
18-
- [MCP Inspector > docs](https://modelcontextprotocol.io/docs/tools/inspector)
19-
- [MCP Inspector > codes](https://github.com/modelcontextprotocol/inspector)
29+
- [VectorDistance() を使用したクエリによるベクトル検索を実行する](https://learn.microsoft.com/ja-jp/azure/cosmos-db/nosql/vector-search#perform-vector-search-with-queries-using-vectordistance)
30+
- [LangChain / Azure Cosmos DB No SQL](https://python.langchain.com/docs/integrations/vectorstores/azure_cosmos_db_no_sql/)
2031

21-
## Application Insights
32+
```shell
33+
# Azure Cosmos DB のローカル認証を有効にする
34+
# (注意: この操作はセキュリティ上のリスクを伴うため、開発環境でのみ使用してください。)
35+
az resource update \
36+
--resource-group $RESOURCE_GROUP \
37+
--name $COSMOS_DB_ACCOUNT_NAME \
38+
--resource-type "Microsoft.DocumentDB/databaseAccounts" \
39+
--set properties.disableLocalAuth=false
40+
```
41+
42+
### Application Insights
2243

2344
- [Application Insights の概要 - OpenTelemetry の可観測性](https://learn.microsoft.com/ja-jp/azure/azure-monitor/app/app-insights-overview)
2445
- [Azure Monitor OpenTelemetry を設定する](https://learn.microsoft.com/ja-jp/azure/azure-monitor/app/opentelemetry-configuration?tabs=python)
2546
- [open-telemetry/opentelemetry-python > Basic Trace](https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples/basic_tracer)
2647
- [FastAPI のテレメトリデータを Azure Application Insights に送る](https://qiita.com/hoto17296/items/2f366dfabdbe3d1d4e97)
2748
- [【Azure Functions】 - Application Insights のログが表示されない問題](https://zenn.dev/headwaters/articles/ff19f7e1b99b44)
2849
- [opentelemetry-instrumentation-fastapi (python) から OpenTelemetry に入門する](https://zenn.dev/taxin/articles/opentelemetry-fast-api-instrumentation-basics)
29-
30-
## OpenTelemetry
31-
32-
- [Docs > Language APIs & SDKs > Python > Getting Started](https://opentelemetry.io/docs/languages/python/getting-started/)

scripts/foodies_restaurants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import typer
77
from azure.cosmos import CosmosClient, PartitionKey
8-
from langchain_azure_openai import AzureOpenAIEmbeddings
98
from langchain_core.documents import Document
9+
from langchain_openai import AzureOpenAIEmbeddings
1010
from rich.console import Console
1111

1212
from template_fastapi.settings.azure_cosmosdb import get_azure_cosmosdb_settings
@@ -139,7 +139,7 @@ def search(
139139
query_text = f"""
140140
SELECT TOP {k} r.id, r.name, r.description, r.price, r.tags
141141
FROM restaurants r
142-
ORDER BY VECTOR_DISTANCE(r.vector, @queryVector)
142+
ORDER BY VectorDistance(r.vector, @queryVector)
143143
"""
144144

145145
parameters = [{"name": "@queryVector", "value": query_embedding}]

0 commit comments

Comments
 (0)