This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static async Task Main(string[] args) | |
| { | |
| string endpoint = "<azure-openi-key>"; | |
| string key = "<azure-openi-endpoint>"; | |
| string deploymentName = "gpt-4o"; | |
| var azureOpenAIClient = new AzureOpenAIClient(new Uri(endpoint), new ApiKeyCredential(key)); | |
| //get userQuestion from the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "functions": [{ | |
| "name": "search_microsoft365_documents", | |
| "description": "Search the Microsfot 365 documents from user's SharePoint and OneDrive", | |
| "parameters": { | |
| "type": "object", | |
| "required": ["searchQuery"], | |
| "properties": { | |
| "searchQuery": { | |
| "type": "string", | |
| "description": "the text to search in the documents to get the required information" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var azureClient = new AzureOpenAIClient(new Uri(endpoint), new ApiKeyCredential(key)); | |
| OpenAIFileClient fileClient = azureClient.GetOpenAIFileClient(); | |
| AssistantClient assistantClient = azureClient.GetAssistantClient(); | |
| OpenAIFile infoFile = await fileClient.UploadFileAsync("C:\\Users\\vardh\\Documents\\Customers.xlsx", FileUploadPurpose.Assistants); | |
| AssistantCreationOptions assistantOptions = new() | |
| { | |
| Name = "CodeInterpreterProMAX", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var azureClient = new AzureOpenAIClient(new Uri(endpoint), new ApiKeyCredential(key)); | |
| OpenAIFileClient fileClient = azureClient.GetOpenAIFileClient(); | |
| AssistantClient assistantClient = azureClient.GetAssistantClient(); | |
| OpenAIFile infoFile = await fileClient.UploadFileAsync("C:\\Customers.xlsx", FileUploadPurpose.Assistants); | |
| AssistantCreationOptions assistantOptions = new() | |
| { | |
| Name = "CodeInterpreterProMAX", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string endpoint = "https://<myopenaiservice>.openai.azure.com/"; | |
| string key = "<my-open-ai-service-key>"; | |
| string deploymentName = "gpt-4o"; | |
| var azureClient = new AzureOpenAIClient(new Uri(endpoint), new ApiKeyCredential(key)); | |
| OpenAIFileClient fileClient = azureClient.GetOpenAIFileClient(); | |
| AssistantClient assistantClient = azureClient.GetAssistantClient(); | |
| VectorStoreClient vectorClient = azureClient.GetVectorStoreClient(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string endpoint = "https://<myopenaiservice>.openai.azure.com/"; | |
| string key = "<my-open-ai-service-key>"; | |
| string deploymentName = "gpt-4o"; | |
| //We are using the Azure OpenAI Service so create an Azure OpenAI client | |
| var azureClient = new AzureOpenAIClient(new Uri(endpoint), new ApiKeyCredential(key)); | |
| AssistantClient assistantClient = azureClient.GetAssistantClient(); | |
| //Create assistant | |
| AssistantCreationOptions assistantOptions = new() | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var chatClient = openAiClient.GetChatClient(deploymentName); | |
| List<ChatMessage> messages = [ | |
| new UserChatMessage( | |
| ChatMessageContentPart.CreateImageMessageContentPart( | |
| new Uri("https://dalleprodsec.blob.core.windows.net/private/images/generated_00.png"), | |
| ImageChatMessageContentPartDetail.High) | |
| ), | |
| new UserChatMessage( | |
| ChatMessageContentPart.CreateImageMessageContentPart( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var chatClient = openAiClient.GetChatClient(deploymentName); | |
| string dataURI = "data:image/jpeg;base64,<long-data-uri-of-image>"; | |
| //convert data uri to binary data | |
| byte[] binaryData = Convert.FromBase64String(dataURI.Split(',')[1]); | |
| List<ChatMessage> messages = [ | |
| new UserChatMessage( | |
| ChatMessageContentPart.CreateImageMessageContentPart(BinaryData.FromBytes(binaryData), "image/jpeg", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var chatClient = openAiClient.GetChatClient(deploymentName); | |
| List<ChatMessage> messages = [ | |
| new UserChatMessage( | |
| ChatMessageContentPart.CreateImageMessageContentPart(BinaryData.FromStream(File.OpenRead("C:\\images\\ROBOT ASTRONAUT .png")), "image/jpg" , | |
| ImageChatMessageContentPartDetail.High) | |
| ), | |
| new UserChatMessage("What is in this image?") | |
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var chatClient = openAiClient.GetChatClient(deploymentName); | |
| List<ChatMessage> messages = [ | |
| new UserChatMessage( | |
| ChatMessageContentPart.CreateImageMessageContentPart( | |
| new Uri("https://www.allrecipes.com/thmb/HbnN9fkzDBmzI83sbxOhtbfEQUE=/750x0/filters:no_upscale():max_bytes(150000):strip_icc():format(webp)/AR-15022-veggie-pizza-DDMFS-4x3-step-01-a32ad6054e974ecd9f79c8627bc9e811.jpg"), | |
| ImageChatMessageContentPartDetail.High) | |
| ), | |
| new UserChatMessage("What can I cook with these ingredients?"), | |
| ]; |