HsYu223/Com.Ai.Cars.Rs

C#

0

4 commits

updated Dec 4, 2025

See the code

README

AI 聊天與自訂資料

此專案示範如何使用 AI 語言模型與自訂資料進行聊天互動的應用程式。該範本目前仍處於早期預覽階段。如有回饋意見,歡迎填寫此簡短問卷: https://aka.ms/dotnet-chat-templatePreview2-survey。

[!NOTE] 在執行本專案之前,您需要為所選的提供者設定 API 金鑰或端點。下方有關於不同選項的詳細說明。

先決條件

若要使用 Azure OpenAI 或 Azure AI Search,您需要一個 Azure 帳戶。若尚未擁有帳戶,請建立一個: https://azure.microsoft.com/free/。

專案結構

此專案遵循 .NET 專案結構最佳實踐:

Com.Ai.Cars.Rs/
├── Components/           # Blazor 元件
│   ├── Layout/          # 版面配置元件
│   ├── Pages/           # 頁面元件
│   └── App.razor        # 應用程式根元件
├── Services/            # 商業邏輯與服務
│   ├── Ingestion/       # 資料擷取服務
│   ├── SemanticSearch.cs    # 語意搜尋服務
│   └── IngestedChunk.cs     # 擷取資料模型
├── wwwroot/             # 靜態資源和資料
├── Program.cs           # 應用程式進入點
└── Com.Ai.Cars.Rs.csproj   # 專案組態檔

設定 AI 模型提供者

使用 Azure OpenAI

若要使用 Azure OpenAI,您需要一個 Azure 帳戶以及一個 Azure OpenAI Service 資源。詳細說明請參閱 Azure OpenAI Service 文件: https://learn.microsoft.com/azure/ai-services/openai/how-to/create-resource。

1. 建立 Azure OpenAI Service 資源

請參閱: https://learn.microsoft.com/azure/ai-services/openai/how-to/create-resource?pivots=web-portal。

2. 部署模型

將 gpt-4o-mini 與 text-embedding-3-small 模型部署到您的 Azure OpenAI Service 資源。建立部署時,請將部署名稱設為與模型相同(gpt-4o-mini 與 text-embedding-3-small)。

欲了解如何部署模型,請參閱: https://learn.microsoft.com/azure/ai-services/openai/how-to/create-resource?pivots=web-portal#deploy-a-model。

3. 設定 API 金鑰與端點

使用 .NET User Secrets 為本專案設定 Azure OpenAI 的 API 金鑰與端點:

  1. 在 Azure 入口網站中,前往您的 Azure OpenAI 資源。
  2. 從「Keys and Endpoint」區段複製「Endpoint」網址與「Key 1」。
  3. 在 Visual Studio 中,於 Solution Explorer 對專案點選右鍵,選取 Manage User Secrets。
  4. 此操作會開啟 secrets.json 檔案,您可以在此儲存 API 金鑰與端點而不會被版本控制追蹤。將下列鍵值加入檔案:
{
  "AzureOpenAI:Endpoint": "YOUR-AZURE-OPENAI-ENDPOINT",
  "AzureOpenAI:Key": "YOUR-AZURE-OPENAI-KEY"
}

請將 YOUR-AZURE-OPENAI-KEY 與 YOUR-AZURE-OPENAI-ENDPOINT 替換為您實際的金鑰與端點。請確保端點 URL 的格式為 https://YOUR-DEPLOYMENT-NAME.openai.azure.com/(不要在 .openai.azure.com/ 之後加入其他路徑)。

運行應用程式

  1. 確保已設定好 Azure OpenAI 的金鑰與端點。
  2. 在 Visual Studio 或命令行中執行應用程式:
dotnet run
  1. 開啟瀏覽器並瀏覽至 https://localhost:5001。

主要功能

  • 聊天介面:與 AI 模型進行自然語言對話
  • 自訂資料搜尋:使用向量搜尋在自訂資料中查找相關內容
  • 資料擷取:支援 PDF 和 Markdown 文件的自動處理
  • 引用追蹤:聊天回應中包含資料來源的引用

技術棧

  • .NET 10:最新的 .NET 執行時環境
  • Blazor Server:伺服器端 Blazor 應用程式框架
  • Azure OpenAI:大型語言模型和嵌入式模型服務
  • SQLite Vector:向量資料儲存
  • Semantic Kernel:AI 整合框架

HsYu223/Com.Ai.Cars.Rs

