# 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).
require 'oci'
# Create a default config using DEFAULT profile in default location
# Refer to https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File for more info
config = OCI::ConfigFileLoader.load_config
# Initialize service client with default config file
generative_ai_inference_client =
OCI::GenerativeAiInference::GenerativeAiInferenceClient.new(config: config)
# Send the request to service, some parameters are not required, see API doc for more info
chat_response =
generative_ai_inference_client.chat(
OCI::GenerativeAiInference::Models::ChatDetails.new(
compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
serving_mode:
OCI::GenerativeAiInference::Models::OnDemandServingMode.new(
serving_type: 'ON_DEMAND',
model_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value'
),
chat_request:
OCI::GenerativeAiInference::Models::GenericChatRequest.new(
api_format: 'GENERIC',
messages: [
OCI::GenerativeAiInference::Models::UserMessage.new(
role: 'USER',
content: [
OCI::GenerativeAiInference::Models::ImageContent.new(
type: 'IMAGE',
image_url:
OCI::GenerativeAiInference::Models::ImageUrl.new(
url: 'EXAMPLE-url-Value', detail: 'AUTO'
)
)
],
name: 'EXAMPLE-name-Value'
)
],
reasoning_effort: 'MINIMAL',
verbosity: 'LOW',
metadata: 'EXAMPLE-metadata-Value',
is_stream: false,
stream_options:
OCI::GenerativeAiInference::Models::StreamOptions.new(
is_include_usage: false
),
num_generations: 1,
seed: 466,
is_echo: false,
top_k: 0,
top_p: 0.6882889,
temperature: 0.88353145,
frequency_penalty: 1.8963226,
presence_penalty: 0.5661726,
stop: %w[EXAMPLE--Value],
log_probs: 351,
max_tokens: 275,
max_completion_tokens: 199,
logit_bias: 'EXAMPLE-logitBias-Value',
prediction:
OCI::GenerativeAiInference::Models::StaticContent.new(
type: 'CONTENT',
content: [
OCI::GenerativeAiInference::Models::TextContent.new(
type: 'TEXT', text: 'EXAMPLE-text-Value'
)
]
),
response_format:
OCI::GenerativeAiInference::Models::JsonSchemaResponseFormat.new(
type: 'JSON_SCHEMA',
json_schema:
OCI::GenerativeAiInference::Models::ResponseJsonSchema.new(
name: 'EXAMPLE-name-Value',
description: 'EXAMPLE-description-Value',
schema: 'EXAMPLE-schema-Value',
is_strict: false
)
),
tool_choice:
OCI::GenerativeAiInference::Models::ToolChoiceFunction.new(
type: 'FUNCTION', name: 'EXAMPLE-name-Value'
),
is_parallel_tool_calls: false,
tools: [
OCI::GenerativeAiInference::Models::FunctionDefinition.new(
type: 'FUNCTION',
name: 'EXAMPLE-name-Value',
description: 'EXAMPLE-description-Value',
parameters: 'EXAMPLE-parameters-Value'
)
],
web_search_options:
OCI::GenerativeAiInference::Models::WebSearchOptions.new(
search_context_size: 'LOW',
user_location:
OCI::GenerativeAiInference::Models::ApproximateLocation.new(
city: 'EXAMPLE-city-Value',
region: 'EXAMPLE-region-Value',
country: 'Hl',
timezone: 'EXAMPLE-timezone-Value'
)
),
service_tier: 'DEFAULT'
)
)
)
# Get the data from response
puts "#{chat_response.data}"