# 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).
import 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.config.from_file()
# Initialize service client with default config file
generative_ai_inference_client = oci.generative_ai_inference.AsyncGenerativeAiInferenceClient(
config)
# Send the request to service, some parameters are not required, see API
# doc for more info
chat_response = generative_ai_inference_client.chat(
chat_details=oci.generative_ai_inference.models.ChatDetails(
compartment_id="ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
serving_mode=oci.generative_ai_inference.models.DedicatedServingMode(
serving_type="DEDICATED",
endpoint_id="ocid1.test.oc1..<unique_ID>EXAMPLE-endpointId-Value"),
chat_request=oci.generative_ai_inference.models.CohereChatRequestV2(
api_format="COHEREV2",
messages=[
oci.generative_ai_inference.models.CohereToolMessageV2(
role="TOOL",
content=[
oci.generative_ai_inference.models.CohereTextContentV2(
type="TEXT",
text="EXAMPLE-text-Value")],
tool_call_id="ocid1.test.oc1..<unique_ID>EXAMPLE-toolCallId-Value")],
documents=["EXAMPLE-documents-Value"],
citation_options=oci.generative_ai_inference.models.CitationOptionsV2(
mode="FAST"),
tools_choice="NONE",
tools=[
oci.generative_ai_inference.models.CohereToolV2(
type="FUNCTION",
function=oci.generative_ai_inference.models.Function(
name="EXAMPLE-name-Value",
parameters="EXAMPLE-parameters-Value",
description="EXAMPLE-description-Value"))],
is_strict_tools_enabled=False,
is_log_probs_enabled=True,
thinking=oci.generative_ai_inference.models.CohereThinkingV2(
type="DISABLED",
token_budget=154),
response_format=oci.generative_ai_inference.models.CohereResponseTextFormat(
type="TEXT"),
is_search_queries_only=True,
stream_options=oci.generative_ai_inference.models.StreamOptions(
is_include_usage=False),
is_stream=False,
max_tokens=795,
temperature=0.9205316,
top_k=499,
top_p=0.023533046,
frequency_penalty=0.9655093,
presence_penalty=0.53107053,
seed=924,
stop_sequences=["EXAMPLE--Value"],
priority=438,
is_raw_prompting=False,
safety_mode="OFF")),
opc_retry_token="EXAMPLE-opcRetryToken-Value",
opc_request_id="O5XF0DMOTVDLEXAHB33S<unique_ID>")
# Get the data from response
print(chat_response.data)