// This is an automatically generated code sample. 
// To make this code sample work in your Oracle Cloud tenancy, 
// please replace the values for any parameters whose current values do not fit
// your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and 
// boolean, number, and enum parameters with values not fitting your use case).

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oci.GenerativeaiinferenceService;
using Oci.Common;
using Oci.Common.Auth;

namespace Oci.Sdk.DotNet.Example.Generativeaiinference
{
    public class ChatExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var chatDetails = new Oci.GenerativeaiinferenceService.Models.ChatDetails
			{
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				ServingMode = new Oci.GenerativeaiinferenceService.Models.OnDemandServingMode
				{
					ModelId = "ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value"
				},
				ChatRequest = new Oci.GenerativeaiinferenceService.Models.GenericChatRequest
				{
					Messages = new List<Oci.GenerativeaiinferenceService.Models.Message>
					{
						new Oci.GenerativeaiinferenceService.Models.ToolMessage
						{
							ToolCallId = "ocid1.test.oc1..<unique_ID>EXAMPLE-toolCallId-Value",
							Content = new List<Oci.GenerativeaiinferenceService.Models.ChatContent>
							{
								new Oci.GenerativeaiinferenceService.Models.ImageContent
								{
									ImageUrl = new Oci.GenerativeaiinferenceService.Models.ImageUrl
									{
										Url = "EXAMPLE-url-Value",
										Detail = Oci.GenerativeaiinferenceService.Models.ImageUrl.DetailEnum.Low
									}
								}
							}
						}
					},
					ReasoningEffort = Oci.GenerativeaiinferenceService.Models.GenericChatRequest.ReasoningEffortEnum.Medium,
					Verbosity = Oci.GenerativeaiinferenceService.Models.GenericChatRequest.VerbosityEnum.Low,
					Metadata = "EXAMPLE-metadata-Value",
					IsStream = false,
					StreamOptions = new Oci.GenerativeaiinferenceService.Models.StreamOptions
					{
						IsIncludeUsage = true
					},
					NumGenerations = 2,
					Seed = 691,
					IsEcho = false,
					TopK = 0,
					TopP = 0.42572474,
					Temperature = 0.047066092,
					FrequencyPenalty = 1.9310186,
					PresencePenalty = 1.0621411,
					Stop = new List<string>
					{
						"EXAMPLE--Value"
					},
					LogProbs = 924,
					MaxTokens = 508,
					MaxCompletionTokens = 65,
					LogitBias = "EXAMPLE-logitBias-Value",
					Prediction = new Oci.GenerativeaiinferenceService.Models.StaticContent
					{
						Content = new List<Oci.GenerativeaiinferenceService.Models.TextContent>
						{
							new Oci.GenerativeaiinferenceService.Models.TextContent
							{
								Text = "EXAMPLE-text-Value"
							}
						}
					},
					ResponseFormat = new Oci.GenerativeaiinferenceService.Models.JsonObjectResponseFormat
					{
					},
					ToolChoice = new Oci.GenerativeaiinferenceService.Models.ToolChoiceFunction
					{
						Name = "EXAMPLE-name-Value"
					},
					IsParallelToolCalls = false,
					Tools = new List<Oci.GenerativeaiinferenceService.Models.ToolDefinition>
					{
						new Oci.GenerativeaiinferenceService.Models.FunctionDefinition
						{
							Name = "EXAMPLE-name-Value",
							Description = "EXAMPLE-description-Value",
							Parameters = "EXAMPLE-parameters-Value"
						}
					},
					WebSearchOptions = new Oci.GenerativeaiinferenceService.Models.WebSearchOptions
					{
						SearchContextSize = Oci.GenerativeaiinferenceService.Models.WebSearchOptions.SearchContextSizeEnum.Medium,
						UserLocation = new Oci.GenerativeaiinferenceService.Models.ApproximateLocation
						{
							City = "EXAMPLE-city-Value",
							Region = "EXAMPLE-region-Value",
							Country = "kP",
							Timezone = "EXAMPLE-timezone-Value"
						}
					},
					ServiceTier = Oci.GenerativeaiinferenceService.Models.GenericChatRequest.ServiceTierEnum.Priority
				}
			};
			var chatRequest = new Oci.GenerativeaiinferenceService.Requests.ChatRequest
			{
				ChatDetails = chatDetails,
				OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
				OpcRequestId = "01F8ZU5VSK2GAJPZXNSY<unique_ID>"
			};

            // Create a default authentication provider that uses the DEFAULT
            // profile in the configuration file.
            // Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file. 
            var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
            try
            {
                // Create a service client and send the request.
				using (var client = new GenerativeAiInferenceClient(provider, new ClientConfiguration()))
				{
					var response = await client.Chat(chatRequest);
					// Retrieve value from the response.
					var modelIdValue = response.ChatResult.ModelId;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"Chat Failed with {e.Message}");
                throw e;
            }
        }

    }
}