Skip to main content

Chat Completions (GPT4)

info

Chat Completion is used along with GPT4 models/deployments. If you are looking for GPT3 model usage through AI SDK, please refer to Completions.

AI Engine and Versions:

  • 2023-03-15-preview
  • 2023-05-15
  • 2023-06-01-preview
  • 2023-07-01-preview
  • 2023-08-01-preview

Demo Program

Program NamePackageDescription
ZP_AISDKDEMO_CHATCOMPL_SIMPLEZPENGG_AZOAI_SDK_DEMOSMSPENG: AI SDK Demo programs - Chat Completions - Simple
tip

Review the demo program along with the content of this page to understand the use of AI SDK feature. The demo program was imported to your SAP Application server as part of AI SDK Installation.

Operations

OperationDescription
CreateWith the Completions operation, the model will generate one or more predicted completions based on a provided prompt. The service can also return the probabilities of alternative tokens at each position.

Using Chat Completion

info

Chat completion only works with deployments of following models:

Model IDMax Request (tokens)
gpt-35-turbo4096
gpt-48,192
gpt-4-32k32,768

Chat Completions - Create

With the Chat Completions operation, the model will generate one or more predicted completions based on a provided prompt. The service can also return the probabilities of alternative tokens at each position.

DATA:
chatcompl_input TYPE zif_peng_azoai_sdk_types=>ty_chatcompletion_input,
chatcompl_output TYPE zif_peng_azoai_sdk_types=>ty_chatcompletion_output.


sdk_instance->chat_completions( )->create(
EXPORTING
deploymentid = deployment_id
prompts = chatcompl_input
IMPORTING
statuscode = status_code
statusreason = status_reason
response = chatcompl_output
error = error
).

Parameters and Exceptions

ParameterDirectionData TypeDescription
deploymentidEXPORTINGstringDeployment ID on which this completion must be run
promptsEXPORTINGChat Completions InputMessages organized by role (system/user/assistant)
statuscodeIMPORTINGIntegerResponse Code.
statusreasonIMPORTINGStringStatus Description/Reason
responseIMPORTINGChat Completions OutputABAP Ready chat completion result.
errorIMPORTINGErrorABAP Ready error structure, if operation resulted in an error

Responses/Status Code

NameTypeStructure PopulatedDescription
200 OKChat Completions OutputresponseSuccess
Other Status CodesErrorerrorAn error occurred.