@@ -4,7 +4,7 @@ In this example we will create the local file, upload it to Azure and will use i
44
551 . First, we need to create agent client and read the environment variables, which will be used in the next steps.
66
7- ``` C# Snippet:Sample_CreateAgentClient_FileSearch_Streaming
7+ ``` C# Snippet:Sample_CreateAgentClient_FileSearch_Streaming_2
88var projectEndpoint = System .Environment .GetEnvironmentVariable (" PROJECT_ENDPOINT" );
99var modelDeploymentName = System .Environment .GetEnvironmentVariable (" MODEL_DEPLOYMENT_NAME" );
1010AgentClient client = new (endpoint : new Uri (projectEndpoint ), tokenProvider : new DefaultAzureCredential ());
@@ -14,7 +14,7 @@ OpenAIClient openAIClient = client.GetOpenAIClient();
14142 . We will create a toy example file and upload it using OpenAI mechanism.
1515
1616Synchronous sample:
17- ``` C# Snippet:Sample_UploadFile_FileSearch_Streaming_Sync
17+ ``` C# Snippet:Sample_UploadFile_FileSearch_Streaming_Sync_2
1818string filePath = " sample_file_for_upload.txt" ;
1919File .WriteAllText (
2020 path : filePath ,
@@ -25,7 +25,7 @@ File.Delete(filePath);
2525```
2626
2727Asynchronous sample:
28- ``` C# Snippet:Sample_UploadFile_FileSearch_Streaming_Async
28+ ``` C# Snippet:Sample_UploadFile_FileSearch_Streaming_Async_2
2929string filePath = " sample_file_for_upload.txt" ;
3030File .WriteAllText (
3131 path : filePath ,
@@ -38,7 +38,7 @@ File.Delete(filePath);
38383 . Create the ` VectorStore ` and provide it with uploaded file ID.
3939
4040Synchronous sample:
41- ``` C# Snippet:Sample_CreateVectorStore_FileSearch_Streaming_Sync
41+ ``` C# Snippet:Sample_CreateVectorStore_FileSearch_Streaming_Sync_2
4242VectorStoreClient vctStoreClient = openAIClient .GetVectorStoreClient ();
4343VectorStoreCreationOptions options = new ()
4444{
@@ -49,7 +49,7 @@ VectorStore vectorStore = vctStoreClient.CreateVectorStore(options);
4949```
5050
5151Asynchronous sample:
52- ``` C# Snippet:Sample_CreateVectorStore_FileSearch_Streaming_Async
52+ ``` C# Snippet:Sample_CreateVectorStore_FileSearch_Streaming_Async_2
5353VectorStoreClient vctStoreClient = openAIClient .GetVectorStoreClient ();
5454VectorStoreCreationOptions options = new ()
5555{
@@ -62,7 +62,7 @@ VectorStore vectorStore = await vctStoreClient.CreateVectorStoreAsync(options);
62622 . Now we can create an agent capable of using File search.
6363
6464Synchronous sample:
65- ``` C# Snippet:Sample_CreateAgent_FileSearch_Streaming_Sync
65+ ``` C# Snippet:Sample_CreateAgent_FileSearch_Streaming_Sync_2
6666PromptAgentDefinition agentDefinition = new (model : modelDeploymentName )
6767{
6868 Instructions = " You are a helpful agent that can help fetch data from files you know about." ,
@@ -75,7 +75,7 @@ AgentVersion agentVersion = client.CreateAgentVersion(
7575```
7676
7777Asynchronous sample:
78- ``` C# Snippet:Sample_CreateAgent_FileSearch_Streaming_Async
78+ ``` C# Snippet:Sample_CreateAgent_FileSearch_Streaming_Async_2
7979PromptAgentDefinition agentDefinition = new (model : modelDeploymentName )
8080{
8181 Instructions = " You are a helpful agent that can help fetch data from files you know about." ,
@@ -90,7 +90,7 @@ AgentVersion agentVersion = await client.CreateAgentVersionAsync(
90903 . In this example we will ask a question to the file contents.
9191
9292Synchronous sample:
93- ``` C# Snippet:Sample_CreateResponse_FileSearch_Streaming_Sync
93+ ``` C# Snippet:Sample_CreateResponse_FileSearch_Streaming_Sync_2
9494OpenAIResponseClient responseClient = openAIClient .GetOpenAIResponseClient (modelDeploymentName );
9595ResponseCreationOptions responseOptions = new ();
9696ConversationClient conversationClient = client .GetConversationClient ();
@@ -102,7 +102,7 @@ ResponseItem request = ResponseItem.CreateUserMessageItem("Can you give me the d
102102```
103103
104104Asynchronous sample:
105- ``` C# Snippet:Sample_CreateResponse_FileSearch_Streaming_Async
105+ ``` C# Snippet:Sample_CreateResponse_FileSearch_Streaming_Async_2
106106OpenAIResponseClient responseClient = openAIClient .GetOpenAIResponseClient (modelDeploymentName );
107107ResponseCreationOptions responseOptions = new ();
108108ConversationClient conversationClient = client .GetConversationClient ();
@@ -115,7 +115,7 @@ ResponseItem request = ResponseItem.CreateUserMessageItem("Can you give me the d
115115
1161164 . To format streaming response output we will create a helper method ` ParseResponse ` . If the stream ends up in error state, it will throw an error.
117117
118- ``` C# Snippet:Sample_ParseResponse_FileSearch_Streaming
118+ ``` C# Snippet:Sample_ParseResponse_FileSearch_Streaming_2
119119private static void ParseResponse (StreamingResponseUpdate streamResponse )
120120{
121121 if (streamResponse is StreamingResponseCreatedUpdate createUpdate )
@@ -158,15 +158,15 @@ private static void ParseResponse(StreamingResponseUpdate streamResponse)
1581585 . Wait for the stream to complete.
159159
160160Synchronous sample:
161- ``` C# Snippet:Sample_StreamingResponse_FileSearch_Streaming_Sync
161+ ``` C# Snippet:Sample_StreamingResponse_FileSearch_Streaming_Sync_2
162162foreach (StreamingResponseUpdate streamResponse in responseClient .CreateResponseStreaming ([request ], responseOptions ))
163163{
164164 ParseResponse (streamResponse );
165165}
166166```
167167
168168Asynchronous sample:
169- ``` C# Snippet:Sample_StreamingResponse_FileSearch_Streaming_Async
169+ ``` C# Snippet:Sample_StreamingResponse_FileSearch_Streaming_Async_2
170170await foreach (StreamingResponseUpdate streamResponse in responseClient .CreateResponseStreamingAsync ([request ], responseOptions ))
171171{
172172 ParseResponse (streamResponse );
@@ -176,7 +176,7 @@ await foreach (StreamingResponseUpdate streamResponse in responseClient.CreateRe
1761766 . Ask follow up question and start a new stream.
177177
178178Synchronous sample:
179- ``` C# Snippet:Sample_FollowUp_FileSearch_Streaming_Sync
179+ ``` C# Snippet:Sample_FollowUp_FileSearch_Streaming_Sync_2
180180Console .WriteLine (" Demonstrating follow-up query with streaming..." );
181181request = ResponseItem .CreateUserMessageItem (" What was my previous question about?" );
182182foreach (StreamingResponseUpdate streamResponse in responseClient .CreateResponseStreaming ([request ], responseOptions ))
@@ -186,7 +186,7 @@ foreach (StreamingResponseUpdate streamResponse in responseClient.CreateResponse
186186```
187187
188188Asynchronous sample:
189- ``` C# Snippet:Sample_FollowUp_FileSearch_Streaming_Async
189+ ``` C# Snippet:Sample_FollowUp_FileSearch_Streaming_Async_2
190190Console .WriteLine (" Demonstrating follow-up query with streaming..." );
191191request = ResponseItem .CreateUserMessageItem (" What was my previous question about?" );
192192await foreach (StreamingResponseUpdate streamResponse in responseClient .CreateResponseStreamingAsync ([request ], responseOptions ))
@@ -198,14 +198,14 @@ await foreach (StreamingResponseUpdate streamResponse in responseClient.CreateRe
1981985 . Finally, delete all the resources, we have created in this sample.
199199
200200Synchronous sample:
201- ``` C# Snippet:Sample_Cleanup_FileSearch_Streaming_Sync
201+ ``` C# Snippet:Sample_Cleanup_FileSearch_Streaming_Sync_2
202202client .DeleteAgentVersion (agentName : agentVersion .Name , agentVersion : agentVersion .Version );
203203vctStoreClient .DeleteVectorStore (vectorStoreId : vectorStore .Id );
204204fileClient .DeleteFile (uploadedFile .Id );
205205```
206206
207207Asynchronous sample:
208- ``` C# Snippet:Sample_Cleanup_FileSearch_Streaming_Async
208+ ``` C# Snippet:Sample_Cleanup_FileSearch_Streaming_Async_2
209209await client .DeleteAgentVersionAsync (agentName : agentVersion .Name , agentVersion : agentVersion .Version );
210210await vctStoreClient .DeleteVectorStoreAsync (vectorStoreId : vectorStore .Id );
211211await fileClient .DeleteFileAsync (uploadedFile .Id );
0 commit comments