Chat Completions (GPT4)
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:
- Azure Open AI
- Open AI
- 2023-03-15-preview
- 2023-05-15
- 2023-06-01-preview
- 2023-07-01-preview
- 2023-08-01-preview
- v1
Demo Program
- Azure Open AI
- Open AI
Program Name | Package | Description |
---|---|---|
ZP_AISDKDEMO_CHATCOMPL_SIMPLE | ZPENGG_AZOAI_SDK_DEMOS | MSPENG: AI SDK Demo programs - Chat Completions - Simple |
Program Name | Package | Description |
---|---|---|
ZP_AISDKDEMO_CHTCMPL_SMPL_OAI | ZPENGG_OAI_DEMOS | MS AI SDK for SAP : Demo program for Open AI Chat Completions |
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
Operation | Description |
---|---|
Create | With 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
Chat completion only works with deployments of following models:
- Azure Open AI
- Open AI
Model ID | Max Request (tokens) |
---|---|
gpt-35-turbo | 4096 |
gpt-4 | 8,192 |
gpt-4-32k | 32,768 |
Model ID | Max Request (tokens) |
---|---|
gpt-3.5-turbo | 4096 |
gpt-4 | 8,192 |
gpt-4-32k | 32,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
- Parameters
- Exceptions
Parameter | Direction | Data Type | Description |
---|---|---|---|
deploymentid | EXPORTING | string | Deployment ID on which this completion must be run |
prompts | EXPORTING | Chat Completions Input | Messages organized by role (system/user/assistant) |
statuscode | IMPORTING | Integer | Response Code. |
statusreason | IMPORTING | String | Status Description/Reason |
response | IMPORTING | Chat Completions Output | ABAP Ready chat completion result. |
error | IMPORTING | Error | ABAP Ready error structure, if operation resulted in an error |
ZCX_PENG_AZOAI_SDK_EXCEPTION - Raised if an error occured during processing.
The exception is not raised if an error occured during AI Engine processing. In such situations, the ov_error parameter will provide error details. The exception is raised only if SDK encouters a situation where it cannot proceed with the requested operation.
Responses/Status Code
Name | Type | Structure Populated | Description |
---|---|---|---|
200 OK | Chat Completions Output | response | Success |
Other Status Codes | Error | error | An error occurred. |