// 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).

package main

import (
	"context"
	"fmt"

	"github.com/oracle/oci-go-sdk/v65/common"
	"github.com/oracle/oci-go-sdk/v65/example/helpers"
	"github.com/oracle/oci-go-sdk/v65/generativeaiinference"
)

func ExampleChat() {
	// 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.
	client, err := generativeaiinference.NewGenerativeAiInferenceClientWithConfigurationProvider(common.DefaultConfigProvider())
	helpers.FatalIfError(err)

	// Create a request and dependent object(s).
	var schema interface{}
	schema = "EXAMPLE-schema-Value"
	var parameters interface{}
	parameters = "EXAMPLE-parameters-Value"
	req := generativeaiinference.ChatRequest{ChatDetails: generativeaiinference.ChatDetails{CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		ServingMode: generativeaiinference.OnDemandServingMode{ModelId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value")},
		ChatRequest: generativeaiinference.CohereChatRequest{PresencePenalty: common.Float64(0.8330015),
			PromptTruncation:  generativeaiinference.CohereChatRequestPromptTruncationAutoPreserveOrder,
			ResponseFormat:    generativeaiinference.CohereResponseJsonFormat{Schema: &schema},
			Temperature:       common.Float64(0.91363806),
			TopK:              common.Int(19),
			IsForceSingleStep: common.Bool(true),
			Message:           common.String("EXAMPLE-message-Value"),
			PreambleOverride:  common.String("EXAMPLE-preambleOverride-Value"),
			StreamOptions:     &generativeaiinference.StreamOptions{IsIncludeUsage: common.Bool(true)},
			TopP:              common.Float64(0.64706963),
			ChatHistory: []generativeaiinference.CohereMessage{generativeaiinference.CohereChatBotMessage{Message: common.String("EXAMPLE-message-Value"),
				ToolCalls: []generativeaiinference.CohereToolCall{generativeaiinference.CohereToolCall{Name: common.String("EXAMPLE-name-Value"),
					Parameters: &parameters}}}},
			MaxTokens:           common.Int(17),
			IsStream:            common.Bool(true),
			MaxInputTokens:      common.Int(465),
			Seed:                common.Int(999),
			FrequencyPenalty:    common.Float64(0.6347251),
			IsEcho:              common.Bool(false),
			IsSearchQueriesOnly: common.Bool(true),
			SafetyMode:          generativeaiinference.CohereChatRequestSafetyModeOff,
			StopSequences:       []string{"EXAMPLE--Value"},
			ToolResults: []generativeaiinference.CohereToolResult{generativeaiinference.CohereToolResult{Call: &generativeaiinference.CohereToolCall{Name: common.String("EXAMPLE-name-Value"),
				Parameters: &parameters},
				Outputs: []interface{}{"EXAMPLE-outputs-Value"}}},
			Tools: []generativeaiinference.CohereTool{generativeaiinference.CohereTool{Description: common.String("EXAMPLE-description-Value"),
				Name: common.String("EXAMPLE-name-Value"),
				ParameterDefinitions: map[string]generativeaiinference.CohereParameterDefinition{"EXAMPLE_KEY_389H9": generativeaiinference.CohereParameterDefinition{IsRequired: common.Bool(true),
					Type:        common.String("EXAMPLE-type-Value"),
					Description: common.String("EXAMPLE-description-Value")}}}},
			CitationQuality: generativeaiinference.CohereChatRequestCitationQualityAccurate,
			Documents:       []interface{}{"EXAMPLE-documents-Value"},
			IsRawPrompting:  common.Bool(true)}},
		OpcRequestId:  common.String("YTLTWPGKCCX8LUPFY2FC<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value")}

	// Send the request using the service client
	resp, err := client.Chat(context.Background(), req)
	helpers.FatalIfError(err)

	// Retrieve value from the response.
	fmt.Println(resp)
}