diff --git a/docs/ai/azure-ai-services-authentication.md b/docs/ai/azure-ai-services-authentication.md index bbb0e6debda8c..1d457b9de9cd1 100644 --- a/docs/ai/azure-ai-services-authentication.md +++ b/docs/ai/azure-ai-services-authentication.md @@ -1,6 +1,6 @@ --- title: Authenticate to Azure OpenAI using .NET -description: Learn about the different options to authenticate to Azure OpenAI and other services using .NET +description: Learn about the different options to authenticate to Azure OpenAI and other services using .NET. author: alexwolfmsft ms.topic: concept-article ms.date: 04/09/2025 @@ -8,7 +8,7 @@ ms.date: 04/09/2025 # Azure AI services authentication and authorization using .NET -Application requests to Azure AI Services must be authenticated. In this article, you explore the options available to authenticate to Azure OpenAI and other AI services using .NET. These concepts apply to the Semantic Kernel SDK, as well as SDKs from specific services such as Azure OpenAI. Most AI services offer two primary ways to authenticate apps and users: +Application requests to Azure AI Services must be authenticated. In this article, you explore the options available to authenticate to Azure OpenAI and other AI services using .NET. Most AI services offer two primary ways to authenticate apps and users: - **Key-based authentication** provides access to an Azure service using secret key values. These secret values are sometimes known as API keys or access keys depending on the service. - **Microsoft Entra ID** provides a comprehensive identity and access management solution to ensure that the correct identities have the correct level of access to different Azure resources. @@ -80,18 +80,18 @@ az login ### Configure the app code -Use the [`Azure.Identity`](/dotnet/api/overview/azure/identity-readme) client library from the Azure SDK to implement Microsoft Entra authentication in your code. The `Azure.Identity` libraries include the `DefaultAzureCredential` class, which automatically discovers available Azure credentials based on the current environment and tooling available. Visit the [Azure SDK for .NET](/dotnet/api/azure.identity.defaultazurecredential) documentation for the full set of supported environment credentials and the order in which they are searched. +Use the [`Azure.Identity`](/dotnet/api/overview/azure/identity-readme) client library from the Azure SDK to implement Microsoft Entra authentication in your code. The `Azure.Identity` libraries include the `DefaultAzureCredential` class, which automatically discovers available Azure credentials based on the current environment and tooling available. For the full set of supported environment credentials and the order in which they are searched, see the [Azure SDK for .NET](/dotnet/api/azure.identity.defaultazurecredential) documentation. -For example, configure Semantic Kernel to authenticate using `DefaultAzureCredential` using the following code: +For example, configure Azure OpenAI to authenticate using `DefaultAzureCredential` using the following code: ```csharp -Kernel kernel = Kernel - .CreateBuilder() - .AddAzureOpenAITextGeneration( - "your-model", - "your-endpoint", - new DefaultAzureCredential()) - .Build(); +AzureOpenAIClient azureClient = + new( + new Uri(endpoint), + new DefaultAzureCredential(new DefaultAzureCredentialOptions() + { TenantId = tenantId } + ) + ); ``` `DefaultAzureCredential` enables apps to be promoted from local development to production without code changes. For example, during development `DefaultAzureCredential` uses your local user credentials from Visual Studio or the Azure CLI to authenticate to the AI service. When the app is deployed to Azure, `DefaultAzureCredential` uses the managed identity that is assigned to your app. diff --git a/docs/ai/conceptual/embeddings.md b/docs/ai/conceptual/embeddings.md index e6ae4047f247c..79ca9ffd307f5 100644 --- a/docs/ai/conceptual/embeddings.md +++ b/docs/ai/conceptual/embeddings.md @@ -49,14 +49,14 @@ You generate embeddings for your raw data by using an AI embedding model, which ### Store and process embeddings in a vector database -After you generate embeddings, you'll need a way to store them so you can later retrieve them with calls to an LLM. Vector databases are designed to store and process vectors, so they're a natural home for embeddings. Different vector databases offer different processing capabilities, so you should choose one based on your raw data and your goals. For information about your options, see [available vector database solutions](vector-databases.md#semantic-kernel-vector-database-solutions). +After you generate embeddings, you'll need a way to store them so you can later retrieve them with calls to an LLM. Vector databases are designed to store and process vectors, so they're a natural home for embeddings. Different vector databases offer different processing capabilities, so you should choose one based on your raw data and your goals. For information about your options, see [Vector databases for .NET + AI](vector-databases.md). ### Using embeddings in your LLM solution -When building LLM-based applications, you can use Semantic Kernel to integrate embedding models and vector stores, so you can quickly pull in text data, and generate and store embeddings. This lets you use a vector database solution to store and retrieve semantic memories. +When building LLM-based applications, you can use Agent Framework to integrate embedding models and vector stores, so you can quickly pull in text data, and generate and store embeddings. This lets you use a vector database solution to store and retrieve semantic memories. ## Related content - [How GenAI and LLMs work](how-genai-and-llms-work.md) - [Retrieval-augmented generation](rag.md) -- [Training: Develop AI agents with Azure OpenAI and Semantic Kernel](/training/paths/develop-ai-agents-azure-open-ai-semantic-kernel-sdk/) +- [Training: Develop an AI agent with Microsoft Agent Framework](/training/modules/develop-ai-agent-with-semantic-kernel/) diff --git a/docs/ai/conceptual/prompt-engineering-dotnet.md b/docs/ai/conceptual/prompt-engineering-dotnet.md index f9f0ac09f0213..d56e361853572 100644 --- a/docs/ai/conceptual/prompt-engineering-dotnet.md +++ b/docs/ai/conceptual/prompt-engineering-dotnet.md @@ -1,11 +1,8 @@ --- -title: Prompt Engineering concepts -description: Learn basic prompt engineering concepts and how to implement them using .NET tools such as the Semantic Kernel SDK -ms.topic: concept-article #Don't change. -ms.date: 04/09/2025 - -#customer intent: As a .NET developer, I want to understand prompt engineering techniques for .NET so that I can build more efficient and targeted AI apps. - +title: Prompt engineering concepts +description: Learn basic prompt engineering concepts and how to implement them using .NET tools such as Microsoft Agent Framework. +ms.topic: concept-article +ms.date: 02/05/2026 --- # Prompt engineering in .NET @@ -14,163 +11,51 @@ In this article, you explore essential prompt engineering concepts. Many AI mode ## Work with prompts -Consider this text generation example where *prompt* is the user input and *completion* is the model output: - -Prompt: **"The president who served the shortest term was "** - -Completion: _"Pedro Lascurain."_ - -The completion appears correct, but what if your app is supposed to help U.S. history students? Pedro Lascurain's 45-minute term is the shortest term for any president, but he served as the president of Mexico. The U.S. history students are probably looking for *"William Henry Harrison"*. Clearly, the app could be more helpful to its intended users if you gave it some context. - -Prompt engineering adds context to the prompt by providing [*instructions*](#use-instructions-to-improve-the-completion), [*examples*](#use-examples-to-guide-the-model), and [*cues*](#understand-cues) to help the model produce better completions. - -Models that support text generation often don't require any specific format, but you should organize your prompts so it's clear what's an instruction and what's an example. Models that support chat-based apps use three roles to organize completions: a system role that controls the chat, a user role to represent user input, and an assistant role for responding to users. Divide your prompts into messages for each role: +Models that support chat-based apps use three roles to organize completions: a *system* role that controls the chat, a *user* role to represent user input, and an *assistant* role for responding to users. Divide your prompts into messages for each role: - [*System messages*](/azure/ai-services/openai/concepts/advanced-prompt-engineering?pivots=programming-language-chat-completions#system-message) give the model instructions about the assistant. A prompt can have only one system message, and it must be the first message. -- *User messages* include prompts from the user and show examples, historical prompts, or contain instructions for the assistant. An example chat completion must have at least one user message. -- *Assistant messages* show example or historical completions, and must contain a response to the preceding user message. Assistant messages aren't required, but if you include one it must be paired with a user message to form an example. +- *User messages* include prompts from the user, examples, or instructions for the assistant. An example chat completion must have at least one user message. +- *Assistant messages* show example or historical completions and must contain a response to the preceding user message. Assistant messages aren't required, but if you include one, it must be paired with a user message to form an example. ## Use instructions to improve the completion -An instruction is text that tells the model how to respond. An instruction can be a directive or an imperative: +An *instruction* is text that tells the model how to respond. An instruction can be a *directive* or an *imperative*: -- *Directives* tell the model how to behave, but aren't simple commands—think character setup for an improv actor: **"You're helping students learn about U.S. history, so talk about the U.S. unless they specifically ask about other countries."** +- *Directives* tell the model how to behave but aren't simple commands—think character setup for an improv actor: **"You're helping students learn about U.S. history, so talk about the U.S. unless they specifically ask about other countries or regions."** - *Imperatives* are unambiguous commands for the model to follow. **"Translate to Tagalog:"** -Directives are more open-ended and flexible than imperatives: - -- You can combine several directives in one instruction. -- Instructions usually work better when you use them with examples. However, because imperatives are unambiguous commands, models don't need examples to understand them (though you might use an example to show the model how to format responses). Because a directive doesn't tell the model exactly what to do, each example can help the model work better. -- It's usually better to break down a difficult instruction into a series of steps, which you can do with a sequence of directives. You should also tell the model to output the result of each step, so that you can easily make granular adjustments. Although you can break down the instruction into steps yourself, it's easier to just tell the model to do it, and to output the result of each step. This approach is called [chain of thought prompting](chain-of-thought-prompting.md). - -### Primary and supporting content add context - -You can provide content to add more context to instructions. - -*Primary content* is text that you want the model to process with an instruction. Whatever action the instruction entails, the model will perform it on the primary content to produce a completion. - -*Supporting content* is text that you refer to in an instruction, but which isn't the target of the instruction. The model uses the supporting content to complete the instruction, which means that supporting content also appears in completions, typically as some kind of structure (such as in headings or column labels). - -Use labels with your instructional content to help the model figure out how to use it with the instruction. Don't worry too much about precision—labels don't have to match instructions exactly because the model will handle things like word form and capitalization. - -Suppose you use the instruction **"Summarize US Presidential accomplishments"** to produce a list. The model might organize and order it in any number of ways. But what if you want the list to group the accomplishments by a specific set of categories? Use supporting content to add that information to the instruction. - -Adjust your instruction so the model groups by category, and append supporting content that specifies those categories: - -```csharp -prompt = """ -Instructions: Summarize US Presidential accomplishments, grouped by category. -Categories: Domestic Policy, US Economy, Foreign Affairs, Space Exploration. -Accomplishments: 'George Washington -- First president of the United States. -- First president to have been a military veteran. -- First president to be elected to a second term in office. -- Received votes from every presidential elector in an election. -- Filled the entire body of the United States federal judges; including the Supreme Court. -- First president to be declared an honorary citizen of a foreign country, and an honorary citizen of France. -John Adams ...' ///Text truncated -"""; -``` - ## Use examples to guide the model An example is text that shows the model how to respond by providing sample user input and model output. The model uses examples to infer what to include in completions. Examples can come either before or after the instructions in an engineered prompt, but the two shouldn't be interspersed. An example starts with a prompt and can optionally include a completion. A completion in an example doesn't have to include the verbatim response—it might just contain a formatted word, the first bullet in an unordered list, or something similar to indicate how each completion should start. -Examples are classified as [zero-shot learning](zero-shot-learning.md) or [few-shot learning](zero-shot-learning.md) based on whether they contain verbatim completions. +Examples are classified as [zero-shot learning](zero-shot-learning.md#zero-shot-learning) or [few-shot learning](zero-shot-learning.md#few-shot-learning) based on whether they contain verbatim completions. - **Zero-shot learning** examples include a prompt with no verbatim completion. This approach tests a model's responses without giving it example data output. Zero-shot prompts can have completions that include cues, such as indicating the model should output an ordered list by including **"1."** as the completion. - **Few-shot learning** examples include several pairs of prompts with verbatim completions. Few-shot learning can change the model's behavior by adding to its existing knowledge. -## Understand cues - -A cue is text that conveys the desired structure or format of output. Like an instruction, a cue isn't processed by the model as if it were user input. Like an example, a cue shows the model what you want instead of telling it what to do. You can add as many cues as you want, so you can iterate to get the result you want. Cues are used with an instruction or an example and should be at the end of the prompt. +## Cues -Suppose you use an instruction to tell the model to produce a list of presidential accomplishments by category, along with supporting content that tells the model what categories to use. You decide that you want the model to produce a nested list with all caps for categories, with each president's accomplishments in each category listed on one line that begins with their name, with presidents listed chronologically. After your instruction and supporting content, you could add three cues to show the model how to structure and format the list: - -```csharp -prompt = """ -Instructions: Summarize US Presidential accomplishments, grouped by category. -Categories: Domestic Policy, US Economy, Foreign Affairs, Space Exploration. -Accomplishments: George Washington -First president of the United States. -First president to have been a military veteran. -First president to be elected to a second term in office. -First president to receive votes from every presidential elector in an election. -First president to fill the entire body of the United States federal judges; including the Supreme Court. -First president to be declared an honorary citizen of a foreign country, and an honorary citizen of France. -John Adams ... /// Text truncated - -DOMESTIC POLICY -- George Washington: -- John Adams: -"""; -``` - -- **DOMESTIC POLICY** shows the model that you want it to start each group with the category in all caps. -- **- George Washington:** shows the model to start each section with George Washington's accomplishments listed on one line. -- **- John Adams:** shows the model that it should list remaining presidents in chronological order. +A *cue* is text that conveys the desired structure or format of output. Like an instruction, a cue isn't processed by the model as if it were user input. Like an example, a cue shows the model what you want instead of telling it what to do. You can add as many cues as you want, so you can iterate to get the result you want. Cues are used with an instruction or an example and should be at the end of the prompt. ## Example prompt using .NET -.NET provides various tools to prompt and chat with different AI models. Use [Semantic Kernel](/semantic-kernel/overview/) to connect to a wide variety of AI models and services, as well as other SDKs such as the official [OpenAI .NET library](https://www.nuget.org/packages/OpenAI-DotNet/). Semantic Kernel includes tools to create prompts with different roles and maintain chat history, as well as many other features. +.NET provides various tools to prompt and chat with different AI models. You can use [Agent Framework](/agent-framework/) to connect to a wide variety of AI models and services. Agent Framework includes tools to create agents with system instructions and maintain conversation state across multiple turns. Consider the following code example: -```csharp -using Microsoft.SemanticKernel; -using Microsoft.SemanticKernel.ChatCompletion; - -// Create a kernel with OpenAI chat completion -#pragma warning disable SKEXP0010 -Kernel kernel = Kernel.CreateBuilder() - .AddOpenAIChatCompletion( - modelId: "phi3:mini", - endpoint: new Uri("http://localhost:11434"), - apiKey: "") - .Build(); - -var aiChatService = kernel.GetRequiredService(); -var chatHistory = new ChatHistory(); -chatHistory.Add( - new ChatMessageContent(AuthorRole.System, "You are a helpful AI Assistant.")); - -while (true) -{ - // Get user prompt and add to chat history - Console.WriteLine("Your prompt:"); - chatHistory.Add(new ChatMessageContent(AuthorRole.User, Console.ReadLine())); - - // Stream the AI response and add to chat history - Console.WriteLine("AI Response:"); - var response = ""; - await foreach (var item in - aiChatService.GetStreamingChatMessageContentsAsync(chatHistory)) - { - Console.Write(item.Content); - response += item.Content; - } - chatHistory.Add(new ChatMessageContent(AuthorRole.Assistant, response)); - Console.WriteLine(); -} -``` - -The preceding code provides examples of the following concepts: - -- Creates a chat history service to prompt the AI model for completions based on author roles. -- Configures the AI with an `AuthorRole.System` message. -- Accepts user input to allow for different types of prompts in the context of an `AuthorRole.User`. -- Asynchronously streams the completion from the AI to provide a dynamic chat experience. - -## Extend your prompt engineering techniques - -You can also increase the power of your prompts with more advanced prompt engineering techniques that are covered in depth in their own articles. - -- LLMs have token input limits that constrain the amount of text you can fit in a prompt. Use [embeddings](embeddings.md) and [vector database solutions](vector-databases.md) to reduce the number of tokens you need to represent a given piece of text. -- LLMs aren't trained on your data unless you train them yourself, which can be costly and time-consuming. Use [retrieval augmented generation (RAG)](rag.md) to make your data available to an LLM without training it. +:::code language="csharp" source="../snippets/prompt-engineering/multi-turn-chat.cs"::: + +The preceding code: + +- Creates an Azure OpenAI client with an endpoint and API key. +- Gets a chat client for the GPT-4o model and converts it to an AI agent. +- Creates an agent session to maintain conversation state across multiple turns. +- Accepts user input in a loop to allow for different types of prompts. +- Asynchronously streams the AI response and displays it to the console. ## Related content -- [Prompt engineering techniques](/azure/ai-services/openai/concepts/advanced-prompt-engineering) -- [Configure prompts in Semantic Kernel](/semantic-kernel/prompts/configure-prompts?tabs=Csharp) +- [Prompt engineering techniques](/azure/ai-foundry/openai/concepts/prompt-engineering) +- [System message design](/azure/ai-services/openai/concepts/advanced-prompt-engineering) diff --git a/docs/ai/conceptual/understanding-openai-functions.md b/docs/ai/conceptual/understanding-openai-functions.md index 4ac7d803a2378..8e191c908356c 100644 --- a/docs/ai/conceptual/understanding-openai-functions.md +++ b/docs/ai/conceptual/understanding-openai-functions.md @@ -43,12 +43,6 @@ Some models support parallel function calling, which enables the model to reques Not all OpenAI models are trained to support function calling. For a list of models that support function calling or parallel function calling, see [OpenAI - Supported Models](https://platform.openai.com/docs/guides/function-calling/supported-models). -## Function calling with the Semantic Kernel SDK - -The [Semantic Kernel SDK](/semantic-kernel/overview/) supports describing which functions are available to your AI [using the `KernelFunction` decorator](/semantic-kernel/agents/plugins/using-the-kernelfunction-decorator?tabs=Csharp#use-the-kernelfunction-decorator-to-define-a-native-function). - -The Kernel builds the `tools` parameter of a request based on your decorators, orchestrates the requested function calls to your code, and returns results back to the model. - ## Token counts Function descriptions are included in the system message of your request to a model. These function descriptions count against your model's [token limit](/azure/ai-services/openai/quotas-limits) and are [included in the cost of the request](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/). @@ -61,5 +55,4 @@ If your request exceeds the model's token limit, try the following modifications ## Related content * [Understanding tokens](understanding-tokens.md) -* [Creating native functions for AI to call](/semantic-kernel/agents/plugins/using-the-kernelfunction-decorator?tabs=Csharp) * [Prompt engineering](prompt-engineering-dotnet.md) diff --git a/docs/ai/conceptual/understanding-tokens.md b/docs/ai/conceptual/understanding-tokens.md index 682f4e9272258..9d9e76d55af4b 100644 --- a/docs/ai/conceptual/understanding-tokens.md +++ b/docs/ai/conceptual/understanding-tokens.md @@ -77,7 +77,7 @@ As training continues, the model adds any new tokens in the training text to its The semantic relationships between the tokens can be analyzed by using these token ID sequences. Multi-valued numeric vectors, known as [embeddings](embeddings.md), are used to represent these relationships. An embedding is assigned to each token based on how commonly it's used together with, or in similar contexts to, the other tokens. -After it's trained, a model can calculate an embedding for text that contains multiple tokens. The model tokenizes the text, then calculates an overall embeddings value based on the learned embeddings of the individual tokens. This technique can be used for semantic document searches or adding [vector stores](/semantic-kernel/concepts/vector-store-connectors/) to an AI. +After it's trained, a model can calculate an embedding for text that contains multiple tokens. The model tokenizes the text, then calculates an overall embeddings value based on the learned embeddings of the individual tokens. This technique can be used for semantic document searches or adding vector stores to an AI. During output generation, the model predicts a vector value for the next token in the sequence. The model then selects the next token from its vocabulary based on this vector value. In practice, the model calculates multiple vectors by using various elements of the previous tokens' embeddings. The model then evaluates all potential tokens from these vectors and selects the most probable one to continue the sequence. diff --git a/docs/ai/conceptual/vector-databases.md b/docs/ai/conceptual/vector-databases.md index 36fbfed5b4f4e..2373efce66156 100644 --- a/docs/ai/conceptual/vector-databases.md +++ b/docs/ai/conceptual/vector-databases.md @@ -41,11 +41,6 @@ Other benefits of the RAG pattern include: - Overcome LLM tokens limits - the heavy lifting is done through the database vector search. - Reduce the costs from frequent fine-tuning on updated data. -## Semantic Kernel vector database solutions - -[!INCLUDE [sk-connectors](../includes/sk-connectors.md)] - ## Related content - [Implement Azure OpenAI with RAG using vector search in a .NET app](../tutorials/tutorial-ai-vector-search.md) -- [More Semantic Kernel .NET connectors](https://github.com/microsoft/semantic-kernel/tree/main/dotnet/src/Connectors) diff --git a/docs/ai/dotnet-ai-ecosystem.md b/docs/ai/dotnet-ai-ecosystem.md index 8195c9407f78f..d410a93e0149a 100644 --- a/docs/ai/dotnet-ai-ecosystem.md +++ b/docs/ai/dotnet-ai-ecosystem.md @@ -14,7 +14,7 @@ The .NET ecosystem provides many powerful tools, libraries, and services to deve ## Microsoft.Extensions.AI libraries -[`Microsoft.Extensions.AI`](microsoft-extensions-ai.md) is a set of core .NET libraries that provide a unified layer of C# abstractions for interacting with AI services, such as small and large language models (SLMs and LLMs), embeddings, and middleware. These APIs were created in collaboration with developers across the .NET ecosystem, including Semantic Kernel. The low-level APIs, such as and , were extracted from Semantic Kernel and moved into the namespace. +[`Microsoft.Extensions.AI`](microsoft-extensions-ai.md) is a set of core .NET libraries that provide a unified layer of C# abstractions for interacting with AI services, such as small and large language models (SLMs and LLMs), embeddings, and middleware. These APIs were created in collaboration with developers across the .NET ecosystem. The low-level APIs, such as and , were extracted from Semantic Kernel and moved into the namespace. `Microsoft.Extensions.AI` provides abstractions that can be implemented by various services, all adhering to the same core concepts. This library is not intended to provide APIs tailored to any specific provider's services. The goal of `Microsoft.Extensions.AI` is to act as a unifying layer within the .NET ecosystem, enabling developers to choose their preferred frameworks and libraries while ensuring seamless integration and collaboration across the ecosystem. @@ -41,9 +41,7 @@ For more information, see the [Microsoft Agent Framework documentation](/agent-f ## Semantic Kernel for .NET -[Semantic Kernel](/semantic-kernel/overview/) is an open-source library that enables AI integration and orchestration capabilities in your .NET apps. Semantic Kernel has a dependency on the `Microsoft.Extensions.AI.Abstractions` package and provides connectors with concrete implementations of and for different services, including OpenAI, Amazon Bedrock, and Google Gemini. - -However, for new applications that require agentic capabilities, multi-agent orchestration, or enterprise-grade observability and security, the recommended framework is [Microsoft Agent Framework](/agent-framework/overview/agent-framework-overview). +[Semantic Kernel](/semantic-kernel/overview/) is an open-source library that enables AI integration and orchestration capabilities in your .NET apps. However, for new applications that require agentic capabilities, multi-agent orchestration, or enterprise-grade observability and security, the recommended framework is [Microsoft Agent Framework](/agent-framework/overview/agent-framework-overview). ## .NET SDKs for building AI apps @@ -54,7 +52,6 @@ Many different SDKs are available to build .NET apps with AI capabilities depend | NuGet package | Supported models | Maintainer or vendor | Documentation | |---------------|------------------|----------------------|--------------| | [Microsoft.Agents.AI.OpenAI](https://www.nuget.org/packages/Microsoft.Agents.AI.OpenAI/) | [OpenAI models](https://platform.openai.com/docs/models/overview)
[Azure OpenAI supported models](/azure/ai-services/openai/concepts/models) | [Microsoft Agent Framework](https://github.com/microsoft/agent-framework) (Microsoft) | [Agent Framework documentation](/agent-framework/overview/agent-framework-overview) | -| [Microsoft.SemanticKernel](https://www.nuget.org/packages/Microsoft.SemanticKernel/) | [OpenAI models](https://platform.openai.com/docs/models/overview)
[Azure OpenAI supported models](/azure/ai-services/openai/concepts/models) | [Semantic Kernel](https://github.com/microsoft/semantic-kernel) (Microsoft) | [Semantic Kernel documentation](/semantic-kernel/) | | [Azure OpenAI SDK](https://www.nuget.org/packages/Azure.AI.OpenAI/) | [Azure OpenAI supported models](/azure/ai-services/openai/concepts/models) | [Azure SDK for .NET](https://github.com/Azure/azure-sdk-for-net) (Microsoft) | [Azure OpenAI services documentation](/azure/ai-services/openai/) | | [OpenAI SDK](https://www.nuget.org/packages/OpenAI/) | [OpenAI supported models](https://platform.openai.com/docs/models) | [OpenAI SDK for .NET](https://github.com/openai/openai-dotnet) (OpenAI) | [OpenAI services documentation](https://platform.openai.com/docs/overview) | diff --git a/docs/ai/get-started-app-chat-template.md b/docs/ai/get-started-app-chat-template.md index 31f349944d96e..429702e1e512c 100644 --- a/docs/ai/get-started-app-chat-template.md +++ b/docs/ai/get-started-app-chat-template.md @@ -39,7 +39,7 @@ The architecture of the chat app is shown in the following diagram: - **User interface** - The application's chat interface is a [Blazor WebAssembly](/aspnet/core/blazor/) application. This interface is what accepts user queries, routes request to the application backend, and displays generated responses. - **Backend** - The application backend is an [ASP.NET Core Minimal API](/aspnet/core/fundamentals/minimal-apis/overview). The backend hosts the Blazor static web application and is what orchestrates the interactions among the different services. Services used in this application include: - [**Azure AI Search**](/azure/search/search-what-is-azure-search) – Indexes documents from the data stored in an Azure Storage Account. This makes the documents searchable using [vector search](/azure/search/search-get-started-vector) capabilities. - - [**Azure OpenAI Service**](/azure/ai-services/openai/overview) – Provides the Large Language Models (LLM) to generate responses. [Semantic Kernel](/semantic-kernel/whatissk) is used in conjunction with the Azure OpenAI Service to orchestrate the more complex AI workflows. + - [**Azure OpenAI Service**](/azure/ai-services/openai/overview) – Provides the Large Language Models (LLM) to generate responses. [Microsoft Agent Framework](/agent-framework/overview/agent-framework-overview) is used in conjunction with the Azure OpenAI Service to orchestrate the more complex AI workflows. ## Cost diff --git a/docs/ai/includes/sk-connectors.md b/docs/ai/includes/sk-connectors.md deleted file mode 100644 index c0402ca11d34a..0000000000000 --- a/docs/ai/includes/sk-connectors.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -ms.date: 07/29/2024 -ms.topic: include ---- - -AI applications often use data vector databases and services to improve relevancy and provide customized functionality. Many of these services provide a native SDK for .NET, while others offer a REST service you can connect to through custom code. Semantic Kernel provides an extensible component model that enables you to use different vector stores without needing to learn each SDK. - -Semantic Kernel provides connectors for the following vector databases and services: - -| Vector service | Semantic Kernel connector | .NET SDK | -|-------------------------------|---------------------------|----------| -| Azure AI Search | [Microsoft.SemanticKernel.Connectors.AzureAISearch](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.AzureAISearch) | [Azure.Search.Documents](https://www.nuget.org/packages/Azure.Search.Documents/) | -| Azure Cosmos DB for NoSQL | [Microsoft.SemanticKernel.Connectors.AzureCosmosDBNoSQL](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.AzureCosmosDBNoSQL) | [Microsoft.Azure.Cosmos](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/) | -| Azure Cosmos DB for MongoDB | [Microsoft.SemanticKernel.Connectors.AzureCosmosDBMongoDB](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.AzureCosmosDBMongoDB) | [MongoDb.Driver](https://www.nuget.org/packages/MongoDB.Driver) | -| Azure PostgreSQL Server | [Microsoft.SemanticKernel.Connectors.Postgres](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.Postgres) | [Npgsql](https://www.nuget.org/packages/Npgsql/) | -| Azure SQL Database | [Microsoft.SemanticKernel.Connectors.SqlServer](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.SqlServer) | [Microsoft.Data.SqlClient](https://www.nuget.org/packages/Microsoft.Data.SqlClient) | -| Chroma | [Microsoft.SemanticKernel.Connectors.Chroma](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.Chroma) | [ChromaDB.Client](https://www.nuget.org/packages/ChromaDB.Client) | -| DuckDB | [Microsoft.SemanticKernel.Connectors.DuckDB](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.DuckDB) | [DuckDB.NET.Data.Full](https://www.nuget.org/packages/DuckDB.NET.Data.Full) | -| Milvus | [Microsoft.SemanticKernel.Connectors.Milvus](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.Milvus) | [Milvus.Client](https://www.nuget.org/packages/Milvus.Client) | -| MongoDB Atlas Vector Search | [Microsoft.SemanticKernel.Connectors.MongoDB](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.MongoDB) | [MongoDb.Driver](https://www.nuget.org/packages/MongoDB.Driver) | -| Pinecone | [Microsoft.SemanticKernel.Connectors.Pinecone](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.Pinecone) | [REST API](https://docs.pinecone.io/reference/api/introduction) | -| Postgres | [Microsoft.SemanticKernel.Connectors.Postgres](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.Postgres) | [Npgsql](https://www.nuget.org/packages/Npgsql/) | -| Qdrant | [Microsoft.SemanticKernel.Connectors.Qdrant](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.Qdrant) | [Qdrant.Client](https://www.nuget.org/packages/Qdrant.Client) | -| Redis | [Microsoft.SemanticKernel.Connectors.Redis](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.Redis) | [StackExchange.Redis](https://www.nuget.org/packages/StackExchange.Redis) | -| Weaviate | [Microsoft.SemanticKernel.Connectors.Weaviate](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.Weaviate) | [REST API](https://docs.weaviate.io/weaviate/api/rest) | - -To discover .NET SDK and API support, visit the documentation for each respective service. diff --git a/docs/ai/index.yml b/docs/ai/index.yml index 205d6b55a00a1..678b45387b83b 100644 --- a/docs/ai/index.yml +++ b/docs/ai/index.yml @@ -25,10 +25,10 @@ landingContent: links: - text: Develop .NET apps with AI features url: overview.md - - text: Microsoft.Extensions.AI libraries - url: microsoft-extensions-ai.md - text: Microsoft Agent Framework url: /agent-framework/overview/agent-framework-overview?toc=/dotnet/ai/toc.json&bc=/dotnet/ai/toc.json + - text: Microsoft.Extensions.AI libraries + url: microsoft-extensions-ai.md - linkListType: get-started links: - text: Connect to and prompt an AI model @@ -63,28 +63,24 @@ landingContent: links: - text: Authenticate App Service to Azure OpenAI url: how-to/app-service-aoai-auth.md - - text: Authenticate App Service to a vector database - url: how-to/app-service-db-auth.md - - text: Use Redis with the Semantic Kernel SDK - url: how-to/use-redis-for-memory.md - - text: Use custom and local AI models with the Semantic Kernel SDK - url: how-to/work-with-local-models.md - - text: Work with content filtering - url: how-to/work-with-local-models.md + - text: Access data in AI functions + url: how-to/access-data-in-functions.md + - text: Use Microsoft.ML.Tokenizers for text tokenization + url: how-to/use-tokenizers.md # Card - title: Training linkLists: - linkListType: tutorial links: + - text: Develop an AI agent with Microsoft Agent Framework + url: /training/modules/develop-ai-agent-with-semantic-kernel/ - text: Plan and prepare to develop AI solutions on Azure url: /training/modules/prepare-azure-ai-development/ - text: Generate conversations Azure OpenAI completions url: /training/modules/open-ai-dotnet-text-completions - text: .NET enterprise chat sample using RAG url: get-started-app-chat-template.md - - text: Develop generative AI apps with Azure OpenAI and Semantic Kernel - url: /training/paths/develop-ai-agents-azure-open-ai-semantic-kernel-sdk # Card - title: Tutorials diff --git a/docs/ai/overview.md b/docs/ai/overview.md index ef3362204bde4..ed23e161a95cd 100644 --- a/docs/ai/overview.md +++ b/docs/ai/overview.md @@ -33,7 +33,7 @@ Millions of developers use .NET to create applications that run on the web, on m | Google Gemini | Google's multimodal AI models | | Amazon Bedrock | AWS's managed service for foundation models | -Any AI provider that's usable with `Microsoft.Extensions.AI` is also usable with Agent Framework and Semantic Kernel. +Any AI provider that's usable with `Microsoft.Extensions.AI` is also usable with Agent Framework. ## What can you build with AI and .NET? diff --git a/docs/ai/quickstarts/build-chat-app.md b/docs/ai/quickstarts/build-chat-app.md index b8c3cb44bb952..4c4e08a256dd6 100644 --- a/docs/ai/quickstarts/build-chat-app.md +++ b/docs/ai/quickstarts/build-chat-app.md @@ -22,8 +22,6 @@ In this quickstart, you learn how to create a conversational .NET console chat a :::zone-end -[!INCLUDE [semantic-kernel](includes/semantic-kernel.md)] - ## Create the app Complete the following steps to create a .NET console app to connect to an AI model. diff --git a/docs/ai/quickstarts/build-vector-search-app.md b/docs/ai/quickstarts/build-vector-search-app.md index 6e7af69aebc6a..39362176f2aaf 100644 --- a/docs/ai/quickstarts/build-vector-search-app.md +++ b/docs/ai/quickstarts/build-vector-search-app.md @@ -16,7 +16,7 @@ Vector stores, or vector databases, are essential for tasks like semantic search The app uses the and libraries so you can write code using AI abstractions rather than a specific SDK. AI abstractions help create loosely coupled code that allows you to change the underlying AI model with minimal app changes. -[📦 Microsoft.Extensions.VectorData.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.VectorData.Abstractions/) is a .NET library developed in collaboration with Semantic Kernel and the broader .NET ecosystem to provide a unified layer of abstractions for interacting with vector stores. The abstractions in `Microsoft.Extensions.VectorData.Abstractions` provide library authors and developers with the following functionality: +[📦 Microsoft.Extensions.VectorData.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.VectorData.Abstractions/) is a .NET library that provides a unified layer of abstractions for interacting with vector stores. The abstractions in `Microsoft.Extensions.VectorData.Abstractions` provide library authors and developers with the following functionality: - Perform create-read-update-delete (CRUD) operations on vector stores. - Use vector and text search on vector stores. diff --git a/docs/ai/quickstarts/chat-local-model.md b/docs/ai/quickstarts/chat-local-model.md index 808dea2598398..6625a97f32051 100644 --- a/docs/ai/quickstarts/chat-local-model.md +++ b/docs/ai/quickstarts/chat-local-model.md @@ -73,7 +73,7 @@ Complete the following steps to create a .NET console app that connects to your ## Connect to and chat with the AI model -The Semantic Kernel SDK provides many services and features to connect to AI models and manage interactions. In the steps ahead, you'll create a simple app that connects to the local AI and stores conversation history to improve the chat experience. +In the steps ahead, you'll create a simple app that connects to the local AI and stores conversation history to improve the chat experience. 1. Open the _Program.cs_ file and replace the contents of the file with the following code: diff --git a/docs/ai/quickstarts/generate-images.md b/docs/ai/quickstarts/generate-images.md index 761982617c796..aef274e6c69e5 100644 --- a/docs/ai/quickstarts/generate-images.md +++ b/docs/ai/quickstarts/generate-images.md @@ -22,8 +22,6 @@ In this quickstart, you create a .NET console app that uses `OpenAI.Images.Image :::zone-end -[!INCLUDE [semantic-kernel](includes/semantic-kernel.md)] - ## Create the app Complete the following steps to create a .NET console app to connect to an AI model. diff --git a/docs/ai/quickstarts/includes/semantic-kernel.md b/docs/ai/quickstarts/includes/semantic-kernel.md deleted file mode 100644 index e8fd9cd552194..0000000000000 --- a/docs/ai/quickstarts/includes/semantic-kernel.md +++ /dev/null @@ -1,2 +0,0 @@ -> [!NOTE] -> You can also use [Semantic Kernel](/semantic-kernel) to accomplish the tasks in this article. Semantic Kernel is a lightweight, open-source SDK that lets you build AI agents and integrate the latest AI models into your .NET apps. diff --git a/docs/ai/quickstarts/prompt-model.md b/docs/ai/quickstarts/prompt-model.md index 66a91a8b329d8..6d330b6bdec28 100644 --- a/docs/ai/quickstarts/prompt-model.md +++ b/docs/ai/quickstarts/prompt-model.md @@ -22,8 +22,6 @@ In this quickstart, you learn how to create a .NET console chat app to connect t :::zone-end -[!INCLUDE [semantic-kernel](includes/semantic-kernel.md)] - ## Create the app Complete the following steps to create a .NET console app to connect to an AI model. diff --git a/docs/ai/snippets/prompt-engineering/multi-turn-chat.cs b/docs/ai/snippets/prompt-engineering/multi-turn-chat.cs new file mode 100644 index 0000000000000..2099f7180da6c --- /dev/null +++ b/docs/ai/snippets/prompt-engineering/multi-turn-chat.cs @@ -0,0 +1,34 @@ +using Azure; +using Azure.AI.OpenAI; +using Microsoft.Agents.AI; +using OpenAI.Chat; + +string endpoint = "https://.openai.azure.com/"; +string apiKey = ""; + +AIAgent agent = new AzureOpenAIClient( + new Uri(endpoint), + new AzureKeyCredential(apiKey)) + .GetChatClient("gpt-4o") + .AsAIAgent(); + +// Create a session to maintain conversation state. +AgentSession session = await agent.GetNewSessionAsync(); + +while (true) +{ + // Get user prompt. + Console.WriteLine("Your prompt:"); + string? userInput = Console.ReadLine(); + + if (string.IsNullOrWhiteSpace(userInput)) + break; + + // Send prompt to agent and stream response. + Console.WriteLine("AI response:"); + await foreach (AgentResponseUpdate update in agent.RunStreamingAsync(userInput, session)) + { + Console.Write(update.Text); + } + Console.WriteLine(); +} diff --git a/docs/ai/snippets/prompt-engineering/multi-turn-chat.csproj b/docs/ai/snippets/prompt-engineering/multi-turn-chat.csproj new file mode 100644 index 0000000000000..0e266e5e689b7 --- /dev/null +++ b/docs/ai/snippets/prompt-engineering/multi-turn-chat.csproj @@ -0,0 +1,20 @@ + + + + Exe + net10.0 + enable + enable + MultiTurnChat + + + + + + + + +