// 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 document interface{}
document = "EXAMPLE-document-Value"
var parameters interface{}
parameters = "EXAMPLE-parameters-Value"
req := generativeaiinference.ChatRequest{ChatDetails: generativeaiinference.ChatDetails{ChatRequest: generativeaiinference.CohereChatRequestV2{TopP: common.Float64(0.30801296),
Documents: []interface{}{"EXAMPLE-documents-Value"},
IsRawPrompting: common.Bool(true),
IsStrictToolsEnabled: common.Bool(true),
FrequencyPenalty: common.Float64(0.90215766),
IsLogProbsEnabled: common.Bool(false),
MaxTokens: common.Int(887),
Messages: []generativeaiinference.CohereMessageV2{generativeaiinference.CohereToolMessageV2{ToolCallId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-toolCallId-Value"),
Content: []generativeaiinference.CohereContentV2{generativeaiinference.CohereDocumentContentV2{Document: &document}}}},
PresencePenalty: common.Float64(0.7918264),
Priority: common.Int(404),
Seed: common.Int(937),
StopSequences: []string{"EXAMPLE--Value"},
IsSearchQueriesOnly: common.Bool(false),
SafetyMode: generativeaiinference.CohereChatRequestV2SafetyModeOff,
Temperature: common.Float64(0.13406122),
Thinking: &generativeaiinference.CohereThinkingV2{TokenBudget: common.Int(203),
Type: generativeaiinference.CohereThinkingV2TypeDisabled},
Tools: []generativeaiinference.CohereToolV2{generativeaiinference.CohereToolV2{Function: &generativeaiinference.Function{Description: common.String("EXAMPLE-description-Value"),
Name: common.String("EXAMPLE-name-Value"),
Parameters: ¶meters},
Type: generativeaiinference.CohereToolV2TypeFunction}},
ToolsChoice: generativeaiinference.CohereChatRequestV2ToolsChoiceRequired,
TopK: common.Int(36),
CitationOptions: &generativeaiinference.CitationOptionsV2{Mode: generativeaiinference.CitationOptionsV2ModeFast},
IsStream: common.Bool(true),
ResponseFormat: generativeaiinference.CohereResponseTextFormat{},
StreamOptions: &generativeaiinference.StreamOptions{IsIncludeUsage: common.Bool(false)}},
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")}},
OpcRequestId: common.String("NOYUHSDU8YXMQ1XEONMW<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)
}