C#

0

4 commits

updated Dec 4, 2025

See the code

README

AI 聊天與自訂資料

此專案示範如何使用 AI 語言模型與自訂資料進行聊天互動的應用程式。該範本目前仍處於早期預覽階段。如有回饋意見,歡迎填寫此簡短問卷: https://aka.ms/dotnet-chat-templatePreview2-survey。

[!NOTE] 在執行本專案之前,您需要為所選的提供者設定 API 金鑰或端點。下方有關於不同選項的詳細說明。

先決條件

若要使用 Azure OpenAI 或 Azure AI Search,您需要一個 Azure 帳戶。若尚未擁有帳戶,請建立一個: https://azure.microsoft.com/free/。

專案結構

此專案遵循 .NET 專案結構最佳實踐:

Com.Ai.Cars.Rs/
├── Components/           # Blazor 元件
│   ├── Layout/          # 版面配置元件
│   ├── Pages/           # 頁面元件
│   └── App.razor        # 應用程式根元件
├── Services/            # 商業邏輯與服務
│   ├── Ingestion/       # 資料擷取服務
│   ├── SemanticSearch.cs    # 語意搜尋服務
│   └── IngestedChunk.cs     # 擷取資料模型
├── wwwroot/             # 靜態資源和資料
├── Program.cs           # 應用程式進入點
└── Com.Ai.Cars.Rs.csproj   # 專案組態檔

設定 AI 模型提供者

使用 Azure OpenAI

若要使用 Azure OpenAI,您需要一個 Azure 帳戶以及一個 Azure OpenAI Service 資源。詳細說明請參閱 Azure OpenAI Service 文件: https://learn.microsoft.com/azure/ai-services/openai/how-to/create-resource。

1. 建立 Azure OpenAI Service 資源

請參閱: https://learn.microsoft.com/azure/ai-services/openai/how-to/create-resource?pivots=web-portal。

2. 部署模型

將 gpt-4o-mini 與 text-embedding-3-small 模型部署到您的 Azure OpenAI Service 資源。建立部署時,請將部署名稱設為與模型相同(gpt-4o-mini 與 text-embedding-3-small)。

欲了解如何部署模型,請參閱: https://learn.microsoft.com/azure/ai-services/openai/how-to/create-resource?pivots=web-portal#deploy-a-model。

3. 設定 API 金鑰與端點

使用 .NET User Secrets 為本專案設定 Azure OpenAI 的 API 金鑰與端點:

  1. 在 Azure 入口網站中,前往您的 Azure OpenAI 資源。
  2. 從「Keys and Endpoint」區段複製「Endpoint」網址與「Key 1」。
  3. 在 Visual Studio 中,於 Solution Explorer 對專案點選右鍵,選取 Manage User Secrets。
  4. 此操作會開啟 secrets.json 檔案,您可以在此儲存 API 金鑰與端點而不會被版本控制追蹤。將下列鍵值加入檔案:
{
  "AzureOpenAI:Endpoint": "YOUR-AZURE-OPENAI-ENDPOINT",
  "AzureOpenAI:Key": "YOUR-AZURE-OPENAI-KEY"
}

請將 YOUR-AZURE-OPENAI-KEY 與 YOUR-AZURE-OPENAI-ENDPOINT 替換為您實際的金鑰與端點。請確保端點 URL 的格式為 https://YOUR-DEPLOYMENT-NAME.openai.azure.com/(不要在 .openai.azure.com/ 之後加入其他路徑)。

運行應用程式

  1. 確保已設定好 Azure OpenAI 的金鑰與端點。
  2. 在 Visual Studio 或命令行中執行應用程式:
dotnet run
  1. 開啟瀏覽器並瀏覽至 https://localhost:5001。

主要功能

  • 聊天介面:與 AI 模型進行自然語言對話
  • 自訂資料搜尋:使用向量搜尋在自訂資料中查找相關內容
  • 資料擷取:支援 PDF 和 Markdown 文件的自動處理
  • 引用追蹤:聊天回應中包含資料來源的引用

技術棧

  • .NET 10:最新的 .NET 執行時環境
  • Blazor Server:伺服器端 Blazor 應用程式框架
  • Azure OpenAI:大型語言模型和嵌入式模型服務
  • SQLite Vector:向量資料儲存
  • Semantic Kernel:AI 整合框架

Languages

C#

41.9%

JavaScript

37.4%

HTML

14.0%

CSS

6.7%