// 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.DedicatedServingMode
				{
					EndpointId = "ocid1.test.oc1..<unique_ID>EXAMPLE-endpointId-Value"
				},
				ChatRequest = new Oci.GenerativeaiinferenceService.Models.CohereChatRequestV2
				{
					Messages = new List<Oci.GenerativeaiinferenceService.Models.CohereMessageV2>
					{
						new Oci.GenerativeaiinferenceService.Models.CohereSystemMessageV2
						{
							Content = new List<Oci.GenerativeaiinferenceService.Models.CohereContentV2>
							{
								new Oci.GenerativeaiinferenceService.Models.CohereImageContentV2
								{
									ImageUrl = new Oci.GenerativeaiinferenceService.Models.CohereImageUrlV2
									{
										Url = "EXAMPLE-url-Value",
										Detail = Oci.GenerativeaiinferenceService.Models.CohereImageUrlV2.DetailEnum.Auto
									}
								}
							}
						}
					},
					Documents = new List<Object>
					{
						"EXAMPLE-documents-Value"
					},
					CitationOptions = new Oci.GenerativeaiinferenceService.Models.CitationOptionsV2
					{
						Mode = Oci.GenerativeaiinferenceService.Models.CitationOptionsV2.ModeEnum.Off
					},
					ToolsChoice = Oci.GenerativeaiinferenceService.Models.CohereChatRequestV2.ToolsChoiceEnum.None,
					Tools = new List<Oci.GenerativeaiinferenceService.Models.CohereToolV2>
					{
						new Oci.GenerativeaiinferenceService.Models.CohereToolV2
						{
							Type = Oci.GenerativeaiinferenceService.Models.CohereToolV2.TypeEnum.Function,
							Function = new Oci.GenerativeaiinferenceService.Models.Function
							{
								Name = "EXAMPLE-name-Value",
								Description = "EXAMPLE-description-Value",
								Parameters = "EXAMPLE-parameters-Value"
							}
						}
					},
					IsStrictToolsEnabled = false,
					IsLogProbsEnabled = true,
					Thinking = new Oci.GenerativeaiinferenceService.Models.CohereThinkingV2
					{
						Type = Oci.GenerativeaiinferenceService.Models.CohereThinkingV2.TypeEnum.Enabled,
						TokenBudget = 407
					},
					ResponseFormat = new Oci.GenerativeaiinferenceService.Models.CohereResponseJsonFormat
					{
						Schema = "EXAMPLE-schema-Value"
					},
					IsSearchQueriesOnly = true,
					StreamOptions = new Oci.GenerativeaiinferenceService.Models.StreamOptions
					{
						IsIncludeUsage = true
					},
					IsStream = false,
					MaxTokens = 676,
					Temperature = 0.8016353,
					TopK = 79,
					TopP = 0.153871,
					FrequencyPenalty = 0.9440276,
					PresencePenalty = 0.3435359,
					Seed = 478,
					StopSequences = new List<string>
					{
						"EXAMPLE--Value"
					},
					Priority = 313,
					IsRawPrompting = true,
					SafetyMode = Oci.GenerativeaiinferenceService.Models.CohereChatRequestV2.SafetyModeEnum.Off
				}
			};
			var chatRequest = new Oci.GenerativeaiinferenceService.Requests.ChatRequest
			{
				ChatDetails = chatDetails,
				OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
				OpcRequestId = "V8SNRFQ3CEC5XR0VQ9K7<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;
            }
        }

    }
}