AI SDK for SAP Files Overview
AI Engine and Versions:
- Azure Open AI
- Open AI
- 2022-12-01
- 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_MSAISDKDEMO_FILES | ZPENGG_AZOAI_SDK_DEMOS | MS AI SDK for SAP : Demo Program for Files |
Program Name | Package | Description |
---|---|---|
ZP_MSAISDKDEMO_FILES_OAI | ZPENGG_OAI_DEMOS | MS AI SDK for SAP : Demo program for Open AI Files |
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 |
---|---|
Delete | Deletes the file with the given file-id. Deletion is also allowed if a file was used, e.g., as training file in a fine-tune job. |
Get | Gets details for a single file specified by the given file-id including status, size, purpose, etc. |
Get Content | Gets the content of the file specified by the given file-id. Files can be user uploaded content or generated by the service like result metrics of a fine-tune job. |
Import | Creates a new file entity by importing data from a provided url. Uploaded files can, for example, be used for training or evaluating fine-tuned models. |
List | Gets a list of all files owned by the Azure OpenAI resource |
Upload | Creates a new file entity by uploading data from ABAP Application Server. Uploaded files can, for example, be used for training or evaluating fine-tuned models. |
Files - Delete
Deletes the file with the given file-id. Deletion is also allowed if a file was used, e.g., as training file in a fine-tune job.
sdk_instance->files( )->delete(
EXPORTING
fileid = file_id " The identifier of the file.
IMPORTING
statuscode = status_code " Status Code
statusreason = status_reason " HTTP status description
error = error " ABAP Ready error details
).
Parameters and Exceptions
- Parameters
- Exceptions
Parameter | Direction | Data Type | Description |
---|---|---|---|
fileid | EXPORTING | string | The identifier of the file. |
statuscode | IMPORTING | Integer | Response Code. |
statusreason | IMPORTING | String | Status Description/Reason |
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 |
---|---|---|---|
204 No Content | The file was successfully deleted. | ||
Other Status Codes | Error | error | An error occurred. |
Files - Get
Gets details for a single file specified by the given file-id including status, size, purpose, etc.
DATA:
get_file_info TYPE zif_peng_azoai_sdk_types=>ty_file_get.
sdk_instance->files( )->get(
EXPORTING
fileid = file_id " The identifier of the file.
IMPORTING
statuscode = status_code " Status Code
statusreason = status_reason " HTTP status description
file = get_file_info " ABAP Ready File Information
error = error " ABAP Ready error details
).
Parameters and Exceptions
- Parameters
- Exceptions
Parameter | Direction | Data Type | Description |
---|---|---|---|
fileid | EXPORTING | string | The identifier of the file. |
statuscode | IMPORTING | Integer | Response Code. |
statusreason | IMPORTING | String | Status Description/Reason |
file | IMPORTING | File | ABAP Ready File Information |
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 | File | file | Success |
Other Status Codes | Error | error | An error occurred. |
Files - Get Content
Gets the content of the file specified by the given file-id. Files can be user uploaded content or generated by the service like result metrics of a fine-tune job.
DATA:
file_content TYPE string.
sdk_instance->files( )->get_content(
EXPORTING
fileid = uploaded_file_info-id " The identifier of the file.
IMPORTING
statuscode = status_code " Status Code
statusreason = status_reason " HTTP status description
content = file_content " Content of the file
error = error " ABAP Ready error details
).
Parameters and Exceptions
- Parameters
- Exceptions
Parameter | Direction | Data Type | Description |
---|---|---|---|
fileid | EXPORTING | string | The identifier of the file. |
statuscode | IMPORTING | Integer | Response Code. |
statusreason | IMPORTING | String | Status Description/Reason |
content | IMPORTING | string | Content of the file as string |
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 | string | content | Success |
Other Status Codes | Error | error | An error occurred. |
Files - Import
Creates a new file entity by importing data from a provided url. Imported files can, for example, be used for training or evaluating fine-tuned models.
DATA:
import_location TYPE zif_peng_azoai_sdk_types=>ty_file_import,
imported_file_info TYPE zif_peng_azoai_sdk_types=>ty_file_get.
"Specify location of file to import.
import_location-content_url = 'https://www.testfile.com/puppy.jsonl'.
"Specify what to name the file in AI Engine portal.
import_location-filename = 'Demo_File_Import.jsonl'.
"Perform the import operation.
sdk_instance->files( )->import(
EXPORTING
import_info = import_location
IMPORTING
statuscode = status_code " Status Code
statusreason = status_reason " HTTP status description
file = imported_file_info " ABAP Ready Imported File Information
error = error " ABAP Ready error details
).
Parameters and Exceptions
- Parameters
- Exceptions
Parameter | Direction | Data Type | Description |
---|---|---|---|
import_info | EXPORTING | File Import | File Import Information |
statuscode | IMPORTING | Integer | Response Code. |
statusreason | IMPORTING | String | Status Description/Reason |
file | IMPORTING | File | ABAP Ready Imported File Information |
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 |
---|---|---|---|
201 Created | File | file | Success |
Other Status Codes | Error | error | An error occurred. |
Files - List
Gets a list of all files owned by the Azure OpenAI resource. These include user uploaded content like files with purpose "fine-tune" for training or validation of fine-tunes models as well as files that are generated by the service such as "fine-tune-results" which contains various metrics for the corresponding fine-tune job.
DATA:
file_list TYPE zif_peng_azoai_sdk_types=>ty_file_list.
sdk_instance->files( )->list(
IMPORTING
statuscode = status_code " Status Code
statusreason = status_reason " HTTP status description
filelist = file_list " ABAP Ready list of files
error = error " ABAP Ready error details
).
Parameters and Exceptions
- Parameters
- Exceptions
Parameter | Direction | Data Type | Description |
---|---|---|---|
statuscode | IMPORTING | Integer | Response Code. |
statusreason | IMPORTING | String | Status Description/Reason |
filelist | IMPORTING | File List | ABAP Ready File List |
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 | File List | filelist | Success |
Other Status Codes | Error | error | An error occurred. |
Files - Upload
Creates a new file entity by uploading data from ABAP Application Server. Uploaded files can, for example, be used for training or evaluating fine-tuned models.
DATA:
upload_data TYPE zif_peng_azoai_sdk_types=>tty_file_upload,
sdk_instance->files( )->upload(
EXPORTING
filename = 'Demo_File_Upload.jsonl' "File Name
jsonldata = upload_data " JSONL data to upload
IMPORTING
statuscode = status_code " Status Code
statusreason = status_reason " HTTP status description
file = uploaded_file_info " ABAP Ready uploaded file information.
error = error " ABAP Ready error details
).
Parameters and Exceptions
- Parameters
- Exceptions
Parameter | Direction | Data Type | Description |
---|---|---|---|
filename | EXPORTING | string | Name of file to be set in AI Portal after successful upload. |
jsonldata | EXPORTING | File Upload[] | Internal table of training data. |
statuscode | IMPORTING | Integer | Response Code. |
statusreason | IMPORTING | String | Status Description/Reason |
file | IMPORTING | File | ABAP Ready File Information |
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 |
---|---|---|---|
201 Created | File | file | Success |
Other Status Codes | Error | error | An error occurred. |