Skip to content

Commit f7a7972

Browse files
authored
Merge pull request #1580 from sdgilley/sdg-main-sdk-overview
Add zone pivots
2 parents 5b674f2 + f53fe95 commit f7a7972

File tree

3 files changed

+181
-22
lines changed

3 files changed

+181
-22
lines changed

.openpublishing.publish.config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@
110110
"branch": "dantaylo/nov2024",
111111
"branch_mapping": {}
112112
},
113+
{
114+
"path_to_root": "azureai-samples-csharp",
115+
"url": "https://github.com/Azure-Samples/azureai-samples",
116+
"branch": "dantaylo/csharp",
117+
"branch_mapping": {}
118+
},
113119
{
114120
"path_to_root": "azureml-examples-main",
115121
"url": "https://github.com/azure/azureml-examples",

articles/ai-studio/how-to/develop/sdk-overview.md

Lines changed: 165 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,24 @@ ms.date: 11/19/2024
1212
ms.reviewer: dantaylo
1313
ms.author: sgilley
1414
author: sdgilley
15+
zone_pivot_groups: programming-languages-sdk-overview
16+
# customer intent: I want to learn how to use the Azure AI Foundry SDK to build AI applications on Azure.
1517
---
1618

1719
# The Azure AI Foundry SDK
1820

1921
The Azure AI Foundry SDK is a comprehensive toolchain designed to simplify the development of AI applications on Azure. It enables developers to:
2022

21-
- Access popular models from various model providers through a single interface
22-
- Easily combine together models, data, and AI services to build AI-powered applications
23-
- Evaluate, debug, and improve application quality & safety across development, testing, and production environments
23+
- Access popular models from various model providers through a single interface
24+
- Easily combine together models, data, and AI services to build AI-powered applications
25+
- Evaluate, debug, and improve application quality & safety across development, testing, and production environments
2426

2527
The AI Foundry SDK is a set of packages and services designed to work together. You can use the Azure AI Projects client library to easily use multiple services through a single project client and connection string. You can also use services and SDKs on their own and connect directly to your services.
2628

2729
If you want to jump right in and start building an app, check out:
28-
- [Create a chat app](../../quickstarts/get-started-code.md)
29-
- [Create a custom RAG app](../../tutorials/copilot-sdk-create-resources.md)
30+
31+
- [Create a chat app](../../quickstarts/get-started-code.md)
32+
- [Create a custom RAG app](../../tutorials/copilot-sdk-create-resources.md)
3033

3134
## Get started with Projects
3235

@@ -36,13 +39,15 @@ First follow steps to [create an AI Project](../create-projects.md) if you don't
3639

3740
Sign in with the Azure CLI using the same account that you use to access your AI Project:
3841

39-
```
42+
```bash
4043
az login
4144
```
4245

4346
Install the Azure AI projects client library:
4447

45-
```
48+
::: zone pivot="programming-language-python"
49+
50+
```bash
4651
pip install azure-ai-projects azure-identity
4752
```
4853

@@ -76,22 +81,64 @@ project = await AIProjectClient.from_connection_string(
7681

7782
---
7883

79-
Copy the **Project connection string** from the **Overview** page of the project and update the `project_connection_string` variable above.
84+
::: zone-end
85+
86+
::: zone pivot="programming-language-csharp"
87+
88+
```dotnet
89+
dotnet add package Azure.AI.Projects
90+
dotnet add package Azure.Identity
91+
```
92+
93+
Add using statements:
94+
95+
```csharp
96+
using Azure.Identity;
97+
using Azure.AI.Projects;
98+
```
99+
100+
Create a project client in code:
101+
102+
# [Sync](#tab/sync)
103+
104+
:::code language="csharp" source="~/azureai-samples-csharp/scenarios/projects/basic-csharp/Program.cs" id="snippet_get_project":::
105+
106+
# [Async](#tab/async)
80107

81-
Once you have created the project client, you can use the client for the capabilities in the following sections.
108+
Not yet available in C#.
109+
110+
::: zone-end
111+
112+
Copy the **Project connection string** from the **Overview** page of the project and update the connections string value above.
113+
114+
Once you have created the project client, you can use the client for the capabilities in the following sections.
115+
116+
::: zone pivot="programming-language-python"
82117

83118
Be sure to check out the [reference](https://aka.ms/aifoundrysdk/reference) and [samples](https://aka.ms/azsdk/azure-ai-projects/python/samples).
84119

120+
::: zone-end
121+
122+
::: zone pivot="programming-language-csharp"
123+
124+
Be sure to check out the [reference](https://aka.ms/aifoundrysdk/reference) and [samples](https://aka.ms/azsdk/azure-ai-projects/csharp/samples).
125+
126+
::: zone-end
127+
85128
## Azure OpenAI Service
86129

87130
The [Azure OpenAI Service](../../../ai-services/openai/overview.md) provides access to OpenAI's models including the GPT-4o, GPT-4o mini, GPT-4, GPT-4 Turbo with Vision, DALLE-3, Whisper, and Embeddings model series with the data residency, scalability, safety, security and enterprise capabilities of Azure.
88131

89132
If you have code that uses the OpenAI SDK, you can easily target your code to use the Azure OpenAI service. First, install the OpenAI SDK:
90-
```
133+
134+
::: zone pivot="programming-language-python"
135+
136+
```bash
91137
pip install openai
92138
```
93139

94-
If you have existing code that uses the OpenAI SDK, you can use the project client to create an ```AzureOpenAI``` client that uses your project's Azure OpenAI connection:
140+
If you have existing code that uses the OpenAI SDK, you can use the project client to create an `AzureOpenAI` client that uses your project's Azure OpenAI connection:
141+
95142
```Python
96143
openai = project.inference.get_azure_openai_client(api_version="2024-06-01")
97144
response = openai.chat.completions.create(
@@ -104,22 +151,45 @@ response = openai.chat.completions.create(
104151

105152
print(response.choices[0].message.content)
106153
```
107-
If you’re already using the [Azure OpenAI SDK](../../../ai-services/openai/chatgpt-quickstart.md) directly against the Azure OpenAI Service, the project provides a convenient way to use Azure OpenAI Service capabilities alongside the rest of the AI Foundry capabilities.
108154

155+
::: zone-end
156+
157+
::: zone pivot="programming-language-csharp"
158+
159+
```dotnet
160+
dotnet add package Azure.AI.OpenAI
161+
```
162+
163+
Add using statements:
164+
165+
```csharp
166+
using OpenAI.Chat;
167+
using Azure.AI.OpenAI;
168+
```
169+
170+
If you have existing code that uses the OpenAI SDK, you can use the project client to create an `AzureOpenAI` client that uses your project's Azure OpenAI connection:
171+
172+
:::code language="csharp" source="~/azureai-samples-csharp/scenarios/projects/basic-csharp/Program.cs" id="azure_openai":::
173+
174+
::: zone-end
175+
176+
If you’re already using the [Azure OpenAI SDK](../../../ai-services/openai/chatgpt-quickstart.md) directly against the Azure OpenAI Service, the project provides a convenient way to use Azure OpenAI Service capabilities alongside the rest of the AI Foundry capabilities.
109177

110178
## Azure AI model inference service
111179

112180
The [Azure AI model inference service](/azure/ai-studio/ai-services/model-inference) offers access to powerful models from leading providers like OpenAI, Microsoft, Meta, and more. These models support tasks such as content generation, summarization, and code generation.
113181

114182
To use the model inference service, first ensure that your project has an AI Services connection (in the management center).
115183

116-
Install the ```azure-ai-inferencing``` client library:
184+
Install the `azure-ai-inferencing` client library:
117185

118-
```
186+
::: zone pivot="programming-language-python"
187+
188+
```bash
119189
pip install azure-ai-inference
120190
```
121191

122-
You can use the project client to get a configured and authenticated ```ChatCompletionsClient``` or ```EmbeddingsClient```:
192+
You can use the project client to get a configured and authenticated `ChatCompletionsClient` or `EmbeddingsClient`:
123193

124194
```Python
125195
# get an chat inferencing client using the project's default model inferencing endpoint
@@ -137,17 +207,39 @@ response = chat.complete(
137207
print(response.choices[0].message.content)
138208
```
139209

210+
::: zone-end
211+
212+
::: zone pivot="programming-language-csharp"
213+
214+
```dotnet
215+
dotnet add package Azure.AI.Inference
216+
```
217+
218+
Add using statements:
219+
220+
```csharp
221+
using Azure.AI.Inference;
222+
```
223+
224+
You can use the project client to get a configured and authenticated `ChatCompletionsClient` or `EmbeddingsClient`:
225+
226+
:::code language="csharp" source="~/azureai-samples-csharp/scenarios/projects/basic-csharp/Program.cs" id="snippet_inference":::
227+
228+
::: zone-end
229+
140230
You can change the model name to any model that you deployed to the inference service or Azure OpenAI service.
141231

142232
To learn more about using the Azure AI inferencing client, check out the [Azure AI model inferencing reference](/azure/ai-studio/reference/reference-model-inference-api).
143233

234+
::: zone pivot="programming-language-python"
235+
144236
## Prompt Templates
145237

146238
The inferencing client supports for creating prompt messages from templates. The template allows you to dynamically generate prompts using inputs that are available at runtime.
147239

148240
To use prompt templates, install the `azure-ai-inferencing` package:
149241

150-
```
242+
```bash
151243
pip install azure-ai-inference
152244
```
153245

@@ -198,13 +290,17 @@ response = chat.complete(
198290
)
199291
```
200292

293+
::: zone-end
294+
201295
## Azure AI Search
202296

203-
If you have an Azure AI Search resource connected to your project, you can also use the project client to create an Azure AI Search client using the project connection.
297+
If you have an Azure AI Search resource connected to your project, you can also use the project client to create an Azure AI Search client using the project connection.
204298

205299
Install the Azure AI Search client library:
206300

207-
```
301+
::: zone pivot="programming-language-python"
302+
303+
```bash
208304
pip install azure-search-documents
209305
```
210306

@@ -235,22 +331,48 @@ search_client = SearchClient(
235331
)
236332
```
237333

334+
::: zone-end
335+
336+
::: zone pivot="programming-language-csharp"
337+
338+
```dotnet
339+
dotnet add package Azure.Search.Documents
340+
```
341+
342+
Add using statements:
343+
344+
```csharp
345+
using Azure.Search.Documents;
346+
using Azure.Search.Documents.Models;
347+
```
348+
349+
Instantiate the search and/or search index client as desired:
350+
351+
:::code language="csharp" source="~/azureai-samples-csharp/scenarios/projects/basic-csharp/Program.cs" id="azure_aisearch":::
352+
353+
::: zone-end
354+
238355
To learn more about using Azure AI Search, check out [Azure AI Search documentation](/azure/search/).
239356

240-
## Azure AI agents runtime
357+
## Azure AI Agent Service
241358

242359
Azure AI Agent Service is a fully managed service designed to empower developers to securely build, deploy, and scale high-quality, and extensible AI agents. Using an extensive ecosystem of models, tools and capabilities from OpenAI, Microsoft, and third-party providers, Azure AI Agent Service enables building agents for a wide range of generative AI use cases.
243360

244-
To get access to agents, [sign-up for the private preview](https://nam.dcv.ms/nzy5CEG6Br).
361+
To get access to agents, [sign-up for the preview](https://nam.dcv.ms/nzy5CEG6Br).
245362

246363
## Evaluation
247364

365+
::: zone pivot="programming-language-python"
366+
248367
You can use the project client to easily connect to the Azure AI evaluation service, and models needed for running your evaluators.
368+
369+
249370
```
250371
pip install azure-ai-evaluation
251372
```
252373

253-
Using the ```project.scope``` parameter, we can instantiate a ```ViolenceEvaluator```:
374+
Using the `project.scope` parameter, we can instantiate a `ViolenceEvaluator`:
375+
254376
```Python
255377
from azure.ai.evaluation import ViolenceEvaluator
256378
from azure.identity import DefaultAzureCredential
@@ -264,20 +386,34 @@ violence_eval = ViolenceEvaluator(
264386
violence_score = violence_eval(query="what's the capital of france", response="Paris")
265387
print(violence_score)
266388
```
389+
267390
NOTE: to run violence evaluators your project needs to be in East US 2, Sweden Central, US North Central, France Central.
268391

269392
To learn more, check out [Evaluation using the SDK](evaluate-sdk.md).
270393

394+
::: zone-end
395+
396+
::: zone pivot="programming-language-csharp"
397+
398+
An Azure AI evaluation package is not yet available for C#. For a sample on how to use Prompty and Semantic Kernel for evaluation, see the [contoso-chat-csharp-prompty](https://github.com/Azure-Samples/contoso-chat-csharp-prompty/blob/main/src/ContosoChatAPI/ContosoChat.Evaluation.Tests/Evalutate.cs) sample.
399+
400+
::: zone-end
401+
402+
271403
## Tracing
272404

405+
::: zone pivot="programming-language-python"
406+
273407
To enable tracing, first ensure your project has an attached Application Insights resource. Go to the **Tracing** page of your project and follow instructions to create or attach Application Insights.
274408

275409
Install the Azure Monitor OpenTelemetry package:
410+
276411
```
277412
pip install azure-monitor-opentelemetry
278413
```
279414

280415
Use the following code to enable instrumentation of the Azure AI Inference SDK and logging to your AI project:
416+
281417
```Python
282418
# Enable instrumentation of AI packages (inference, agents, openai, langchain)
283419
project.telemetry.enable()
@@ -288,6 +424,14 @@ if application_insights_connection_string:
288424
configure_azure_monitor(connection_string=application_insights_connection_string)
289425
```
290426

427+
::: zone-end
428+
429+
::: zone pivot="programming-language-csharp"
430+
431+
Tracing is not yet integrated into the projects package. For instructions on how to instrument and log traces from the Azure AI Inferencing package, see [azure-sdk-for-dotnet](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/ai/Azure.AI.Inference/samples/Sample8_ChatCompletionsWithOpenTelemetry.md.).
432+
433+
::: zone-end
434+
291435
## Related content
292436

293437
Below are some helpful links to other services and frameworks that you can use with the Azure AI Foundry SDK.

zone-pivots/zone-pivot-groups.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,4 +916,13 @@ groups:
916916
- id: programming-language-ai-studio
917917
title: AI Studio
918918
- id: programming-language-javascript
919-
title: JavaScript
919+
title: JavaScript
920+
# owner: sgilley
921+
- id: programming-languages-sdk-overview
922+
title: Programming languages
923+
prompt: Choose one of the client library languages.
924+
pivots:
925+
- id: programming-language-python
926+
title: Python
927+
- id: programming-language-csharp
928+
title: C#

0 commit comments

Comments
 (0)