[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-Azure-Samples--contoso-chat":3,"tool-Azure-Samples--contoso-chat":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":79,"owner_email":79,"owner_twitter":79,"owner_website":80,"owner_url":81,"languages":82,"stars":107,"forks":108,"last_commit_at":109,"license":110,"difficulty_score":10,"env_os":111,"env_gpu":112,"env_ram":113,"env_deps":114,"category_tags":127,"github_topics":128,"view_count":23,"oss_zip_url":79,"oss_zip_packed_at":79,"status":16,"created_at":140,"updated_at":141,"faqs":142,"releases":173},1257,"Azure-Samples\u002Fcontoso-chat","contoso-chat","This sample has the full End2End process of creating RAG application with Prompty and Azure AI Foundry. It includes GPT-4 LLM application code, evaluations, deployment automation with AZD CLI, GitHub actions for evaluation and deployment and intent mapping for multiple LLM task mapping.","Contoso Chat 是一个基于 Azure AI Foundry 和 Prompty 构建的零售领域智能助手示例，采用检索增强生成（RAG）技术，帮助用户通过自然语言提问获取与产品和客户数据相关的精准回答。它能够根据用户的购买历史提供个性化推荐，提升购物体验。\n\n此项目解决了传统客服系统响应不够智能、无法实时结合用户数据的问题，使企业能够快速构建具备数据驱动能力的聊天机器人，提高客户满意度和运营效率。\n\n适合希望探索 RAG 应用的开发者、AI 研究人员以及对 Azure 服务感兴趣的技术人员使用。项目包含完整的开发、评估和部署流程，并支持自动化部署和多任务意图映射，便于集成到实际业务场景中。\n\n其独特之处在于结合了 Azure 多项 AI 服务，如 Azure OpenAI、Azure 认知搜索和 Azure Cosmos DB，展示了如何在真实业务场景中实现端到端的 AI 解决方案。同时，项目提供了多种开发环境配置方式，包括 GitHub Codespaces、VS Code Dev Containers 和本地环境，方便不同需求的用户快速上手。","---\npage_type: sample\nlanguages:\n- azdeveloper\n- python\n- bash\n- bicep\n- prompty\nproducts:\n- azure\n- azure-openai\n- azure-cognitive-search\n- azure-cosmos-db\nurlFragment: contoso-chat\nname: Contoso Chat - Retail RAG Copilot with Azure AI Foundry and Prompty (Python Implementation)\ndescription: Build, evaluate, and deploy, a RAG-based retail copilot that responds to customer questions with responses grounded in the retailer's product and customer data.\n---\n\u003C!-- YAML front-matter schema: https:\u002F\u002Freview.learn.microsoft.com\u002Fen-us\u002Fhelp\u002Fcontribute\u002Fsamples\u002Fprocess\u002Fonboarding?branch=main#supported-metadata-fields-for-readmemd -->\n\n\n# Contoso Chat: Retail RAG Copilot with Azure AI Foundry and Prompty\n\n[![Open in GitHub Codespaces](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=brightgreen&logo=github)](https:\u002F\u002Fgithub.com\u002Fcodespaces\u002Fnew?hide_repo_select=true&machine=basicLinux32gb&repo=725257907&ref=main&devcontainer_path=.devcontainer%2Fdevcontainer.json&geo=UsEast)\n[![Open in Dev Containers](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https:\u002F\u002Fvscode.dev\u002Fredirect?url=vscode:\u002F\u002Fms-vscode-remote.remote-containers\u002FcloneInVolume?url=https:\u002F\u002Fgithub.com\u002Fazure-samples\u002Fcontoso-chat)\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Features](#features) · [Architecture Diagram](#architecture-diagram) \n- [Pre-Requisites](#pre-requisites)\n- [Getting Started](#getting-started) \n    - [GitHub Codespaces](#github-codespaces) \n    - [VS Code Dev Containers](#vs-code-dev-containers) \n    - [Local Environment](#local-environment) \n- [Development](#development) \n- [Testing](#testing) \n- [Deployment](#deployment)\n- [Guidance](#guidance) - [Region Availability](#region-availability) · [Costs](#costs) · [Security](#security)\n- [Workshop](#workshop) 🆕 · [Versions](#versions)\n- [Resources](#resources) · [Code of Conduct](#code-of-conduct)\n· [Responsible AI Guidelines](#responsible-ai-guidelines)\n\n\n## Important Security Notice \n\nThis template, the application code and configuration it contains, has been built to showcase Microsoft Azure specific services and tools. We strongly advise our customers not to make this code part of their production environments without implementing or enabling additional security features.  \n\nFor a more comprehensive list of best practices and security recommendations for Intelligent Applications, visit our [official documentation](https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fdeveloper\u002Fai\u002Fget-started-securing-your-ai-app).\n\n> [!WARNING]  \n>\n> **Some of the features used in this repository are in preview.** Preview versions are provided without a service level agreement, and they are not recommended for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see [Supplemental Terms of Use for Microsoft Azure Previews](https:\u002F\u002Fazure.microsoft.com\u002Fen-us\u002Fsupport\u002Flegal\u002Fpreview-supplemental-terms\u002F).\n\n**Sample application code is included in this project**. You can use or modify this app code or you can rip it out and include your own.\n\n---\n\n## Overview\n\n_Contoso Outdoor_ is an online retailer specializing in hiking and camping equipment for outdoor enthusiasts. The website offers an extensive catalog of products - resulting in customers needing product information and recommendations to assist them in making relevant purchases.\n\n![Contoso Outdoor](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FAzure-Samples_contoso-chat_readme_ef6c675d5cbd.png)\n\nThis sample implements _Contoso Chat_ - a retail copilot solution for Contoso Outdoor that uses a _retrieval augmented generation_ design pattern to ground chatbot responses in the retailer's product and customer data. Customers can ask questions from the website in natural language, and get relevant responses with potential recommendations based on their purchase history - with responsible AI practices to ensure response quality and safety.\n\n![Contoso Chat](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FAzure-Samples_contoso-chat_readme_cc25989c18aa.png)\n\nThe sample illustrates the end-to-end workflow (GenAIOps) for building a RAG-based copilot **code-first** with Azure AI and Prompty. By exploring and deploying this sample, you will learn to:\n\n1. Ideate and iterate rapidly on app prototypes using [Prompty](https:\u002F\u002Fprompty.ai)\n1. Deploy and use [Azure OpenAI](https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fai-services\u002Fopenai\u002F) models for chat, embeddings and evaluation\n1. Use Azure AI Search (indexes) and Azure CosmosDB (databases) for your data\n1. Evaluate chat responses for quality using AI-assisted evaluation flows\n1. Host the application as a FastAPI endpoint deployed to Azure Container Apps\n1. Provision and deploy the solution using the Azure Developer CLI\n1. Support Responsible AI practices with content safety & assessments\n\n\n## Features\n\nThe project template provides the following features:\n\n- [Azure OpenAI](https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fai-services\u002Fopenai\u002F) for embeddings, chat, and evaluation models\n- [Prompty](https:\u002F\u002Fprompty.ai) for creating and managing prompts for rapid iteration\n- [Azure AI Search](https:\u002F\u002Fazure.microsoft.com\u002Fproducts\u002Fai-services\u002Fai-search) for performing semantic similarity search\n- [Azure CosmosDB](https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fcosmos-db\u002F) for storing customer orders in a noSQL database \n- [Azure Container Apps](https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fcontainer-apps\u002Foverview) for hosting the chat AI endpoint on Azure\n\nIt also comes with:\n- Sample product and customer data for rapid prototyping\n- Sample application code for chat and evaluation workflows\n- Sample datasets and custom evaluators using prompty assets\n\n### Architecture Diagram \n![Architecture](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FAzure-Samples_contoso-chat_readme_562c6c60eaff.png)\n\n## Pre-requisites\n\nTo deploy and explore the sample, you will need:\n\n1. An active Azure subscription - [Signup for a free account here](https:\u002F\u002Fazure.microsoft.com\u002Ffree\u002F)\n1. An active GitHub account - [Signup for a free account here](https:\u002F\u002Fgithub.com\u002Fsignup)\n1. Access to Azure OpenAI Services - [Learn about Limited Access here](https:\u002F\u002Flearn.microsoft.com\u002Flegal\u002Fcognitive-services\u002Fopenai\u002Flimited-access)\n1. Access to Azure AI Search - [With Semantic Ranker](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fazure\u002Fsearch\u002Fsemantic-search-overview) (premium feature)\n1. Available Quota for: `text-embedding-ada-002`, `gpt-4o-mini`. and `gpt-4`\n\nWe recommend deployments to `eastus2` or `francecentral` as regions that can support all these models. In addition to the above, you will also need the ability to:\n - provision Azure Monitor (free tier)\n - provision Azure Container Apps (free tier)\n - provision Azure CosmosDB for noSQL (free tier)\n\nFrom a tooling perspective, familiarity with the following is useful:\n - Visual Studio Code (and extensions)\n - GitHub Codespaces and dev containers\n - Python and Jupyter Notebooks\n - Azure CLI, Azure Developer CLI and commandline usage\n\n## Getting Started\n\nYou have three options for setting up your development environment:\n\n1. Use GitHub Codespaces - for a prebuilt dev environment in the cloud\n1. Use Docker Desktop - for a prebuilt dev environment on local device\n1. Use Manual Setup - for control over all aspects of local env setup\n\n**We recommend going with GitHub Codespaces** for the fastest start and lowest maintenance overheads. Pick one option below - click to expand the section and view the details.\n\n### GitHub Codespaces\n\n1. You can run this template virtually by using GitHub Codespaces. Click this button to open a web-based VS Code instance in your browser:\n\n    [![Open in GitHub Codespaces](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=brightgreen&logo=github)](https:\u002F\u002Fgithub.com\u002Fcodespaces\u002Fnew?hide_repo_select=true&machine=basicLinux32gb&repo=725257907&ref=main&devcontainer_path=.devcontainer%2Fdevcontainer.json&geo=UsEast)\n\n1. Once the codespaces environment is ready (this can take several minutes), open a new terminal in that VS Code instance - and proceed to the [Development](#development) step.\n\n### VS Code Dev Containers\n\nA related option is to use VS Code Dev Containers, which will open the project in your _local Visual Studio Code editor_ using the [Dev Containers extension](https:\u002F\u002Fmarketplace.visualstudio.com\u002Fitems?itemName=ms-vscode-remote.remote-containers):\n\n1. Install [Docker Desktop](https:\u002F\u002Fwww.docker.com\u002Fproducts\u002Fdocker-desktop) (if not installed), then start it.\n1. Open the project in your local VS Code by clicking the button below:\n   \n    [![Open in Dev Containers](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https:\u002F\u002Fvscode.dev\u002Fredirect?url=vscode:\u002F\u002Fms-vscode-remote.remote-containers\u002FcloneInVolume?url=https:\u002F\u002Fgithub.com\u002Fazure-samples\u002Fcontoso-chat)\n\n1. Once the VS Code window shows the project files (this can take several minutes), open a new terminal in that VS Code instance - and proceed to the [Development](#development) step.\n\n### Local environment\n\n1. **Install the required tools** in your local device:\n    - [Azure Developer CLI (azd)](https:\u002F\u002Faka.ms\u002Finstall-azd)\n    - [Python 3.10+](https:\u002F\u002Fwww.python.org\u002Fdownloads\u002F)\n    - [Docker Desktop](https:\u002F\u002Fwww.docker.com\u002Fproducts\u002Fdocker-desktop\u002F)\n    - [Git](https:\u002F\u002Fgit-scm.com\u002Fdownloads)\n\n    **Note for Windows users:** If you are _not_ using a container to run this sample, note that our post-provisioning hooks make use of shell scripts. While we update scripts for different local device environments, we recommend using [git bash](https:\u002F\u002Fgitforwindows.org\u002F) to run samples correctly.\n\n1. **Initialize the project** in your local device:\n    - Create a new folder `contoso-chat` and `cd` into it\n    - Run this command to download project template. Note that this command will initialize a git repository, so you do not need to clone this repository.\n        ```bash\n        azd init -t contoso-chat\n        ```\n1. **Install dependencies** for the project, manually. Note that this is done for you automatically if you use the dev container options above.\n    ```bash\n        cd src\u002Fapi\n        pip install -r requirements.txt\n    ```\n\nYou can now proceed to the next step - [Development](#development) - where we will provision the required Azure infrastructure and deploy the application from the template using `azd`.\n\n\n## Development\n\nOnce you've completed the setup the project (using [Codespaces](#github-codespaces), [Dev Containers](#vs-code-dev-containers), or [local environment](#local-environment)) you should now have a Visual Studio Code editor open, with the project files loaded, and a terminal open for running commands. Let's verify that all required tools are installed.\n\n```bash\naz version\nazd version\nprompty --version\npython --version\n```\n\nWe can now proceed with next steps - click to expand for detailed instructions.\n\n\u003Cdetails>\n\u003Csummary> 1️⃣ | Authenticate With Azure \u003C\u002Fsummary>\n\n1. Open a VS Code terminal and authenticate with Azure CLI. Use the `--use-device-code` option if authenticating from GitHub Codespaces. Complete the auth workflow as guided.\n\n    ```bash\n    az login --use-device-code\n    ```\n1. Now authenticate with Azure Developer CLI in the same terminal. Complete the auth workflow as guided. \n\n    ```bash\n    azd auth login --use-device-code\n    ```\n1. You should see: **Logged in on Azure.** This will create a folder under `.azure\u002F` in your project to store the configuration for this deployment. You may have multiple azd environments if desired.\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary> 2️⃣ |  Provision-Deploy with AZD \u003C\u002Fsummary>\n\n1. Run `azd up` to provision infrastructure _and_ deploy the application, with one command. (You can also use `azd provision`, `azd deploy` separately if needed)\n\n    ```bash\n    azd up\n    ```\n1. You will be asked for  a _subscription_ for provisioning resources, an _environment name_ that maps to the resource group, and a _location_ for deployment. Refer to the [Region Availability](#region-availability) guidance to select the region that has the desired models and quota available.\n1. The `azd up` command can take 15-20 minutes to complete. Successful completion sees a **`SUCCESS: ...`** messages posted to the console. We can now validate the outcomes.\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary> 3️⃣ | Validate the Infrastructure \u003C\u002Fsummary>\n\n1. Visit the [Azure Portal](https:\u002F\u002Fportal.azure.com) - look for the `rg-ENVNAME` resource group created above\n1. Click the `Deployments` link in the **Essentials** section - wait till all are completed.\n1. Return to `Overview` page - you should see: **35** deployments, **15** resources\n1. Click on the `Azure CosmosDB resource` in the list\n    - Visit the resource detail page - click \"Data Explorer\"\n    - Verify that it has created a `customers` database with data items in it\n1. Click on the `Azure AI Search` resource in the list\n    - Visit the resource detail page - click \"Search Explorer\"\n    - Verify that it has created a `contoso-products` index with data items in it\n1. Click on the `Azure Container Apps` resource in the list\n    - Visit the resource detail page - click `Application Url`\n    - Verify that you see a hosted endpoint with a `Hello World` message on page\n1. Next, visit the [Azure AI Foundry](https:\u002F\u002Fai.azure.com) portal\n    - Sign in - you should be auto-logged in with existing Azure credential\n    - Click on `All Resources` - you should see an `AIServices` and `Hub` resources\n    - Click the hub resource - you should see an `AI Project` resource listed\n    - Click the project resource - look at Deployments page to verify models\n1. ✅ | **Congratulations!** - Your Azure project infrastructure is ready!\n\u003C\u002Fdetails>\n\n\n\u003Cdetails>\n\u003Csummary> 4️⃣ | Validate the Deployment \u003C\u002Fsummary>\n\n1. The `azd up` process also deploys the application as an Azure Container App\n1. Visit the ACA resource page - click on `Application Url` to view endpoint\n1. Add a `\u002Fdocs` suffix to default deployed path - to get a Swagger API test page\n1. Click `Try it out` to unlock inputs - you see `question`, `customer_id`, `chat_history`\n    - Enter `question` = \"Tell me about the waterproof tents\"\n    - Enter `customer_id` = 2\n    - Enter `chat_history` = []\n    - Click **Execute** to see results: _You should see a valid response with a list of matching tents from the product catalog with additional details_.\n1. ✅ | **Congratulations!** - Your Chat AI Deployment is working! \n\n\u003C\u002Fdetails>\n\n## Testing\n\nWe can think about two levels of testing - _manual_ validation and _automated_ evaluation. The first is interactive, using a single test prompt to validate the prototype as we iterate. The second is code-driven, using a test prompt dataset to assess quality and safety of prototype responses for a diverse set of prompt inputs - and score them for criteria like _coherence_, _fluency_, _relevance_ and _groundedness_ based on built-in or custom evaluators.\n\n\u003Cdetails>\n\u003Csummary> 1️⃣ | Manual Testing (interactive) \u003C\u002Fsummary>\n\u003Cbr\u002F>\n\nThe Contoso Chat application is implemented as a _FastAPI_ application that can be deployed to a hosted endpoint in Azure Container Apps. The API implementation is defined in `src\u002Fapi\u002Fmain.py` and currently exposes 2 routes:\n - `\u002F` - which shows the default \"Hello World\" message\n - `\u002Fapi\u002Fcreate_request` - which is our chat AI endpoint for test prompts\n\nTo test locally, we run the FastAPI dev server, then use the Swagger endpoint at the `\u002Fdocs` route to test the locally-served endpoint in the same way we tested the deployed version\u002F\n\n- Change to the root folder of the repository\n- Run `fastapi dev .\u002Fsrc\u002Fapi\u002Fmain.py` - it should launch a dev server\n- Click `Open in browser` to preview the dev server page in a new tab\n    - You should see: \"Hello, World\" with route at `\u002F`\n- Add `\u002Fdocs` to the end of the path URL in the browser tab\n    - You should see: \"FASTAPI\" page with 2 routes listed\n    - Click the `POST` route then click `Try it out` to unlock inputs\n- Try a test input\n    - Enter `question` = \"Tell me about the waterproof tents\"\n    - Enter `customer_id` = 2\n    - Enter `chat_history` = []\n    - Click **Execute** to see results: _You should see a valid response with a list of matching tents from the product catalog with additional details_.\n1. ✅ | **Congratulations!** - You successfully tested the app locally\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary> 2️⃣ | AI-Assisted Evaluation (code-driven) \u003C\u002Fsummary>\n\u003Cbr\u002F>\n\nTesting a single prompt is good for rapid prototyping and ideation. But once we have our application designed, we want to validate the _quality and safety_ of responses against diverse test prompts. The sample shows you how to do **AI-Assisted Evaluation** using custom evaluators implemented with Prompty.\n\n- Visit the `src\u002Fapi\u002Fevaluators\u002F` folder\n- Open the `evaluate-chat-flow.ipynb` notebook - \"Select Kernel\" to activate\n- Clear inputs and then `Run all` - starts evaluaton flow with `data.jsonl` test dataset\n- Once evaluation completes (takes 10+ minutes), you should see\n    - `results.jsonl` = the chat model's responses to test inputs\n    - `evaluated_results.jsonl` = the evaluation model's scoring of the responses\n    - tabular results = coherence, fluency, relevance, groundedness scores\n\nWant to get a better understanding of how custom evaluators work? Check out the `src\u002Fapi\u002Fevaluators\u002Fcustom_evals` folder and explore the relevant Prompty assets and their template instructions.\n\nThe Prompty tooling also has support for built-in _tracing_ for observability. Look for a `.runs\u002F` subfolder to be created during the evaluation run, with `.tracy` files containing the trace data. Click one of them to get a _trace-view_ display in Visual Studio Code to help you drill down or debug the interaction flow. _This is a new feature so look for more updates in usage soon_.\n\n\u003C\u002Fdetails>\n\n## Deployment\n\nThe solution is deployed using the Azure Developer CLI. The `azd up` command effectively calls `azd provision` and then `azd deploy` - allowing you to provision infrastructure and deploy the application with a single command. Subsequent calls to `azd up` (e.g., ,after making changes to the application) should be faster, re-deploying the application and updating infrastructure provisioning only if required. You can then test the deployed endpoint as described earlier.\n\n## Guidance\n\n### Region Availability\n\nThis template currently uses the following models: `gpt35-turbo`, `gpt-4` and `text-embedding-ada-002`, which may not be available in all Azure regions, or may lack sufficient quota for your subscription in supported regions. Check for [up-to-date region availability](https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fai-services\u002Fopenai\u002Fconcepts\u002Fmodels#standard-deployment-model-availability) and select a region during deployment accordingly\n\n**We recommend using `francecentral`**\n\n### Costs\n\nPricing for services may vary by region and usage and exact costs are hard to determine. You can _estimate_ the cost of this project's architecture with [Azure's pricing calculator](https:\u002F\u002Fazure.microsoft.com\u002Fpricing\u002Fcalculator\u002F) with these services:\n\n- Azure OpenAI - Standard tier, gpt-4, gpt-4o-mini and text-embedding-ada-002 models. [See Pricing](https:\u002F\u002Fazure.microsoft.com\u002Fpricing\u002Fdetails\u002Fcognitive-services\u002Fopenai-service\u002F)\n- Azure AI Search - Basic tier, Semantic Ranker enabled. [See Pricing](https:\u002F\u002Fazure.microsoft.com\u002Fen-us\u002Fpricing\u002Fdetails\u002Fsearch\u002F)\n- Azure Cosmos DB for NoSQL - Serverless, Free Tier. [See Pricing](https:\u002F\u002Fazure.microsoft.com\u002Fen-us\u002Fpricing\u002Fdetails\u002Fcosmos-db\u002Fautoscale-provisioned\u002F#pricing)\n- Azure Monitor - Serverless, Free Tier. [See Pricing](https:\u002F\u002Fazure.microsoft.com\u002Fen-us\u002Fpricing\u002Fdetails\u002Fmonitor\u002F)\n- Azure Container Apps - Severless, Free Tier. [See Pricing](https:\u002F\u002Fazure.microsoft.com\u002Fen-us\u002Fpricing\u002Fdetails\u002Fcontainer-apps\u002F)\n\n\n### Security\n\nThis template uses [Managed Identity](https:\u002F\u002Flearn.microsoft.com\u002Fentra\u002Fidentity\u002Fmanaged-identities-azure-resources\u002Foverview) for authentication with key Azure services including Azure OpenAI, Azure AI Search, and Azure Cosmos DB. Applications can use managed identities to obtain Microsoft Entra tokens without having to manage any credentials. This also removes the need for developers to manage these credentials themselves and reduces their complexity.\n\nAdditionally, we have added a [GitHub Action tool](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsecurity-devops-action) that scans the infrastructure-as-code files and generates a report containing any detected issues. To ensure best practices we recommend anyone creating solutions based on our templates ensure that the [Github secret scanning](https:\u002F\u002Fdocs.github.com\u002Fcode-security\u002Fsecret-scanning\u002Fabout-secret-scanning) setting is enabled in your repo.\n\n## Workshop \n\nThe sample has a `docs\u002Fworkshop` folder with step-by-step guidance for developers, to help you deconstruct the codebase, and understand how to to provision, ideate, build, evaluate, and deploy, the application yourself, with your own data. \n - The workshop may be offered as an _instructor-guided option_ (e.g., on [Microsoft AI Tour](https:\u002F\u002Faitour.microsoft.com))\n - The workshop can be completed at home as a **self-paced lab** with your own subscription.\n\n### Lab Guide\n\n1. [View Workshop Online](https:\u002F\u002Faka.ms\u002Faitour\u002Fcontoso-chat\u002Fworkshop) - view a pre-built workshop version in your browser\n1. **View Workshop Locally** - The workshop is built using Mkdocs. To preview it locally, \n    - install mkdocs: `pip install mkdocs-material`\n    - switch to folder: `cd docs\u002Fworkshop`\n    - launch preview: `mkdocs serve` \n    - open browser to the preview URL specified\n\nHave issues or questions about the workshop? Submit [a new issue](https:\u002F\u002Fgithub.com\u002FAzure-Samples\u002Fcontoso-chat\u002Fissues\u002Fnew) with a `documentation` tag.\n\n\n## Resources\n\n1. [Prompty Documentation](https:\u002F\u002Fprompty.ai)\n1. [Azure AI Foundry Documentation](https:\u002F\u002Faka.ms\u002Faistudio)\n1. [Develop AI Apps using Azure AI Services](https:\u002F\u002Faka.ms\u002Fai-apps-docs)\n1. [Azure AI Templates with Azure Developer CLI](https:\u002F\u002Faka.ms\u002Fai-studio\u002Fazd-templates)\n\n\n## Code of Conduct\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002F). Learn more here:\n\n- [Microsoft Open Source Code of Conduct](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002F)\n- [Microsoft Code of Conduct FAQ](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002Ffaq\u002F)\n- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns\n\nFor more information see the [Code of Conduct FAQ](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002Ffaq\u002F) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n\n## Responsible AI Guidelines\n\nThis project follows below responsible AI guidelines and best practices, please review them before using this project:\n\n- [Microsoft Responsible AI Guidelines](https:\u002F\u002Fwww.microsoft.com\u002Fen-us\u002Fai\u002Fresponsible-ai)\n- [Responsible AI practices for Azure OpenAI models](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Flegal\u002Fcognitive-services\u002Fopenai\u002Foverview)\n- [Safety evaluations transparency notes](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fazure\u002Fai-studio\u002Fconcepts\u002Fsafety-evaluations-transparency-note)\n\n---\n\n\n\n\n","---\npage_type: sample\nlanguages:\n- azdeveloper\n- python\n- bash\n- bicep\n- prompty\nproducts:\n- azure\n- azure-openai\n- azure-cognitive-search\n- azure-cosmos-db\nurlFragment: contoso-chat\nname: Contoso Chat - 基于 Azure AI Foundry 和 Prompty 的零售 RAG Copilot（Python 实现）\ndescription: 构建、评估并部署一个基于 RAG 的零售 Copilot，该 Copilot 能够根据零售商的产品和客户数据生成有据可依的回复，以回答客户的提问。\n---\n\u003C!-- YAML front-matter schema: https:\u002F\u002Freview.learn.microsoft.com\u002Fen-us\u002Fhelp\u002Fcontribute\u002Fsamples\u002Fprocess\u002Fonboarding?branch=main#supported-metadata-fields-for-readmemd -->\n\n\n# Contoso Chat：基于 Azure AI Foundry 和 Prompty 的零售 RAG Copilot\n\n[![在 GitHub Codespaces 中打开](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=brightgreen&logo=github)](https:\u002F\u002Fgithub.com\u002Fcodespaces\u002Fnew?hide_repo_select=true&machine=basicLinux32gb&repo=725257907&ref=main&devcontainer_path=.devcontainer%2Fdevcontainer.json&geo=UsEast)\n[![在 Dev Containers 中打开](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https:\u002F\u002Fvscode.dev\u002Fredirect?url=vscode:\u002F\u002Fms-vscode-remote.remote-containers\u002FcloneInVolume?url=https:\u002F\u002Fgithub.com\u002Fazure-samples\u002Fcontoso-chat)\n\n## 目录\n\n- [概述](#overview)\n- [功能](#features) · [架构图](#architecture-diagram) \n- [先决条件](#pre-requisites)\n- [入门](#getting-started) \n    - [GitHub Codespaces](#github-codespaces) \n    - [VS Code Dev Containers](#vs-code-dev-containers) \n    - [本地环境](#local-environment) \n- [开发](#development) \n- [测试](#testing) \n- [部署](#deployment)\n- [指导](#guidance) - [区域可用性](#region-availability) · [成本](#costs) · [安全性](#security)\n- [研讨会](#workshop) 🆕 · [版本](#versions)\n- [资源](#resources) · [行为准则](#code-of-conduct)\n· [负责任的 AI 指南](#responsible-ai-guidelines)\n\n\n## 重要安全提示 \n\n本模板及其包含的应用程序代码和配置旨在展示 Microsoft Azure 的特定服务和工具。我们强烈建议客户在未实施或启用额外的安全功能之前，不要将此代码用于生产环境。\n\n如需了解有关智能应用程序的更全面的最佳实践和安全建议，请访问我们的[官方文档](https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fdeveloper\u002Fai\u002Fget-started-securing-your-ai-app)。\n\n> 【警告】  \n>\n> **本仓库中使用的部分功能处于预览阶段。** 预览版不提供服务级别协议，也不建议用于生产工作负载。某些功能可能不受支持或功能受限。更多信息请参阅[Microsoft Azure 预览版的补充使用条款](https:\u002F\u002Fazure.microsoft.com\u002Fen-us\u002Fsupport\u002Flegal\u002Fpreview-supplemental-terms\u002F)。\n\n**本项目中包含示例应用程序代码**。您可以使用或修改此应用代码，也可以将其移除并替换为自己的代码。\n\n---\n\n## 概述\n\n_Contoso Outdoor_ 是一家专注于户外爱好者的徒步与露营装备的在线零售商。其网站提供海量产品目录，因此客户需要产品信息和推荐来帮助他们做出合适的购买决策。\n\n![Contoso Outdoor](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FAzure-Samples_contoso-chat_readme_ef6c675d5cbd.png)\n\n本示例实现了 _Contoso Chat_——一款专为 Contoso Outdoor 打造的零售 Copilot 解决方案，采用“检索增强生成”设计模式，使聊天机器人的回复能够基于零售商的产品和客户数据。客户可以在网站上用自然语言提出问题，并获得与自身购买历史相关的回复及潜在推荐——同时遵循负责任的 AI 实践，确保回复的质量与安全性。\n\n![Contoso Chat](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FAzure-Samples_contoso-chat_readme_cc25989c18aa.png)\n\n本示例展示了使用 Azure AI 和 Prompty 以“代码优先”方式构建 RAG 基础 Copilot 的端到端工作流（GenAIOps）。通过探索并部署本示例，您将学会：\n\n1. 使用 [Prompty](https:\u002F\u002Fprompty.ai) 快速构思并迭代应用程序原型\n1. 部署并使用 [Azure OpenAI](https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fai-services\u002Fopenai\u002F) 模型进行聊天、嵌入和评估\n1. 使用 Azure AI Search（索引）和 Azure CosmosDB（数据库）存储您的数据\n1. 利用 AI 辅助的评估流程对聊天回复质量进行评估\n1. 将应用程序作为 FastAPI 端点托管在 Azure Container Apps 上\n1. 使用 Azure Developer CLI 配置并部署解决方案\n1. 通过内容安全与评估支持负责任的 AI 实践\n\n\n## 功能\n\n该项目模板提供以下功能：\n\n- [Azure OpenAI](https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fai-services\u002Fopenai\u002F) 用于嵌入、聊天和评估模型\n- [Prompty](https:\u002F\u002Fprompty.ai) 用于创建和管理提示，以实现快速迭代\n- [Azure AI Search](https:\u002F\u002Fazure.microsoft.com\u002Fproducts\u002Fai-services\u002Fai-search) 用于执行语义相似度搜索\n- [Azure CosmosDB](https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fcosmos-db\u002F) 用于在 NoSQL 数据库中存储客户订单\n- [Azure Container Apps](https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fcontainer-apps\u002Foverview) 用于在 Azure 上托管聊天 AI 端点\n\n此外，还附带：\n- 用于快速原型设计的示例产品和客户数据\n- 用于聊天和评估工作流的示例应用程序代码\n- 使用 Prompty 资产的示例数据集和自定义评估器\n\n### 架构图 \n![架构](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FAzure-Samples_contoso-chat_readme_562c6c60eaff.png)\n\n## 先决条件\n\n要部署并探索本示例，您需要：\n\n1. 有效的 Azure 订阅——[在此注册免费账户](https:\u002F\u002Fazure.microsoft.com\u002Ffree\u002F)\n1. 有效的 GitHub 账户——[在此注册免费账户](https:\u002F\u002Fgithub.com\u002Fsignup)\n1. 对 Azure OpenAI 服务的访问权限——[了解有限访问权限](https:\u002F\u002Flearn.microsoft.com\u002Flegal\u002Fcognitive-services\u002Fopenai\u002Flimited-access)\n1. 对 Azure AI Search 的访问权限——[使用语义排名器](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fazure\u002Fsearch\u002Fsemantic-search-overview)（高级功能）\n1. 可用配额：`text-embedding-ada-002`、`gpt-4o-mini` 和 `gpt-4`\n\n我们建议将部署区域选择为 `eastus2` 或 `francecentral`，因为这些区域可以支持所有上述模型。除此之外，您还需要具备以下能力：\n - 配置 Azure Monitor（免费层）\n - 配置 Azure Container Apps（免费层）\n - 配置 Azure CosmosDB 用于 NoSQL（免费层）\n\n从工具使用角度来看，熟悉以下内容会很有帮助：\n - Visual Studio Code（以及相关扩展）\n - GitHub Codespaces 和开发容器\n - Python 和 Jupyter Notebook\n - Azure CLI、Azure Developer CLI 以及命令行操作\n\n## 入门指南\n\n您有三种方式来搭建开发环境：\n\n1. 使用 GitHub Codespaces——在云端预置的开发环境\n2. 使用 Docker Desktop——在本地设备上预置的开发环境\n3. 手动搭建——可完全掌控本地环境的各个配置细节\n\n**我们建议选择 GitHub Codespaces**，因为它启动最快、维护开销最低。请从下方选择一种方式——点击以展开相应部分并查看详细信息。\n\n### GitHub Codespaces\n\n1. 您可以通过 GitHub Codespaces 虚拟运行此模板。点击此按钮即可在浏览器中打开一个基于 Web 的 VS Code 实例：\n\n    [![在 GitHub Codespaces 中打开](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=brightgreen&logo=github)](https:\u002F\u002Fgithub.com\u002Fcodespaces\u002Fnew?hide_repo_select=true&machine=basicLinux32gb&repo=725257907&ref=main&devcontainer_path=.devcontainer%2Fdevcontainer.json&geo=UsEast)\n\n1. 等待 Codespaces 环境准备就绪（可能需要几分钟），然后在该 VS Code 实例中打开一个新的终端——接着进入[开发](#development)步骤。\n\n### VS Code 开发容器\n\n另一种相关选项是使用 VS Code 开发容器，它会通过 [Dev Containers 扩展](https:\u002F\u002Fmarketplace.visualstudio.com\u002Fitems?itemName=ms-vscode-remote.remote-containers) 在您的_本地 Visual Studio Code 编辑器_中打开项目：\n\n1. 如果尚未安装，请先安装 [Docker Desktop](https:\u002F\u002Fwww.docker.com\u002Fproducts\u002Fdocker-desktop)，然后启动它。\n1. 点击下方按钮，在本地 VS Code 中打开项目：\n\n    [![在 Dev Containers 中打开](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https:\u002F\u002Fvscode.dev\u002Fredirect?url=vscode:\u002F\u002Fms-vscode-remote.remote-containers\u002FcloneInVolume?url=https:\u002F\u002Fgithub.com\u002Fazure-samples\u002Fcontoso-chat)\n\n1. 等待 VS Code 窗口显示项目文件（可能需要几分钟），然后在该 VS Code 实例中打开一个新的终端——接着进入[开发](#development)步骤。\n\n### 本地环境\n\n1. **在本地设备上安装所需工具**：\n    - [Azure Developer CLI (azd)](https:\u002F\u002Faka.ms\u002Finstall-azd)\n    - [Python 3.10+](https:\u002F\u002Fwww.python.org\u002Fdownloads\u002F)\n    - [Docker Desktop](https:\u002F\u002Fwww.docker.com\u002Fproducts\u002Fdocker-desktop\u002F)\n    - [Git](https:\u002F\u002Fgit-scm.com\u002Fdownloads)\n\n    **Windows 用户请注意：** 如果您_不使用容器来运行此示例_，请注意我们的部署后钩子会使用 Shell 脚本。尽管我们会针对不同的本地设备环境更新脚本，但我们仍建议使用 [git bash](https:\u002F\u002Fgitforwindows.org\u002F) 来正确运行示例。\n\n1. **在本地设备上初始化项目**：\n    - 创建一个新文件夹 `contoso-chat` 并切换到该目录\n    - 运行以下命令下载项目模板。请注意，此命令会初始化一个 Git 仓库，因此您无需再克隆该仓库。\n        ```bash\n        azd init -t contoso-chat\n        ```\n1. **手动安装项目依赖**。如果您使用上述开发容器选项，则此步骤将自动为您完成。\n    ```bash\n        cd src\u002Fapi\n        pip install -r requirements.txt\n    ```\n\n现在您可以进入下一步——[开发](#development)——我们将在此步骤中预配所需的 Azure 基础设施，并使用 `azd` 从模板部署应用程序。\n\n## 开发\n\n在完成项目的设置后（可通过 [Codespaces](#github-codespaces)、[Dev Containers](#vs-code-dev-containers) 或 [本地环境](#local-environment) 实现），您应该已打开 Visual Studio Code 编辑器，项目文件已加载，并且打开了一个用于运行命令的终端。现在让我们验证所有必需的工具是否已安装。\n\n```bash\naz version\nazd version\nprompty --version\npython --version\n```\n\n接下来我们可以继续执行后续步骤——点击展开以查看详细说明。\n\n\u003Cdetails>\n\u003Csummary> 1️⃣ | 使用 Azure 进行身份验证 \u003C\u002Fsummary>\n\n1. 打开 VS Code 终端并使用 Azure CLI 进行身份验证。如果从 GitHub Codespaces 进行身份验证，请使用 `--use-device-code` 选项。按照提示完成身份验证流程。\n\n    ```bash\n    az login --use-device-code\n    ```\n1. 现在在同一终端中使用 Azure Developer CLI 进行身份验证。按照提示完成身份验证流程。\n\n    ```bash\n    azd auth login --use-device-code\n    ```\n1. 您应该会看到：**已登录 Azure。** 这将在您的项目目录下的 `.azure\u002F` 文件夹中创建一个用于存储此次部署配置的文件夹。如果您需要，还可以创建多个 azd 环境。\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary> 2️⃣ | 使用 AZD 预配并部署 \u003C\u002Fsummary>\n\n1. 运行 `azd up` 命令，即可通过一条命令同时完成基础设施的预配与应用程序的部署。（如有需要，您也可以分别使用 `azd provision` 和 `azd deploy`）\n\n    ```bash\n    azd up\n    ```\n1. 系统将提示您选择用于预配资源的_订阅_、映射到资源组的_环境名称_以及部署的_位置_。请参考【区域可用性】指南，选择具有所需模型和配额的区域。\n1. `azd up` 命令可能需要 15–20 分钟才能完成。成功完成后，控制台将显示 **`SUCCESS: ...`** 的消息。现在我们可以验证部署结果。\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary> 3️⃣ | 验证基础设施 \u003C\u002Fsummary>\n\n1. 访问 [Azure 门户](https:\u002F\u002Fportal.azure.com)，查找上面创建的 `rg-ENVNAME` 资源组。\n1. 在“基本”部分中单击“部署”链接，等待所有部署完成。\n1. 返回“概览”页面，您应该会看到：**35** 个部署，**15** 个资源。\n1. 在列表中单击“Azure CosmosDB 资源”。\n    - 进入该资源的详细信息页面，单击“数据资源管理器”。\n    - 确认已创建名为“customers”的数据库，并且其中包含数据条目。\n1. 在列表中单击“Azure AI Search 资源”。\n    - 进入该资源的详细信息页面，单击“搜索资源管理器”。\n    - 确认已创建名为“contoso-products”的索引，并且其中包含数据条目。\n1. 在列表中单击“Azure 容器应用”资源。\n    - 进入该资源的详细信息页面，单击“应用程序 URL”。\n    - 确认您看到一个托管的端点，页面上显示“Hello World”消息。\n1. 接下来，访问 [Azure AI Foundry](https:\u002F\u002Fai.azure.com) 门户。\n    - 登录——系统应自动使用您现有的 Azure 凭据登录。\n    - 单击“所有资源”，您应该会看到“AIServices”和“Hub”资源。\n    - 单击 Hub 资源，您应该会看到列出的“AI Project”资源。\n    - 单击该项目资源，进入“部署”页面以验证模型。\n1. ✅ | **恭喜！** 您的 Azure 项目基础设施已准备就绪！\n\u003C\u002Fdetails>\n\n\n\u003Cdetails>\n\u003Csummary> 4️⃣ | 验证部署 \u003C\u002Fsummary>\n\n1. `azd up` 过程还会将应用程序部署为 Azure 容器应用。\n1. 进入 ACA 资源页面，单击“应用程序 URL”以查看端点。\n1. 在默认部署路径后添加 `\u002Fdocs` 后缀，以访问 Swagger API 测试页面。\n1. 单击“试用”以解锁输入字段——您会看到“question”、“customer_id”、“chat_history”。\n    - 输入“question” = “告诉我关于防水帐篷的信息”\n    - 输入“customer_id” = 2\n    - 输入“chat_history” = []\n    - 单击“执行”以查看结果：_您应该会看到一个有效的响应，其中包含产品目录中匹配的帐篷列表及更多详细信息_。\n1. ✅ | **恭喜！** 您的聊天 AI 部署已正常运行！ \n\n\u003C\u002Fdetails>\n\n## 测试\n\n我们可以从两个层面来考虑测试：_手动_验证和_自动化_评估。前者是交互式的，通过单个测试提示在迭代过程中对原型进行验证；后者则是基于代码的，利用测试提示数据集来评估原型响应在多种不同提示输入下的质量和安全性，并根据内置或自定义的评估器，针对_连贯性_、_流畅性_、_相关性_和_事实依据_等指标进行打分。\n\n\u003Cdetails>\n\u003Csummary> 1️⃣ | 手动测试（交互式） \u003C\u002Fsummary>\n\u003Cbr\u002F>\n\nContoso Chat 应用程序以 _FastAPI_ 应用的形式实现，可部署到 Azure Container Apps 中的托管端点。API 实现位于 `src\u002Fapi\u002Fmain.py` 文件中，目前公开了两条路由：\n- `\u002F` —— 显示默认的“Hello World”消息\n- `\u002Fapi\u002Fcreate_request` —— 这是我们用于测试提示的聊天 AI 端点\n\n要在本地进行测试，我们先运行 FastAPI 开发服务器，然后通过 `\u002Fdocs` 路由上的 Swagger 端点，以与测试已部署版本相同的方式测试本地提供的端点。\n\n- 切换到仓库的根文件夹\n- 运行 `fastapi dev .\u002Fsrc\u002Fapi\u002Fmain.py` —— 应该会启动一个开发服务器\n- 点击“在浏览器中打开”，在新标签页中预览开发服务器页面\n    - 您应该会看到：“Hello, World”，路径为 `\u002F`\n- 在浏览器标签页的路径 URL 后加上 `\u002Fdocs`\n    - 您应该会看到：“FASTAPI”页面，列出两条路由\n    - 点击 `POST` 路由，再点击“试用”以解锁输入\n- 输入一个测试提示\n    - 输入 `question` = “告诉我关于防水帐篷的信息”\n    - 输入 `customer_id` = 2\n    - 输入 `chat_history` = []\n    - 点击**执行**查看结果：_您应该会看到一条有效的响应，其中包含产品目录中匹配的帐篷列表及更多详细信息_。\n1. ✅ | **恭喜！** —— 您已成功在本地测试了该应用\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary> 2️⃣ | AI 辅助评估（基于代码） \u003C\u002Fsummary>\n\u003Cbr\u002F>\n\n仅测试一个提示有助于快速原型设计和创意构思。但一旦我们的应用程序设计完成，我们就希望针对多样化的测试提示，对响应的_质量和安全性_进行验证。本示例展示了如何使用 Prompty 实现的自定义评估器来进行**AI 辅助评估**。\n\n- 访问 `src\u002Fapi\u002Fevaluators\u002F` 文件夹\n- 打开 `evaluate-chat-flow.ipynb` 笔记本——选择“内核”以激活\n- 清空输入后，点击“全部运行”——将启动使用 `data.jsonl` 测试数据集的评估流程\n- 评估完成后（需时 10 分钟以上），您应该会看到：\n    - `results.jsonl` —— 聊天模型对测试输入的响应\n    - `evaluated_results.jsonl` —— 评估模型对这些响应的评分\n    - 表格形式的结果——包括连贯性、流畅性、相关性、事实依据等得分\n\n想更深入地了解自定义评估器的工作原理吗？请查看 `src\u002Fapi\u002Fevaluators\u002Fcustom_evals` 文件夹，探索相关的 Prompty 资源及其模板说明。\n\nPrompty 工具还支持内置的_追踪_功能，以提升可观测性。在评估运行期间，会生成一个 `.runs\u002F` 子文件夹，其中包含 `.tracy` 文件，记录了追踪数据。点击其中一个文件，即可在 Visual Studio Code 中查看_追踪视图_，帮助您深入分析或调试交互流程。_这是一项新功能，敬请期待后续使用指南的更新_。\n\n\u003C\u002Fdetails>\n\n## 部署\n\n该解决方案使用 Azure Developer CLI 进行部署。`azd up` 命令实际上会依次调用 `azd provision` 和 `azd deploy`——让您只需一条命令即可完成基础设施的配置与应用程序的部署。之后再次运行 `azd up`（例如，在对应用程序进行修改后），应会更加迅速，仅在确有需要时才会重新部署应用程序并更新基础设施配置。随后，您可以按照前面所述的方式测试已部署的端点。\n\n## 指导\n\n### 区域可用性\n\n本模板目前使用以下模型：`gpt35-turbo`、`gpt-4` 和 `text-embedding-ada-002`，这些模型可能并非在所有 Azure 区域都可用，或者在受支持的区域中您的订阅可能没有足够的配额。请查阅[最新的区域可用性信息](https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fai-services\u002Fopenai\u002Fconcepts\u002Fmodels#standard-deployment-model-availability)，并在部署时相应地选择区域。\n\n**我们建议使用 `francecentral`**\n\n### 成本\n\n各项服务的定价可能因区域和使用情况而异，具体费用难以准确估算。您可以通过 [Azure 定价计算器](https:\u002F\u002Fazure.microsoft.com\u002Fpricing\u002Fcalculator\u002F)，结合以下服务，对本项目的架构成本进行_估算_：\n\n- Azure OpenAI — 标准层，使用 gpt-4、gpt-4o-mini 和 text-embedding-ada-002 模型。[参见定价](https:\u002F\u002Fazure.microsoft.com\u002Fpricing\u002Fdetails\u002Fcognitive-services\u002Fopenai-service\u002F)\n- Azure AI Search — 基础层，启用语义排名器。[参见定价](https:\u002F\u002Fazure.microsoft.com\u002Fen-us\u002Fpricing\u002Fdetails\u002Fsearch\u002F)\n- Azure Cosmos DB for NoSQL — 无服务器，免费层。[参见定价](https:\u002F\u002Fazure.microsoft.com\u002Fen-us\u002Fpricing\u002Fdetails\u002Fcosmos-db\u002Fautoscale-provisioned\u002F#pricing)\n- Azure Monitor — 无服务器，免费层。[参见定价](https:\u002F\u002Fazure.microsoft.com\u002Fen-us\u002Fpricing\u002Fdetails\u002Fmonitor\u002F)\n- Azure Container Apps — 无服务器，免费层。[参见定价](https:\u002F\u002Fazure.microsoft.com\u002Fen-us\u002Fpricing\u002Fdetails\u002Fcontainer-apps\u002F)\n\n\n### 安全性\n\n本模板使用[托管身份](https:\u002F\u002Flearn.microsoft.com\u002Fentra\u002Fidentity\u002Fmanaged-identities-azure-resources\u002Foverview)来认证关键 Azure 服务，包括 Azure OpenAI、Azure AI Search 和 Azure Cosmos DB。应用程序可通过托管身份获取 Microsoft Entra 令牌，而无需管理任何凭据。这不仅免去了开发者自行管理这些凭据的麻烦，也降低了操作复杂度。\n\n此外，我们还添加了一个[GitHub Action 工具](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsecurity-devops-action)，用于扫描基础设施即代码文件，并生成一份包含所有检测到问题的报告。为确保最佳实践，我们建议所有基于我们的模板创建解决方案的人员，务必在您的仓库中启用[Github 秘密扫描](https:\u002F\u002Fdocs.github.com\u002Fcode-security\u002Fsecret-scanning\u002Fabout-secret-scanning)设置。\n\n## 研讨会\n\n本示例提供了一个 `docs\u002Fworkshop` 文件夹，其中包含面向开发者的分步指导，帮助您拆解代码库，理解如何自行配置、构思、构建、评估和部署应用程序，并使用您自己的数据。\n- 研讨会可以作为_讲师引导的选项_提供（例如，在[Microsoft AI Tour](https:\u002F\u002Faitour.microsoft.com)上）\n- 研讨会也可以在家以**自主进度的实验课**形式完成，使用您自己的订阅。\n\n### 实验室指南\n\n1. [在线查看研讨会](https:\u002F\u002Faka.ms\u002Faitour\u002Fcontoso-chat\u002Fworkshop) - 在浏览器中查看预先构建的研讨会版本\n1. **本地查看研讨会** - 该研讨会使用 Mkdocs 构建。要本地预览，  \n    - 安装 mkdocs：`pip install mkdocs-material`\n    - 切换到文件夹：`cd docs\u002Fworkshop`\n    - 启动预览：`mkdocs serve`\n    - 打开浏览器并访问指定的预览 URL\n\n在使用研讨会时遇到问题或疑问？请提交带有 `documentation` 标签的[新问题](https:\u002F\u002Fgithub.com\u002FAzure-Samples\u002Fcontoso-chat\u002Fissues\u002Fnew)。\n\n\n## 资源\n\n1. [Prompty 文档](https:\u002F\u002Fprompty.ai)\n1. [Azure AI Foundry 文档](https:\u002F\u002Faka.ms\u002Faistudio)\n1. [使用 Azure AI 服务开发 AI 应用程序](https:\u002F\u002Faka.ms\u002Fai-apps-docs)\n1. [结合 Azure 开发者 CLI 的 Azure AI 模板](https:\u002F\u002Faka.ms\u002Fai-studio\u002Fazd-templates)\n\n\n## 行为准则\n\n本项目已采纳[Microsoft 开源行为准则](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002F)。了解更多信息：\n\n- [Microsoft 开源行为准则](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002F)\n- [Microsoft 行为准则常见问题解答](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002Ffaq\u002F)\n- 如有任何问题或疑虑，请联系 [opencode@microsoft.com](mailto:opencode@microsoft.com)\n\n如需更多信息，请参阅[行为准则常见问题解答](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002Ffaq\u002F)，或如有其他问题或意见，请联系 [opencode@microsoft.com](mailto:opencode@microsoft.com)。\n\n## 责任AI指南\n\n本项目遵循以下责任AI指南与最佳实践，请在使用本项目前仔细阅读：\n\n- [Microsoft 责任AI指南](https:\u002F\u002Fwww.microsoft.com\u002Fen-us\u002Fai\u002Fresponsible-ai)\n- [适用于 Azure OpenAI 模型的责任AI实践](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Flegal\u002Fcognitive-services\u002Fopenai\u002Foverview)\n- [安全评估透明度说明](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fazure\u002Fai-studio\u002Fconcepts\u002Fsafety-evaluations-transparency-note)\n\n---","# Contoso Chat 快速上手指南\n\n---\n\n## 环境准备\n\n### 系统要求\n\n- 操作系统：Windows、Linux 或 macOS（推荐使用 Linux 或 macOS）\n- Python 3.10+\n- Docker Desktop（用于本地开发或容器环境）\n- Azure 账户（[免费注册](https:\u002F\u002Fazure.microsoft.com\u002Ffree\u002F)）\n- GitHub 账户（[免费注册](https:\u002F\u002Fgithub.com\u002Fsignup)）\n\n### 前置依赖\n\n- Azure CLI (`az`)\n- Azure Developer CLI (`azd`)\n- Prompty 工具\n- Git\n\n> **提示**：如果你在中国，可以使用国内镜像源加速安装过程。例如，使用 [清华源](https:\u002F\u002Fmirrors.tuna.tsinghua.edu.cn\u002Fhelp\u002Fanaconda\u002F) 安装 Python 包。\n\n---\n\n## 安装步骤\n\n### 1. 克隆项目\n\n你可以通过以下命令在本地初始化项目：\n\n```bash\nazd init -t contoso-chat\n```\n\n这将创建一个名为 `contoso-chat` 的文件夹，并下载项目模板。\n\n进入项目目录：\n\n```bash\ncd contoso-chat\n```\n\n### 2. 安装依赖\n\n进入 API 目录并安装 Python 依赖项：\n\n```bash\ncd src\u002Fapi\npip install -r requirements.txt\n```\n\n> 如果你使用的是国内网络，建议配置 pip 使用国内镜像源，如：\n> ```bash\n> pip install -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple -r requirements.txt\n> ```\n\n### 3. 配置 Azure 认证\n\n在终端中运行以下命令登录 Azure：\n\n```bash\naz login --use-device-code\n```\n\n接着，使用 Azure Developer CLI 登录：\n\n```bash\nazd auth login --use-device-code\n```\n\n---\n\n## 基本使用\n\n### 1. 初始化 Azure 环境\n\n运行以下命令来部署基础设施并启动应用：\n\n```bash\nazd up\n```\n\n该命令会提示你选择以下内容：\n\n- Azure 订阅\n- 环境名称（对应资源组）\n- 部署区域（推荐使用 `eastus2` 或 `francecentral`）\n\n> 注意：部分功能为预览版，不适用于生产环境。\n\n### 2. 启动本地服务（可选）\n\n如果需要在本地运行服务，可以在 `src\u002Fapi` 目录下启动 FastAPI 应用：\n\n```bash\nuvicorn main:app --reload\n```\n\n然后访问 `http:\u002F\u002Flocalhost:8000` 查看 API 文档。\n\n---\n\n## 总结\n\n通过以上步骤，你可以快速搭建并运行 Contoso Chat 项目，体验基于 RAG（检索增强生成）的零售助手功能。更多高级功能和细节，请参考完整文档。","某大型户外用品电商平台“Contoso Outdoor”正在开发一个智能客服系统，用于帮助用户快速获取产品信息和个性化推荐。然而，传统的客服方式无法满足日益增长的用户需求，尤其是在处理复杂查询和提供精准推荐方面存在明显不足。\n\n### 没有 contoso-chat 时\n\n- 客服团队需要手动查找产品信息和用户历史记录，响应速度慢且容易出错。\n- 用户提出的复杂问题（如“适合初学者的帐篷有哪些？”）难以通过预设规则准确回答。\n- 缺乏统一的数据整合机制，导致推荐结果与用户实际需求不匹配。\n- 部署和测试流程繁琐，每次更新都需要人工干预，效率低下。\n- 无法对模型效果进行自动化评估，难以持续优化服务质量。\n\n### 使用 contoso-chat 后\n\n- 基于 RAG 架构，系统能自动从产品数据库和用户行为数据中检索相关信息，生成准确、自然的回答。\n- 支持多意图识别和任务映射，能够灵活处理各种复杂问题，并给出个性化推荐。\n- 整合 Azure AI Foundry 和 Prompty 工具链，实现数据、模型和应用的一体化管理，提升推荐精准度。\n- 通过 AZD CLI 和 GitHub Actions 实现自动化部署和测试，大幅缩短迭代周期。\n- 提供内置的评估框架，可实时监控模型性能并进行持续优化，确保服务质量和用户体验。\n\n核心价值：contoso-chat 通过 RAG 技术和自动化工具链，显著提升了客服系统的智能化水平和运营效率，为用户提供更精准、高效的服务体验。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FAzure-Samples_contoso-chat_cc25989c.png","Azure-Samples","Azure Samples","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FAzure-Samples_101a6251.png","Microsoft Azure code samples and examples in .NET, Java, Python, JavaScript, TypeScript, PHP and Ruby",null,"https:\u002F\u002Flearn.microsoft.com\u002Fazure","https:\u002F\u002Fgithub.com\u002FAzure-Samples",[83,87,91,95,99,103],{"name":84,"color":85,"percentage":86},"Bicep","#519aba",69.1,{"name":88,"color":89,"percentage":90},"Python","#3572A5",13.5,{"name":92,"color":93,"percentage":94},"Jupyter Notebook","#DA5B0B",13.3,{"name":96,"color":97,"percentage":98},"PowerShell","#012456",1.8,{"name":100,"color":101,"percentage":102},"Shell","#89e051",1.4,{"name":104,"color":105,"percentage":106},"Dockerfile","#384d54",0.9,757,4017,"2026-04-02T17:20:22","MIT","Linux, macOS, Windows","未说明","16GB+",{"notes":115,"python":116,"dependencies":117},"建议使用 GitHub Codespaces 或 Dev Containers 进行开发，以减少本地环境配置的复杂性。需要 Azure 订阅和相关服务的访问权限，如 Azure OpenAI、Azure AI Search 和 Azure Cosmos DB。首次部署时需下载并配置多个 Azure 服务资源。","3.10+",[118,119,120,121,122,123,124,125,126],"fastapi","uvicorn","azure-core","azure-ai-search","azure-cosmos","prompty","openai","pydantic","requests",[26,13],[129,130,121,131,132,133,134,135,67,136,137,138,139],"ai-azd-templates","azd-templates","azure-ai-services","azure-cosmosdb","azure-openai-service","copilot-tutorial","llmops","rag-copilot","retail-sample","azure-ai-foundry","azure-ai-samples","2026-03-27T02:49:30.150509","2026-04-06T05:35:32.496484",[143,148,153,158,163,168],{"id":144,"question_zh":145,"answer_zh":146,"source_url":147},5721,"如何解决 `InteractiveBrowserCredential.get_token` 认证超时的问题？","该问题可能是由于订阅配置错误导致的。请确认你的 Azure 工作区名称是否正确，应使用资源名称而非项目名称。如果问题仍然存在，请检查订阅权限和认证流程。","https:\u002F\u002Fgithub.com\u002FAzure-Samples\u002Fcontoso-chat\u002Fissues\u002F61",{"id":149,"question_zh":150,"answer_zh":151,"source_url":152},5722,"如何解决部署时出现的 `The target scope 'subscription' does not match the deployment scope 'resourceGroup'` 错误？","请将 `az deployment sub create` 命令改为 `az deployment group create`，以确保部署作用域与模板文件中定义的作用域一致。","https:\u002F\u002Fgithub.com\u002FAzure-Samples\u002Fcontoso-chat\u002Fissues\u002F79",{"id":154,"question_zh":155,"answer_zh":156,"source_url":157},5723,"如何解决 forked repo 在 Codespaces 中无法构建的问题？","请确保在 fork 的仓库根目录中包含 `requirements.txt` 文件，并且所有依赖项版本一致。如果缺少此文件或版本不匹配，可能会导致环境构建失败。","https:\u002F\u002Fgithub.com\u002FAzure-Samples\u002Fcontoso-chat\u002Fissues\u002F131",{"id":159,"question_zh":160,"answer_zh":161,"source_url":162},5724,"运行 `azd up` 后页面无法加载，如何解决？","请尝试删除并重新创建部署。Azure AI Studio 中已不再支持聊天端点，因此旧链接可能失效。此外，建议检查 README.md 中的步骤是否与当前代码实际一致。","https:\u002F\u002Fgithub.com\u002FAzure-Samples\u002Fcontoso-chat\u002Fissues\u002F146",{"id":164,"question_zh":165,"answer_zh":166,"source_url":167},5725,"如何解决 `Endpoint resources are no longer supported` 错误？","请删除原有的 endpoint 资源，并将其替换为 connection 类型的资源。主分支已更新以符合新要求，但需要手动添加 ContentSafety 的连接配置。","https:\u002F\u002Fgithub.com\u002FAzure-Samples\u002Fcontoso-chat\u002Fissues\u002F137",{"id":169,"question_zh":170,"answer_zh":171,"source_url":172},5726,"如何解决 `Environment '{}' is not registered` 错误？","请在 ML Studio 中找到对应的环境，点击 \"Rebuild\" 按钮重新构建环境。如果构建成功后仍报错，请检查环境是否已正确注册到工作区。","https:\u002F\u002Fgithub.com\u002FAzure-Samples\u002Fcontoso-chat\u002Fissues\u002F51",[]]