6 | "! A Completion operation is about asking the AI engine something, and getting a response. The
7 | "! asking part of this interaction is called "prompts". Prompt Engineering is used to create
8 | "! prompts which will guide the AI engine to understand exactly what you are asking for, and respond meaningfully
9 | "! for the context of the question.
10 | "!
13 | "! This method performs a completion operation with the prompts provided in parameter prompts, and returns the
14 | "! response received from AI engine. Both the raw JSON string received from AI enging, as well as a parsed, ABAP ready
15 | "! data structure is provided back to the caller.
16 | "! @parameter deploymentid |
Deployment ID on which the prompt must be run.
17 | "! @parameter prompts |
1 or more prompts and their parameters like token length.
18 | "! @parameter statuscode |
HTTP Response status code.
19 | "! @parameter statusreason |
HTTP Status Reason.
20 | "! @parameter json |
JSON String received from AI engine.
21 | "! @parameter response |
Parsed and ABAP ready data structure from JSON String
22 | "! @parameter error |
Error information parsed from JSON string
23 | "! @raising zcx_peng_azoai_sdk_exception |
Exception - Note - an AI layer error is NOT an exception.
24 | METHODS create
25 | IMPORTING
26 | deploymentid TYPE string
27 | prompts TYPE zif_peng_azoai_sdk_types=>ty_chatcompletion_input
28 | EXPORTING
29 | statuscode TYPE i
30 | statusreason TYPE string
31 | json TYPE string
32 | response TYPE zif_peng_azoai_sdk_types=>ty_chatcompletion_output
33 | error TYPE zif_peng_azoai_sdk_types=>ty_error
34 | RAISING
35 | zcx_peng_azoai_sdk_exception .
36 | ENDINTERFACE.
37 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_ai_sdk_comp_chatcompl.intf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZIF_PENG_AI_SDK_COMP_CHATCOMPL
7 | E
8 | MSPENG: Azure Open AI SDK - Completions Component
9 | 2
10 | 1
11 | X
12 |
13 |
14 |
15 | CREATE
16 | E
17 | Performs a Chat Completion.
18 |
19 |
20 |
21 |
22 | CREATE
23 | DEPLOYMENTID
24 | E
25 | Deployment ID on which the prompt must be run.
26 |
27 |
28 | CREATE
29 | ERROR
30 | E
31 | Error information parsed from JSON string
32 |
33 |
34 | CREATE
35 | JSON
36 | E
37 | JSON String received from AI engine.
38 |
39 |
40 | CREATE
41 | PROMPTS
42 | E
43 | 1 or more prompts and their parameters like token length.
44 |
45 |
46 | CREATE
47 | RESPONSE
48 | E
49 | Parsed and ABAP ready data structure from JSON String
50 |
51 |
52 | CREATE
53 | STATUSCODE
54 | E
55 | HTTP Response status code.
56 |
57 |
58 | CREATE
59 | STATUSREASON
60 | E
61 | HTTP Status Reason.
62 |
63 |
64 | CREATE
65 | ZCX_PENG_AZOAI_SDK_EXCEPTION
66 | E
67 | Exception - Note - an AI layer error is NOT an exception.
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_centralcontrol.intf.abap:
--------------------------------------------------------------------------------
1 | INTERFACE zif_peng_azoai_centralcontrol
2 | PUBLIC .
3 |
4 | METHODS:
5 | "!
Check if SDK use is permitted
6 | "! Fired before SDK is initialized. To prevent SDK usage, raise the exception.
7 | "!
8 | "! Note: This will be the first call to this handler class, and the only
9 | "! time the api parameters and initialization parameter (init_params) will be passed in.
10 | "! If that information is required for further checks (eg: initialize_sdkcomponent, perform_operation)
11 | "! the implementation of the handler must put these values into an attribute of the object, so that
12 | "! it can be used later, since the instance of the handler used to call each of these methods remains
13 | "! the same.
14 | "! @parameter api_version |
API Version
15 | "! @parameter api_base |
API Base URL
16 | "! @parameter api_type |
API Type
17 | "! @parameter init_params |
Other Initialization Parameters
18 | "! @raising zcx_peng_azoai_sdk_exception |
19 | start_sdk
20 | IMPORTING
21 | api_version TYPE string
22 | api_base TYPE string
23 | api_type TYPE string
24 | sdkprofile TYPE ztaisdkrunprofil
25 | init_params TYPE tihttpnvp
26 | RAISING
27 | zcx_peng_azoai_sdk_exception,
28 |
29 | "!
Check if an SDK component is permitted
30 | "! This method is called prior to initializing a specific component of the SDK, such as a model, deployment,
31 | "! completions, file, finetuning, or embeddings. It takes in the component_type parameter,
32 | "! which specifies the type of component to be initialized. If the component initialization must not be
33 | "! performed, raise the zcx_peng_azoai_sdk_exception (or a sub-class of it) exception.
34 | "!
35 | "! Note:If additional information (eg: API Type, or initialization parameters) are needed
36 | "! to make the determination, be sure to store away parameters passed during "start_sdk()" call into class attributes.
37 | "! @parameter component_type |
Check if a specific operation on a component is permitted
46 | "! This method is used to perform an operation on a specific component of the SDK. It takes in the component_type
47 | "! and operation parameters, which specify the type of component and the operation to be performed, respectively.
48 | "! If the operation should not be performed, raise the zcx_peng_azoai_sdk_exception (or sub-class of it) exception.
49 | "!
50 | "! Note: This will be the first call to this handler class, and the only
51 | "! time the api parameters and initialization parameter (init_params) will be passed in.
52 | "! If that information is required for further checks (eg: initialize_sdkcomponent, perform_operation)
53 | "! the implementation of the handler must put these values into an attribute of the object, so that
54 | "! it can be used later, since the instance of the handler used to call each of these methods remains
55 | "! the same.
56 | "! @parameter component_type |
Component Type
57 | "! @parameter operation |
Operation to be performed
58 | "! @raising zcx_peng_azoai_sdk_exception |
59 | perform_operation
60 | IMPORTING
61 | component_type TYPE string
62 | operation TYPE string
63 | RAISING
64 | zcx_peng_azoai_sdk_exception.
65 |
66 |
67 |
68 | ENDINTERFACE.
69 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_centralcontrol.intf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZIF_PENG_AZOAI_CENTRALCONTROL
7 | E
8 | MSPENG: Interface for Central Control
9 | 2
10 | 1
11 | X
12 |
13 |
14 |
15 | INITIALIZE_SDKCOMPONENT
16 | E
17 | Check if an SDK component is permitted
18 |
19 |
20 | PERFORM_OPERATION
21 | E
22 | Check if a specific operation on a component is permitted
23 |
24 |
25 | START_SDK
26 | E
27 | Check if SDK use is permitted
28 |
29 |
30 |
31 |
32 | INITIALIZE_SDKCOMPONENT
33 | COMPONENT_TYPE
34 | E
35 | Component Type
36 |
37 |
38 | PERFORM_OPERATION
39 | COMPONENT_TYPE
40 | E
41 | Component Type
42 |
43 |
44 | PERFORM_OPERATION
45 | OPERATION
46 | E
47 | Operation to be performed
48 |
49 |
50 | START_SDK
51 | API_BASE
52 | E
53 | API Base URL
54 |
55 |
56 | START_SDK
57 | API_TYPE
58 | E
59 | API Type
60 |
61 |
62 | START_SDK
63 | API_VERSION
64 | E
65 | API Version
66 |
67 |
68 | START_SDK
69 | INIT_PARAMS
70 | E
71 | Other Initialization Parameters
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk.intf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZIF_PENG_AZOAI_SDK
7 | E
8 | MSPENG:Azure Open AI SDK Interface
9 | 2
10 | 1
11 | X
12 |
13 |
14 |
15 | CHAT_COMPLETIONS
16 | E
17 | Returns an instace of SDK Chat Completions component
18 |
19 |
20 | COMPLETIONS
21 | E
22 | Returns an instance of SDK Completions Component
23 |
24 |
25 | DEPLOYMENTS
26 | E
27 | Returns an instance of SDK Deployments Component
28 |
29 |
30 | EMBEDDINGS
31 | E
32 | Returns an instance of SDK Embeddings component
33 |
34 |
35 | FILES
36 | E
37 | Returns an instance of SDK Files Component
38 |
39 |
40 | FINETUNES
41 | E
42 | Returns an instance of SDK Fine-Tunes component
43 |
44 |
45 | INITIALIZE
46 | E
47 | Initialize the SDK (Internal use Only)
48 |
49 |
50 | MODEL
51 | E
52 | Returns the SDK Model Operation Component
53 |
54 |
55 |
56 |
57 | CHAT_COMPLETIONS
58 | CHAT_COMPLETIONS
59 | E
60 | Chat Completions SDK Component
61 |
62 |
63 | COMPLETIONS
64 | COMPLETIONS
65 | E
66 | Completions SDK Component
67 |
68 |
69 | DEPLOYMENTS
70 | DEPLOYMENTS
71 | E
72 | An instance of SDK Deployment Component
73 |
74 |
75 | EMBEDDINGS
76 | EMBEDDING
77 | E
78 | Embeddings SDK Component
79 |
80 |
81 | FILES
82 | FILES
83 | E
84 | Files SDK Component
85 |
86 |
87 | FINETUNES
88 | FINETUNES
89 | E
90 | FineTunes SDK Component
91 |
92 |
93 | INITIALIZE
94 | CONFIG
95 | E
96 | MSPENG:Azure Open AI Config Interface
97 |
98 |
99 | INITIALIZE
100 | ZCX_PENG_AZOAI_SDK_EXCEPTION
101 | E
102 | MSPENG:Azure Open AI ABAP SDK Exception
103 |
104 |
105 | MODEL
106 | ZCX_PENG_AZOAI_SDK_EXCEPTION
107 | E
108 | MSPENG:Azure Open AI ABAP SDK Exception
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_comp_compl.intf.abap:
--------------------------------------------------------------------------------
1 | "!
Performs a completion based on prompts and other parameters.
8 | "! A Completion operation is about asking the AI engine something, and getting a response. The
9 | "! asking part of this interaction is called "prompts". Prompt Engineering is used to create
10 | "! prompts which will guide the AI engine to understand exactly what you are asking for, and respond meaningfully
11 | "! for the context of the question.
12 | "!
15 | "! This method performs a completion operation with the prompts provided in parameter prompts, and returns the
16 | "! response received from AI engine. Both the raw JSON string received from AI enging, as well as a parsed, ABAP ready
17 | "! data structure is provided back to the caller.
18 | "!
19 | "! Parameter Details : Prompts
20 | "! prompt : Internal table of strings
21 | "! The prompt(s) to generate completions for a list of strings
22 | "! max_tokens:Integer
23 | "! The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens can't exceed the model's
24 | "! context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096).
25 | "! user: String
26 | "! A unique identifier representing your end-user, which can help monitoring and detecting abuse
27 | "! n:Integer
28 | "! How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly
29 | "! consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop.
30 | "!
31 | "!
32 | "! @parameter deploymentid |
Deployment ID on which the prompt must be run.
33 | "! @parameter prompts |
1 or more prompts and their parameters like token length.
34 | "! @parameter statuscode |
HTTP Response status code.
35 | "! @parameter statusreason |
HTTP Status Reason.
36 | "! @parameter json |
JSON String received from AI engine.
37 | "! @parameter response |
Parsed and ABAP ready data structure from JSON String
38 | "! @parameter error |
Error information parsed from JSON string
39 | "! @raising zcx_peng_azoai_sdk_exception |
Exception - Note - an AI layer error is NOT an exception.
40 | METHODS create
41 | IMPORTING
42 | deploymentid TYPE string
43 | prompts TYPE zif_peng_azoai_sdk_types=>ty_completion_input
44 | EXPORTING
45 | statuscode TYPE i
46 | statusreason TYPE string
47 | json TYPE string
48 | response TYPE zif_peng_azoai_sdk_types=>ty_completion_output
49 | error TYPE zif_peng_azoai_sdk_types=>ty_error
50 | RAISING
51 | zcx_peng_azoai_sdk_exception .
52 | ENDINTERFACE.
53 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_comp_compl.intf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZIF_PENG_AZOAI_SDK_COMP_COMPL
7 | E
8 | MSPENG: Azure Open AI SDK - Completions Component
9 | 2
10 | 1
11 | X
12 |
13 |
14 |
15 | CREATE
16 | E
17 | Performs a completion based on prompts and other parameters.
18 |
19 |
20 |
21 |
22 | CREATE
23 | DEPLOYMENTID
24 | E
25 | Deployment ID on which the prompt must be run.
26 |
27 |
28 | CREATE
29 | ERROR
30 | E
31 | Error information parsed from JSON string
32 |
33 |
34 | CREATE
35 | JSON
36 | E
37 | JSON String received from AI engine.
38 |
39 |
40 | CREATE
41 | PROMPTS
42 | E
43 | 1 or more prompts and their parameters like token length.
44 |
45 |
46 | CREATE
47 | RESPONSE
48 | E
49 | Parsed and ABAP ready data structure from JSON String
50 |
51 |
52 | CREATE
53 | STATUSCODE
54 | E
55 | HTTP Response status code.
56 |
57 |
58 | CREATE
59 | STATUSREASON
60 | E
61 | HTTP Status Reason.
62 |
63 |
64 | CREATE
65 | ZCX_PENG_AZOAI_SDK_EXCEPTION
66 | E
67 | Exception - Note - an AI layer error is NOT an exception.
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_comp_embed.intf.abap:
--------------------------------------------------------------------------------
1 | "!
Deployment ID on which the embedding must be generated.
9 | "! @parameter inputs |
Input texts for embedding
10 | "! @parameter statuscode |
HTTP Response status code.
11 | "! @parameter statusreason |
HTTP Status Reason.
12 | "! @parameter json |
JSON String received from AI engine.
13 | "! @parameter response |
Parsed and ABAP ready data structure from JSON String
14 | "! @parameter error |
Error information parsed from JSON string
15 | "! @raising zcx_peng_azoai_sdk_exception |
Exception - Note - an AI layer error is NOT an exception.
16 | METHODS create
17 | IMPORTING
18 | deploymentid TYPE string
19 | inputs TYPE zif_peng_azoai_sdk_types=>ty_embeddings_input
20 | EXPORTING
21 | statuscode TYPE i
22 | statusreason TYPE string
23 | json TYPE string
24 | response TYPE zif_peng_azoai_sdk_types=>ty_embeddings_output
25 | error TYPE zif_peng_azoai_sdk_types=>ty_error
26 | RAISING
27 | zcx_peng_azoai_sdk_exception .
28 | ENDINTERFACE.
29 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_comp_embed.intf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZIF_PENG_AZOAI_SDK_COMP_EMBED
7 | E
8 | MSPENG: Azure Open AI SDK - Embeddings Component
9 | 2
10 | 1
11 | X
12 |
13 |
14 |
15 | CREATE
16 | E
17 | Creates embedding from input text.
18 |
19 |
20 |
21 |
22 | CREATE
23 | DEPLOYMENTID
24 | E
25 | Deployment ID on which the embedding must be generated.
26 |
27 |
28 | CREATE
29 | ERROR
30 | E
31 | Error information parsed from JSON string
32 |
33 |
34 | CREATE
35 | INPUTS
36 | E
37 | Input texts for embedding
38 |
39 |
40 | CREATE
41 | JSON
42 | E
43 | JSON String received from AI engine.
44 |
45 |
46 | CREATE
47 | RESPONSE
48 | E
49 | Parsed and ABAP ready data structure from JSON String
50 |
51 |
52 | CREATE
53 | STATUSCODE
54 | E
55 | HTTP Response status code.
56 |
57 |
58 | CREATE
59 | STATUSREASON
60 | E
61 | HTTP Status Reason.
62 |
63 |
64 | CREATE
65 | ZCX_PENG_AZOAI_SDK_EXCEPTION
66 | E
67 | Exception - Note - an AI layer error is NOT an exception.
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_comp_model.intf.abap:
--------------------------------------------------------------------------------
1 | INTERFACE zif_peng_azoai_sdk_comp_model
2 | PUBLIC .
3 |
4 |
5 | * INTERFACES zif_peng_azoai_sdk_component .
6 |
7 | "!
Get details of a single model.
8 | "! Get details of a specific model, as specified in model ID parameter.
9 | "! @parameter iv_modelid |
Model ID
10 | "! @parameter ov_statuscode |
Status Code
11 | "! @parameter ov_statusreason |
Status Description
12 | "! @parameter ov_json |
JSON string with information about deployment, or error.
13 | "! @parameter ov_model |
ABAP ready model details.
14 | "! @parameter ov_error |
ABAP ready error details
15 | "! @raising zcx_peng_azoai_sdk_exception |
16 | METHODS get
17 | IMPORTING
18 | !iv_modelid TYPE string
19 | EXPORTING
20 | ov_statuscode TYPE i
21 | ov_statusreason TYPE string
22 | ov_json TYPE string
23 | ov_model TYPE zif_peng_azoai_sdk_types=>ty_model_get
24 | ov_error TYPE zif_peng_azoai_sdk_types=>ty_error
25 | RAISING
26 | zcx_peng_azoai_sdk_exception .
27 |
28 |
29 | "!
List all models available
30 | "! Provides a list of all models available for deployment.
31 | "! @parameter ov_statuscode |
Status Code
32 | "! @parameter ov_statusreason |
Status Description
33 | "! @parameter ov_json |
JSON string with information about deployment, or error.
34 | "! @parameter ov_model |
ABAP ready model list.
35 | "! @parameter ov_error |
ABAP ready error details
36 | "! @raising zcx_peng_azoai_sdk_exception |
37 | METHODS list
38 | EXPORTING
39 | ov_statuscode TYPE i
40 | ov_statusreason TYPE string
41 | ov_json TYPE string
42 | ov_model TYPE zif_peng_azoai_sdk_types=>ty_model_list
43 | ov_error TYPE zif_peng_azoai_sdk_types=>ty_error
44 | RAISING
45 | zcx_peng_azoai_sdk_exception .
46 | ENDINTERFACE.
47 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_comp_model.intf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZIF_PENG_AZOAI_SDK_COMP_MODEL
7 | E
8 | MSPENG:Azure Open AI SDK - Model Component
9 | 2
10 | 1
11 | X
12 |
13 |
14 |
15 | GET
16 | E
17 | Get details of a single model.
18 |
19 |
20 | LIST
21 | E
22 | List all models available
23 |
24 |
25 |
26 |
27 | GET
28 | IV_MODELID
29 | E
30 | Model ID
31 |
32 |
33 | GET
34 | OV_ERROR
35 | E
36 | ABAP ready error details
37 |
38 |
39 | GET
40 | OV_JSON
41 | E
42 | JSON string with information about deployment, or error.
43 |
44 |
45 | GET
46 | OV_MODEL
47 | E
48 | ABAP ready model details.
49 |
50 |
51 | GET
52 | OV_STATUSCODE
53 | E
54 | Status Code
55 |
56 |
57 | GET
58 | OV_STATUSREASON
59 | E
60 | Status Description
61 |
62 |
63 | LIST
64 | OV_ERROR
65 | E
66 | ABAP ready error details
67 |
68 |
69 | LIST
70 | OV_JSON
71 | E
72 | JSON string with information about deployment, or error.
73 |
74 |
75 | LIST
76 | OV_MODEL
77 | E
78 | ABAP ready model list.
79 |
80 |
81 | LIST
82 | OV_STATUSCODE
83 | E
84 | Status Code
85 |
86 |
87 | LIST
88 | OV_STATUSREASON
89 | E
90 | Status Description
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_component.intf.abap:
--------------------------------------------------------------------------------
1 | INTERFACE zif_peng_azoai_sdk_component
2 | PUBLIC .
3 |
4 |
5 | "!
Initialize an SDK Component (Internal Use Only)
6 | "! INTERNAL USE ONLY
7 | "!
8 | "! Initializes an SDK component, and registered sub-objects into the instance.
9 | "! @parameter component_set |
Table of component parameters and sub-components
10 | "! @raising zcx_peng_azoai_sdk_exception |
11 | METHODS initialize_component
12 | IMPORTING
13 | component_set TYPE zif_peng_azoai_sdk_typinternal=>tty_component_init_param
14 | RAISING
15 | zcx_peng_azoai_sdk_exception.
16 |
17 | ENDINTERFACE.
18 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_component.intf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZIF_PENG_AZOAI_SDK_COMPONENT
7 | E
8 | MSPENG:Azure Open AI SDK Component Interface
9 | 2
10 | 1
11 | X
12 |
13 |
14 |
15 | INITIALIZE_COMPONENT
16 | E
17 | Initialize an SDK Component (Internal Use Only)
18 |
19 |
20 |
21 |
22 | INITIALIZE_COMPONENT
23 | COMPONENT_SET
24 | E
25 | Table of component parameters and sub-components
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_constants.intf.abap:
--------------------------------------------------------------------------------
1 | INTERFACE zif_peng_azoai_sdk_constants
2 | PUBLIC .
3 |
4 |
5 | CONSTANTS:
6 |
7 | * Version Strings currently supported by Azure Open AI.
8 | BEGIN OF c_versions,
9 | v_2022_12_01 TYPE string VALUE '2022-12-01',
10 | v_2023_03_15_preview TYPE string VALUE '2023-03-15-preview',
11 | v_2023_05_15 TYPE string VALUE '2023-05-15',
12 | v_2023_06_01_preview TYPE string VALUE '2023-06-01-preview',
13 | v_2023_07_01_preview TYPE string VALUE '2023-07-01-preview',
14 | v_2023_08_01_preview TYPE string VALUE '2023-08-01-preview',
15 | END OF c_versions,
16 |
17 |
18 | * List of component identifiers/names. This is used internally for interaction and initialization of AI components.
19 | BEGIN OF c_component_type,
20 | sdk TYPE string VALUE 'SDK',
21 | config TYPE string VALUE 'CONFIG',
22 | helper TYPE string VALUE 'HELPER',
23 | model TYPE string VALUE 'MODEL',
24 | deployment TYPE string VALUE 'DEPLOYMENT',
25 | completions TYPE string VALUE 'COMPLETIONS',
26 | chat_completions TYPE string VALUE 'CHAT_COMPLETIONS',
27 | file TYPE string VALUE 'FILE',
28 | fine_tuning TYPE string VALUE 'FINETUNING',
29 | embeddings TYPE string VALUE 'EMBEDDINGS',
30 | END OF c_component_type,
31 |
32 | * Operations supported by components. NOTE: This is an exhaustive list of operations by all components. Not all operations
33 | * are supported by every component.
34 | BEGIN OF c_component_operations,
35 | cancel TYPE string VALUE 'CANCEL',
36 | create TYPE string VALUE 'CREATE',
37 | delete TYPE string VALUE 'DELETE',
38 | get TYPE string VALUE 'GET',
39 | get_content TYPE string VALUE 'GET_CONTENT',
40 | get_events TYPE string VALUE 'GET_EVENTS',
41 | import TYPE string VALUE 'IMPORT',
42 | initialize TYPE string VALUE 'INITIALIZE',
43 | list TYPE string VALUE 'LIST',
44 | update TYPE string VALUE 'UPDATE',
45 | upload TYPE string VALUE 'UPLOAD',
46 | END OF c_component_operations,
47 |
48 | BEGIN OF c_component_classification,
49 | core TYPE string VALUE 'CORE',
50 | submodule TYPE string VALUE 'SUBMODULE',
51 | END OF c_component_classification,
52 |
53 |
54 | * open AI resource identifier.
55 | c_azure_openairesource TYPE string VALUE '.openai.azure.com',
56 | c_openairesource TYPE string VALUE 'api.openai.com',
57 |
58 | * File purpose.
59 | BEGIN OF c_filepurpose,
60 | finetune TYPE string VALUE 'fine-tune',
61 | finetuneresult TYPE string VALUE 'fine-tune-results',
62 | END OF c_filepurpose,
63 |
64 | c_file_upload_boundary TYPE string VALUE '----MSPlatformEngineering{guid}',
65 |
66 | * API Authentication strategies currently supported.
67 | BEGIN OF c_apitype,
68 | azure TYPE string VALUE 'azure',
69 | azure_ad TYPE string VALUE 'azure_ad',
70 | openai TYPE string VALUE 'openai',
71 | END OF c_apitype,
72 |
73 |
74 | * API Authentication Header Parameter values
75 | * Author Side NOTE : Wish there were ENums in ECC - but unfortunately, its only available in S4.
76 | BEGIN OF c_authheader_paramnames,
77 | api_key TYPE string VALUE 'api-key',
78 | authorization TYPE string VALUE 'Authorization',
79 | bearer TYPE string VALUE 'Bearer',
80 | END OF c_authheader_paramnames,
81 |
82 | * Operational parameter names. This will be used for passing in operational params during config initialization.
83 | BEGIN OF c_operational_paramnames,
84 | version TYPE string VALUE 'version',
85 | endpoint TYPE string VALUE 'endpoint',
86 | destination TYPE string VALUE 'destination',
87 | apitype TYPE string VALUE 'apitype',
88 | apikey TYPE string VALUE 'apikey',
89 | END OF c_operational_paramnames,
90 |
91 | * Central Control Class Name.
92 | c_central_control_class TYPE string VALUE 'ZCL_PENG_AZOAI_CENTRALCONTROL',
93 | c_sdk_default_profile_name TYPE zde_azoaisdk_profileid VALUE 'DEFAULT',
94 |
95 | BEGIN OF c_urltemplateproviders,
96 | azureopenai TYPE string VALUE 'zcl_peng_azoai_urlprovider',
97 | openai TYPE string VALUE 'zcl_peng_oai_urlprovider',
98 | END OF c_urltemplateproviders,
99 |
100 | BEGIN OF c_chatcompletion_role,
101 | user TYPE string VALUE 'user',
102 | assistant TYPE string VALUE 'assistant',
103 | system TYPE string VALUE 'system',
104 | END OF c_chatcompletion_role.
105 |
106 |
107 |
108 |
109 |
110 | ENDINTERFACE.
111 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_constants.intf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZIF_PENG_AZOAI_SDK_CONSTANTS
7 | E
8 | MSPENG:Azure Open AI Constants
9 | 2
10 | 1
11 | X
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_types.intf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZIF_PENG_AZOAI_SDK_TYPES
7 | E
8 | MSPENG:Azure Open AI Types Interface
9 | 2
10 | 1
11 | X
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_typinternal.intf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZIF_PENG_AZOAI_SDK_TYPINTERNAL
7 | E
8 | MSPENG:Azure Open AI SDK Internal Data Types (DO NOT USE)
9 | 2
10 | 1
11 | X
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_uripatterns.intf.abap:
--------------------------------------------------------------------------------
1 | INTERFACE zif_peng_azoai_sdk_uripatterns
2 | PUBLIC .
3 |
4 | CONSTANTS:
5 |
6 | BEGIN OF supported_protocols,
7 | https TYPE string VALUE 'https://',
8 | END OF supported_protocols,
9 |
10 | BEGIN OF template_ids,
11 | endpoint TYPE string VALUE '{endpoint}',
12 | version TYPE string VALUE '{version}',
13 | deploymentid TYPE string VALUE '{deployment-id}',
14 | modelid TYPE string VALUE '{model-id}',
15 | fileid TYPE string VALUE '{file-id}',
16 | finetuneid TYPE string VALUE '{fine-tune-id}',
17 | END OF template_ids,
18 |
19 | * This is the endpoint ID. In future, if the end point remains the same, we will map this ID to version.
20 | * This allows us to not define the same end point repeatedly.
21 | BEGIN OF version_20221201_endpoint,
22 |
23 | * Deployment End points (https://learn.microsoft.com/en-us/rest/api/cognitiveservices/azureopenaistable/deployments)
24 | BEGIN OF deployments,
25 | create TYPE string VALUE '{endpoint}/openai/deployments?api-version={version}' , "HTTP - POST.
26 | delete TYPE string VALUE '{endpoint}/openai/deployments/{deployment-id}?api-version={version}' , "HTTP - DELETE
27 | get TYPE string VALUE '{endpoint}/openai/deployments/{deployment-id}?api-version={version}' , "HTTP - GET
28 | list TYPE string VALUE '{endpoint}/openai/deployments?api-version={version}' , "HTTP - GET.
29 | update TYPE string VALUE '{endpoint}/openai/deployments/{deployment-id}?api-version={version}' , "HTTP - PATCH
30 | END OF deployments,
31 |
32 |
33 | * Model end points (https://learn.microsoft.com/en-us/rest/api/cognitiveservices/azureopenaistable/models)
34 | BEGIN OF model,
35 | get TYPE string VALUE '{endpoint}/openai/models/{model-id}?api-version={version}' , "HTTP - GET
36 | list TYPE string VALUE '{endpoint}/openai/models?api-version={version}' , "HTTP - GET
37 | END OF model,
38 |
39 | * Files end points ( https://learn.microsoft.com/en-us/rest/api/cognitiveservices/azureopenaistable/files)
40 | BEGIN OF files,
41 | delete TYPE string VALUE '{endpoint}/openai/files/{file-id}?api-version={version}',
42 | get TYPE string VALUE '{endpoint}/openai/files/{file-id}?api-version={version}',
43 | get_content TYPE string VALUE '{endpoint}/openai/files/{file-id}/content?api-version={version}',
44 | import TYPE string VALUE '{endpoint}/openai/files/import?api-version={version}',
45 | list TYPE string VALUE '{endpoint}/openai/files?api-version={version}',
46 | upload TYPE string VALUE '{endpoint}/openai/files?api-version={version}',
47 | END OF files,
48 |
49 | * Fine tunes end points (https://learn.microsoft.com/en-us/rest/api/cognitiveservices/azureopenaistable/fine-tunes)
50 | BEGIN OF finetunes,
51 | cancel TYPE string VALUE '{endpoint}/openai/fine-tunes/{fine-tune-id}/cancel?api-version={version}' , "HTTP - POST
52 | create TYPE string VALUE '{endpoint}/openai/fine-tunes?api-version={version}' , "HTTP - POST
53 | delete TYPE string VALUE '{endpoint}/openai/fine-tunes/{fine-tune-id}?api-version={version}' , "HTTP - DELETE
54 | get TYPE string VALUE '{endpoint}/openai/fine-tunes/{fine-tune-id}?api-version={version}' , "HTTP - GET
55 | events TYPE string VALUE '{endpoint}/openai/fine-tunes/{fine-tune-id}/events?api-version={version}' , "HTTP - GET
56 | list TYPE string VALUE '{endpoint}/openai/fine-tunes?api-version={version}' , "HTTP - GET
57 | END OF finetunes,
58 |
59 | BEGIN OF completions,
60 | create TYPE string VALUE '{endpoint}/openai/deployments/{deployment-id}/completions?api-version={version}', "HTTP - POST
61 | END OF completions,
62 |
63 | BEGIN OF embeddings,
64 | create TYPE string VALUE '{endpoint}/openai/deployments/{deployment-id}/embeddings?api-version={version}', "HTTP - POST
65 | END OF embeddings,
66 | END OF version_20221201_endpoint,
67 |
68 | BEGIN OF version_2023_03_15_preview,
69 | BEGIN OF completions,
70 | create TYPE string VALUE '{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version={version}', "HTTP - POST
71 | END OF completions,
72 | BEGIN OF chat_completions,
73 | create TYPE string VALUE '{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version={version}', "HTTP - POST
74 | END OF chat_completions,
75 | END OF version_2023_03_15_preview.
76 |
77 | ENDINTERFACE.
78 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zif_peng_azoai_sdk_uripatterns.intf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZIF_PENG_AZOAI_SDK_URIPATTERNS
7 | E
8 | MSPENG:Azure Open AI SDK URI Patterns
9 | 2
10 | 1
11 | X
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_core/zmspeng_azoaisdk_msg.msag.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZMSPENG_AZOAISDK_MSG
7 | E
8 | MSPENG:Azure Open AI SDK Messages
9 |
10 |
11 |
12 | E
13 | ZMSPENG_AZOAISDK_MSG
14 | 000
15 | Version Not Supported.
16 |
17 |
18 | E
19 | ZMSPENG_AZOAISDK_MSG
20 | 001
21 | Invalid Azure Open AI Resource Base URL
22 |
23 |
24 | E
25 | ZMSPENG_AZOAISDK_MSG
26 | 002
27 | Invalid Authentication &.
28 |
29 |
30 | E
31 | ZMSPENG_AZOAISDK_MSG
32 | 003
33 | Feature Not Implemented or Requested operation not valid for version.
34 |
35 |
36 | E
37 | ZMSPENG_AZOAISDK_MSG
38 | 004
39 | Communication Failure to Azure Open AI Resource. Check URL.
40 |
41 |
42 | E
43 | ZMSPENG_AZOAISDK_MSG
44 | 005
45 | Component Initialization Failed (Internal SDK Error).
46 |
47 |
48 | E
49 | ZMSPENG_AZOAISDK_MSG
50 | 006
51 | Parameter & not available.
52 |
53 |
54 | E
55 | ZMSPENG_AZOAISDK_MSG
56 | 007
57 | Error in profile. Invalid Handler class.
58 |
59 |
60 | E
61 | ZMSPENG_AZOAISDK_MSG
62 | 008
63 | & Usage not permitted through run profile. Contact SDK Administrator.
64 |
65 |
66 | E
67 | ZMSPENG_AZOAISDK_MSG
68 | 009
69 | & Usage not valid for version.
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/package.devc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MS Platform Engineering: Azure Open AI SDK Demos
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_aisdkdemo_chatcompl_simple.prog.abap:
--------------------------------------------------------------------------------
1 | *&---------------------------------------------------------------------*
2 | *& Report zp_aisdkdemo_chatcompl_simple
3 | *&---------------------------------------------------------------------*
4 | *&
5 | *&---------------------------------------------------------------------*
6 | REPORT zp_aisdkdemo_chatcompl_simple.
7 |
8 | *INCLUDE zp_msaisdkdemo_params_top. "Common Input Parameters (AI End Point, Version, Key)
9 | INCLUDE zp_msaisdkdemo_common. "Common Data Declarations (SDK Instance Object, status Code, Status Reason, Return JSON String, Error )
10 |
11 | PARAMETERS:
12 | p_url TYPE string OBLIGATORY LOWER CASE,
13 | p_ver TYPE string OBLIGATORY LOWER CASE DEFAULT '2023-03-15-preview',
14 | p_key TYPE string OBLIGATORY LOWER CASE.
15 |
16 |
17 | PARAMETERS:
18 | p_depid TYPE string OBLIGATORY LOWER CASE.
19 |
20 | DATA:
21 | chatcompl_input TYPE zif_peng_azoai_sdk_types=>ty_chatcompletion_input,
22 | chatcompl_output TYPE zif_peng_azoai_sdk_types=>ty_chatcompletion_output.
23 |
24 |
25 | START-OF-SELECTION.
26 |
27 | TRY.
28 | * Create an instance of MS AI SDK for SAP.
29 | sdk_instance = zcl_peng_azoai_sdk_factory=>get_instance( )->get_sdk(
30 | api_version = p_ver
31 | api_base = p_url
32 | api_type = zif_peng_azoai_sdk_constants=>c_apitype-azure
33 | api_key = p_key
34 | ).
35 |
36 | * Construct the prompt with system and user roles.
37 | * APPEND INITIAL LINE TO chatcompl_input-messages ASSIGNING FIELD-SYMBOL().
38 | * -role = zif_peng_azoai_sdk_constants=>c_chatcompletion_role-system.
39 | * -content = |You are an expert ABAP Developer|.
40 | *
41 | * APPEND INITIAL LINE TO chatcompl_input-messages ASSIGNING .
42 | * -role = zif_peng_azoai_sdk_constants=>c_chatcompletion_role-user.
43 | * -content = |Write an ABAP program which gets contents from www.microsoft.com website. Include comments in the code so that anyone can understand the code.|.
44 |
45 | APPEND INITIAL LINE TO chatcompl_input-messages ASSIGNING FIELD-SYMBOL().
46 | -role = zif_peng_azoai_sdk_constants=>c_chatcompletion_role-system.
47 | -content = |You are a math expert |.
48 |
49 | APPEND INITIAL LINE TO chatcompl_input-messages ASSIGNING .
50 | -role = zif_peng_azoai_sdk_constants=>c_chatcompletion_role-user.
51 | -content = | Using 5 randome numbers from 1 to 10, generate the sum, product and show me the result.|.
52 | -content = |{ -content } Additionally, generate ABAP code and Python code and format the code text using HTML so that I can display it. |.
53 | -content = |{ -content } Make sure, the entire response is provided as richly formatted HTML page so that it can be displayed in a browser. |.
54 |
55 |
56 | * Invoke Chat completion.
57 | sdk_instance->chat_completions( )->create(
58 | EXPORTING
59 | deploymentid = p_depid
60 | prompts = chatcompl_input
61 | IMPORTING
62 | statuscode = status_code " Status Code
63 | statusreason = status_reason " HTTP status description
64 | json = returnjson " JSON String returned from AI Resource
65 | response = chatcompl_output
66 | error = error " ABAP Ready error details
67 | ).
68 |
69 | * Display the results.
70 | * cl_demo_output=>display_text( text = chatcompl_output-choices[ 1 ]-message-content ).
71 | cl_demo_output=>display_html( html = chatcompl_output-choices[ 1 ]-message-content ).
72 |
73 | CATCH zcx_peng_azoai_sdk_exception INTO DATA(ex). " MSPENG:Azure Open AI ABAP SDK Exception
74 | MESSAGE ex TYPE 'I'.
75 |
76 | CATCH cx_root.
77 | MESSAGE |An error occured - perhaps the model name is incorrect? Or Access key is incorrect?| TYPE 'I'.
78 | ENDTRY.
79 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_aisdkdemo_chatcompl_simple.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZP_AISDKDEMO_CHATCOMPL_SIMPLE
7 | S
8 | 1
9 | X
10 | D$S
11 | X
12 |
13 |
14 |
15 | R
16 | MSPENG: AI SDK Demo programs - Chat Completions - Simple
17 | 56
18 |
19 |
20 | S
21 | P_DEPID
22 | Deployment ID
23 | 21
24 |
25 |
26 | S
27 | P_KEY
28 | Key
29 | 11
30 |
31 |
32 | S
33 | P_URL
34 | Azure Open AI Base URL
35 | 30
36 |
37 |
38 | S
39 | P_VER
40 | Version
41 | 15
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_aisdkdemo_embeddings.prog.abap:
--------------------------------------------------------------------------------
1 | *&---------------------------------------------------------------------*
2 | *& Report ZP_AISDKDEMO_EMBEDDINGS
3 | *&---------------------------------------------------------------------*
4 | *&
5 | *&---------------------------------------------------------------------*
6 | REPORT zp_aisdkdemo_embeddings.
7 |
8 |
9 | INCLUDE zp_msaisdkdemo_params_top. "Common Input Parameters (AI End Point, Version, Key)
10 | INCLUDE zp_msaisdkdemo_common. "Common Data Declarations (SDK Instance Object, status Code, Status Reason, Return JSON String, Error )
11 |
12 | PARAMETERS:
13 | p_depid TYPE string OBLIGATORY LOWER CASE.
14 |
15 | DATA:
16 | embeddings_input TYPE zif_peng_azoai_sdk_types=>ty_embeddings_input,
17 | embeddings_output TYPE zif_peng_azoai_sdk_types=>ty_embeddings_output.
18 |
19 |
20 | START-OF-SELECTION.
21 |
22 | TRY.
23 |
24 | * Create an instance of MS AI SDK for SAP.
25 | sdk_instance = zcl_peng_azoai_sdk_factory=>get_instance( )->get_sdk(
26 | api_version = p_ver
27 | api_base = p_url
28 | api_type = zif_peng_azoai_sdk_constants=>c_apitype-azure
29 | api_key = p_key
30 | ).
31 |
32 | * Specify text(s) to generate embedding.
33 | APPEND INITIAL LINE TO embeddings_input-input ASSIGNING FIELD-SYMBOL().
34 | = 'Hello world!'.
35 |
36 | * Perform the embeddings operation.
37 | sdk_instance->embeddings( )->create(
38 | EXPORTING
39 | deploymentid = p_depid " Deployment ID on which the embedding must be generated.
40 | inputs = embeddings_input " Input texts for embedding
41 | IMPORTING
42 | statuscode = status_code " Status Code
43 | statusreason = status_reason " HTTP status description
44 | json = returnjson " JSON String returned from AI Resource
45 | response = embeddings_output " ABAP Friendly Embeddings operaiton output
46 | error = error " ABAP Ready error details
47 | ).
48 |
49 | BREAK-POINT.
50 |
51 | CATCH zcx_peng_azoai_sdk_exception INTO DATA(ex). " MSPENG:Azure Open AI ABAP SDK Exception
52 | MESSAGE ex TYPE 'I'.
53 | ENDTRY.
54 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_aisdkdemo_embeddings.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZP_AISDKDEMO_EMBEDDINGS
7 | 1
8 | E
9 | X
10 | X
11 |
12 |
13 |
14 | R
15 | MSPENG: AI SDK Demo programs - Embeddings
16 | 41
17 |
18 |
19 | S
20 | P_DEPID
21 | Deployment ID
22 | 21
23 |
24 |
25 | S
26 | P_KEY
27 | Key
28 | 11
29 |
30 |
31 | S
32 | P_URL
33 | Base URL
34 | 16
35 |
36 |
37 | S
38 | P_VER
39 | Version
40 | 15
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_chatui.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZP_MSAISDKDEMO_CHATUI
7 | I
8 | E
9 | X
10 |
11 |
12 |
13 | R
14 | Include ZP_MSAISDKDEMO_CHATUI
15 | 29
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_chatui_def.prog.abap:
--------------------------------------------------------------------------------
1 | *&---------------------------------------------------------------------*
2 | *& Include ZP_MSAISDKDEMO_CHATUI_DEF
3 | * Provide Defaults for UI Elements
4 | *&---------------------------------------------------------------------*
5 |
6 |
7 | gv_temp_info =
8 | |It controls randomness. | &&
9 | |Lowering the temperature means that the model will produce more repetitive and deterministic responses. | &&
10 | |Increasing the temperature will result in more unexpected or creative responses. | &&
11 | |Try adjusting temperature or Top P but not both.|.
12 | gv_topp_info = |Similar to temperature, this controls randomness but uses a different method. | &&
13 | |Lowering Top P will narrow the model’s token selection to likelier tokens. | &&
14 | |Increasing Top P will let the model choose from tokens with both high and low likelihood.| &&
15 | |Try adjusting temperature or Top P but not both.|.
16 | gv_stop_info = |Make the model end its response at a desired point. | &&
17 | |Make the model end its response at a desired point. | &&
18 | |You can include as many as four stop sequences. | .
19 | gv_pres_info = |Reduce the chance of repeating any token that has appeared in the text at all so far. | &&
20 | | This increases the likelihood of introducing new topics in a response. | .
21 | gv_freq_info = |Reduce the chance of repeating a token proportionally based on how often it has appeared in the text so far.| &&
22 | |This decreases the likelihood of repeating the exact same text in a response.|.
23 |
24 | g_templtable = value #( ( key = 1 temp_name = 'Empty Template' temp_text = value #( ( lineno = 1 text_line = '' ) ) )
25 | ( key = 2 temp_name = 'Default Template'
26 | temp_text = value #( ( lineno = 1 text_line = 'You are an AI assistant that helps people find information.' ) ) )
27 | ( key = 3 temp_name = 'JSON Formatter Assistant'
28 | temp_text = value #( ( lineno = 1 text_line = 'You are an AI assistant that helps users turn a natural language list into JSON format.' ) ) )
29 | ( key = 4 temp_name = 'ABAP Developer Assistant'
30 | temp_text = value #( ( lineno = 1 text_line = 'You are an AI assistant that helps people with ABAP syntax.' )
31 | ( lineno = 2 text_line = 'User will provide requirement in natural language.' )
32 | ( lineno = 3 text_line = 'You will provide ABAP code for implementing that requirement.' ) ) )
33 | ( key = 5 temp_name = 'ABAP Documentation Assistant'
34 | temp_text =
35 | value #( ( lineno = 1 text_line = 'You are an AI assistant that explains ABAP Code.' )
36 | ( lineno = 2 text_line = 'User will provide an ABAP program.' )
37 | ( lineno = 3 text_line = 'You will explain ABAP code in natural language.' )
38 | ( lineno = 4 text_line = 'Add sections with headings for explaining multiple line of code' ) ) )
39 |
40 | ( key = 6 temp_name = 'Summarization Template'
41 | temp_text = value #( ( lineno = 1 text_line = 'You are an AI assistant that helps people ' )
42 | ( lineno = 2 text_line = 'to generate abstractive summaries of texts.' )
43 | ( lineno = 3 text_line = 'Based on users input you can generate summary as keypoints or paragraph' )
44 | )
45 | ) ).
46 |
47 | g_item_table = value #( for l_tempstruct in g_templtable ( key = l_tempstruct-key
48 | text = l_tempstruct-temp_name )
49 | ).
50 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_chatui_def.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZP_MSAISDKDEMO_CHATUI_DEF
7 | I
8 | E
9 | X
10 |
11 |
12 |
13 | R
14 | Include ZP_MSAISDKDEMO_CHATUI_DEF
15 | 33
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_chatui_top.prog.abap:
--------------------------------------------------------------------------------
1 | *&---------------------------------------------------------------------*
2 | *& Include ZP_MSAISDKDEMO_CHATUI_TOP
3 | *&---------------------------------------------------------------------*
4 |
5 | constants: c_line_length type i value 256.
6 |
7 | constants : c_label_width type i value 15,
8 | c_parameter1_text type string
9 | value ' 0 - 1',
10 | c_parameter2_text type string value ' 0 - 2', " (0.10,0.11,0.20,..1.9, 2 etc. )',
11 | c_parameter3_text type string value 'e.g. <|im_end|> ',
12 | c_def_aitext type string value 'You are an AI Assistant that helps people find information.'.
13 | * define table type for data exchange
14 | types: begin of mytable_line,
15 | line(c_line_length) type c,
16 | end of mytable_line .
17 | TYPES: BEGIN OF t_text,
18 | lineno TYPE i,
19 | text_line type string ,
20 | END OF t_text,
21 | t_text_tab TYPE STANDARD TABLE OF t_text with NON-UNIQUE key lineno .
22 | types : begin of template_type,
23 | key type i,
24 | temp_name type string,
25 | temp_text type t_text_tab ,
26 | end of template_type.
27 | * table to exchange text
28 | data g_templtable TYPE TABLE OF template_type.
29 | data g_mytable type table of mytable_line.
30 | data g_systable type table of mytable_line.
31 | data: g_templates type table of template_type,w_template type template_type.
32 | data: g_item_table TYPE VRM_VALUES," INITIAL SIZE 0,
33 | g_ITEM_STRUCT TYPE VRM_VALUE.
34 | data : gv_txt_temp type string value 'Use a template to get started, or just start writing your own system message below.'.
35 | data: gv_temp_info type string,
36 | gv_topp_info type string,
37 | gv_stop_info type string,
38 | gv_freq_info type string,
39 | gv_pres_info type string.
40 |
41 | data:
42 | g_text_input type ref to cl_gui_textedit, "Text Editor for taking user's input
43 | g_sysmsg_input type ref to cl_gui_textedit, "Text Editor for System Message
44 | g_input_temp type ref to cl_gui_input_field, "Text field for Temperature
45 | g_input_topp type ref to cl_gui_input_field, "Text field for TopP
46 | g_input_stop type ref to cl_gui_input_field, "Text field for Stop Sequence
47 | g_input_freq type ref to cl_gui_input_field, "Text field for Frequency Penalty
48 | g_input_pres type ref to cl_gui_input_field, "Text field for Presence Penalty
49 | g_systemp_sel type ref to cl_gui_combobox,
50 |
51 | label_ec_input type string,
52 | g_str_input type string,
53 | g_sys_input type string,
54 | g_text_output type ref to cl_gui_textedit,
55 | g_str_output type string,
56 | g_ok_code like sy-ucomm,
57 |
58 | * n TYPE i, "How many chat completion choices to generate for each input message
59 |
60 | g_temp_val type string, " Temperature
61 | g_topt_val type string, " Topt
62 | g_stop_val type string, " Stop Sequence
63 | g_freq_val type string, " Frequency Penalty
64 | g_pres_val type string. " Presence Penalty
65 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_chatui_top.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZP_MSAISDKDEMO_CHATUI_TOP
7 | I
8 | E
9 | X
10 |
11 |
12 |
13 | R
14 | Include ZP_MSAISDKDEMO_CHATUI_TOP
15 | 33
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_common.prog.abap:
--------------------------------------------------------------------------------
1 | *&---------------------------------------------------------------------*
2 | *& Include ZP_MSAISDKDEMO_COMMON
3 | *&---------------------------------------------------------------------*
4 |
5 | DATA:
6 | sdk_instance TYPE REF TO zif_peng_azoai_sdk, "MS AI SDK for SAP Instance
7 | status_code TYPE i, "Return Status Code
8 | status_reason TYPE string, "Return Status Reason
9 | returnjson TYPE string, "Return JSON. The content of this JSON string is parsed and made available through ABAP data types.
10 | error TYPE zif_peng_azoai_sdk_types=>ty_error. "ABAP Type for Error
11 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_common.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZP_MSAISDKDEMO_COMMON
7 | I
8 | E
9 | X
10 |
11 |
12 |
13 | R
14 | MS Platform Engineering: Azure Open AI SDK Demos: Common Data
15 | 61
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_deployments.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZP_MSAISDKDEMO_DEPLOYMENTS
7 | 1
8 | E
9 | X
10 | X
11 |
12 |
13 |
14 | R
15 | MS AI SDK for SAP : Demo Program for Deployment
16 | 47
17 |
18 |
19 | S
20 | P_KEY
21 | Key
22 | 11
23 |
24 |
25 | S
26 | P_MODID
27 | Model ID for Deployment
28 | 31
29 |
30 |
31 | S
32 | P_URL
33 | Base URL
34 | 16
35 |
36 |
37 | S
38 | P_VER
39 | Version
40 | 15
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_files.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZP_MSAISDKDEMO_FILES
7 | 1
8 | E
9 | X
10 | X
11 |
12 |
13 |
14 | R
15 | MS AI SDK for SAP : Demo Program for Files
16 | 55
17 |
18 |
19 | S
20 | P_KEY
21 | Key
22 | 11
23 |
24 |
25 | S
26 | P_URL
27 | Base URL
28 | 16
29 |
30 |
31 | S
32 | P_VER
33 | Version
34 | 15
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_finetunes.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZP_MSAISDKDEMO_FINETUNES
7 | 1
8 | E
9 | X
10 | X
11 |
12 |
13 |
14 | R
15 | MS AI SDK for SAP : Demo Program for Fine Tunes
16 | 55
17 |
18 |
19 | S
20 | P_KEY
21 | Key
22 | 11
23 |
24 |
25 | S
26 | P_URL
27 | Base URL
28 | 16
29 |
30 |
31 | S
32 | P_VER
33 | Version
34 | 15
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_models.prog.abap:
--------------------------------------------------------------------------------
1 | *&---------------------------------------------------------------------*
2 | *& Report ZP_MSAISDKDEMO_MODELS
3 | *&
4 | *&---------------------------------------------------------------------*
5 | *&
6 | *&
7 | *&---------------------------------------------------------------------*
8 | REPORT zp_msaisdkdemo_models.
9 | INCLUDE zp_msaisdkdemo_params_top. "Common Input Parameters (AI End Point, Version, Key)
10 | INCLUDE zp_msaisdkdemo_common. "Common Data Declarations (SDK Instance Object, status Code, Status Reason, Return JSON String, Error )
11 |
12 | DATA:
13 | model_list TYPE zif_peng_azoai_sdk_types=>ty_model_list, "ABAP Type for List of Models
14 | model_get TYPE zif_peng_azoai_sdk_types=>ty_model_get. "ABAP Type for A single Model information
15 |
16 |
17 | START-OF-SELECTION.
18 |
19 | TRY.
20 | * Create an instance of MS AI SDK for SAP.
21 | sdk_instance = zcl_peng_azoai_sdk_factory=>get_instance( )->get_sdk(
22 | api_version = p_ver
23 | api_base = p_url
24 | api_type = zif_peng_azoai_sdk_constants=>c_apitype-azure
25 | api_key = p_key
26 | ).
27 | ************************** Get a list of all available Models ******************
28 |
29 | * Get a list of all models (Models - List ).
30 | sdk_instance->model( )->list(
31 | IMPORTING
32 | ov_statuscode = status_code " Status Code
33 | ov_statusreason = status_reason " HTTP status description
34 | ov_json = returnjson "JSON String returned from AI Resource
35 | ov_model = model_list "List of Models available ( Type :zif_peng_azoai_sdk_types=>ty_model_list )
36 | ov_error = error "Error if occured, returned from AI Resource (Type : zif_peng_azoai_sdk_types=>ty_error)
37 | ).
38 | ********************************************************************************
39 | BREAK-POINT.
40 |
41 | ************************** Get details of a specific Model *********************
42 |
43 | * Get the Model information for Text-Davinci-003 (Models - Get).
44 | sdk_instance->model( )->get(
45 | EXPORTING
46 | iv_modelid = 'text-davinci-003' " Model ID
47 | IMPORTING
48 | ov_statuscode = status_code " HTTP status code
49 | ov_statusreason = status_reason
50 | ov_json = returnjson
51 | ov_model = model_get
52 | ov_error = error
53 | ).
54 | ********************************************************************************
55 | BREAK-POINT.
56 |
57 | CATCH zcx_peng_azoai_sdk_exception INTO DATA(ex). " MSPENG:Azure Open AI ABAP SDK Exception
58 | MESSAGE ex TYPE 'I'.
59 | ENDTRY.
60 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_models.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZP_MSAISDKDEMO_MODELS
7 | 1
8 | E
9 | X
10 | X
11 |
12 |
13 |
14 | R
15 | MS AI SDK for SAP : Demo Program for Model
16 | 55
17 |
18 |
19 | S
20 | P_KEY
21 | Key
22 | 11
23 |
24 |
25 | S
26 | P_URL
27 | Base URL
28 | 16
29 |
30 |
31 | S
32 | P_VER
33 | Version
34 | 15
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_params_top.prog.abap:
--------------------------------------------------------------------------------
1 | *&---------------------------------------------------------------------*
2 | *& Include ZP_MSAISDKDEMO_PARAMS_TOP Report ZP_MSAISDKDEMO_MODELS
3 | *&
4 | *&---------------------------------------------------------------------*
5 | *REPORT ZP_MSAISDKDEMO_MODELS.
6 | PARAMETERS:
7 | p_url TYPE string OBLIGATORY LOWER CASE,
8 | p_ver TYPE string OBLIGATORY LOWER CASE DEFAULT '2022-12-01',
9 | p_key TYPE string OBLIGATORY LOWER CASE.
10 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_params_top.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZP_MSAISDKDEMO_PARAMS_TOP
7 | I
8 | E
9 | X
10 |
11 |
12 |
13 | R
14 | Include ZP_MSAISDKDEMO_PARAMS_TOP
15 | 33
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_selection.prog.abap:
--------------------------------------------------------------------------------
1 | *&---------------------------------------------------------------------*
2 | *& Include ZP_MSAISDKDEMO_SELECTION
3 | *&---------------------------------------------------------------------*
4 | parameters:
5 | p_url type string obligatory lower case,
6 | p_ver type string obligatory lower case default '2023-03-15-preview',
7 | p_key type string obligatory lower case.
8 |
9 |
10 | parameters:
11 | p_depid type string obligatory lower case.
12 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_msaisdkdemo_selection.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZP_MSAISDKDEMO_SELECTION
7 | I
8 | E
9 | X
10 |
11 |
12 |
13 | R
14 | Include ZP_MSAISDKDEMO_SELECTION
15 | 32
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_demos/zp_pengg_azoai_demo_completion.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZP_PENGG_AZOAI_DEMO_COMPLETION
7 | 1
8 | E
9 | X
10 | X
11 |
12 |
13 |
14 |
15 | ZP_PENGG_AZOAI_DEMO_COMPLETION
16 | 9000
17 | E
18 | Main Screen
19 | N
20 | 9000
21 | 047
22 | 176
23 |
24 |
25 |
26 | SCREEN
27 | SCREEN
28 |
29 |
30 | CUST_CTRL
31 | TXTINPUT
32 | SCREEN
33 | 003
34 | 002
35 | 173
36 | 010
37 |
38 |
39 | CUST_CTRL
40 | TXTOUTPUT
41 | SCREEN
42 | 016
43 | 002
44 | 172
45 | 026
46 |
47 |
48 |
49 |
50 | SCREEN
51 | SCREEN
52 | PUSH
53 | BTNASKAI
54 | Ask_AI________
55 | ICON_START_VIEWER
56 | X
57 | 014
58 | 078
59 | 019
60 | 017
61 | 001
62 | ASKAI
63 | CHAR
64 | N
65 |
66 |
67 | SCREEN
68 | SCREEN
69 | OKCODE
70 | G_OK_CODE
71 | ____________________
72 | 020
73 | 020
74 | 001
75 | CHAR
76 | X
77 |
78 |
79 |
80 |
81 | PROCESS BEFORE OUTPUT.
82 |
83 |
84 | MODULE PBO.
85 |
86 |
87 | *
88 |
89 |
90 | PROCESS AFTER INPUT.
91 |
92 |
93 | MODULE PAI.
94 |
95 |
96 |
97 |
98 |
99 |
100 | R
101 | Microsoft Platform Engineering: Azure Open AI SDK Demo - Completions
102 | 68
103 |
104 |
105 | S
106 | P_DEPID
107 | Deployment ID
108 | 21
109 |
110 |
111 | S
112 | P_KEY
113 | Key
114 | 30
115 |
116 |
117 | S
118 | P_LENGTH
119 | Token Length
120 | 20
121 |
122 |
123 | S
124 | P_URL
125 | Azure Open AI Base URL
126 | 30
127 |
128 |
129 | S
130 | P_VER
131 | Version
132 | 15
133 |
134 |
135 |
136 |
137 |
138 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/package.devc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MS Platform Engineering:Azure Open AI SDK Version 1.0
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/zcl_peng_ai_sdk_v1_chatcomplet.clas.abap:
--------------------------------------------------------------------------------
1 | CLASS zcl_peng_ai_sdk_v1_chatcomplet DEFINITION
2 | PUBLIC
3 | INHERITING FROM zcl_peng_ai_sdk_chatcompl_base
4 | CREATE PUBLIC .
5 |
6 | PUBLIC SECTION.
7 | METHODS zif_peng_ai_sdk_comp_chatcompl~create REDEFINITION.
8 | PROTECTED SECTION.
9 | PRIVATE SECTION.
10 | ENDCLASS.
11 |
12 |
13 |
14 | CLASS zcl_peng_ai_sdk_v1_chatcomplet IMPLEMENTATION.
15 | METHOD zif_peng_ai_sdk_comp_chatcompl~create.
16 | *****************************************************************************************************************
17 | * Class : ZCL_PENG_AI_SDK_V1_CHATCOMPLET
18 | * Method : zif_peng_ai_sdk_comp_chatcompl~create
19 | * Created by : GONAIR (Gopal Nair)
20 | * Date : May 7, 2023
21 | *-------------------------------------------------------------------------------------------------------------
22 | * Description
23 | *-------------------------------------------------------------------------------------------------------------
24 | * Performs a Chat completion based on prompts and other parameters.
25 | *
26 | * A Completion operation is about asking the AI engine something, and getting a response. The asking part of this
27 | * interaction is called "prompts". Prompt Engineering is used to create prompts which will guide the AI engine to
28 | * understand exactly what you are asking for, and respond meaningfully for the context of the question.
29 | *-------------------------------------------------------------------------------------------------------------
30 | * Modification History
31 | *-------------------------------------------------------------------------------------------------------------
32 | * May 7, 2023 // GONAIR // Initial Version
33 | *****************************************************************************************************************
34 |
35 | DATA:
36 | l_completions_create TYPE zif_peng_azoai_sdk_types=>ty_chatcompletion_input.
37 |
38 | * Check if the operation is permitted for the run profile by asking profile handler.
39 | _objconfig->get_runprofile_handler( )->zif_peng_azoai_centralcontrol~perform_operation(
40 | EXPORTING
41 | component_type = _component_type
42 | operation = zif_peng_azoai_sdk_constants=>c_component_operations-create
43 | ).
44 |
45 |
46 | l_completions_create = prompts.
47 |
48 | * If there are no prompts entered by the user, then put in 1 entry with empty string.
49 | IF l_completions_create-messages[] IS INITIAL.
50 | RETURN.
51 | ENDIF.
52 |
53 | * Get the actual URL and HTTP communication objects from helper layer.
54 | _objsdkhelper->get_httpobjs_from_uripattern(
55 | EXPORTING
56 | uri_pattern = _objconfig->get_accesspoint_provider( )->get_urltemplate(
57 | component = _component_type
58 | operation = zif_peng_azoai_sdk_constants=>c_component_operations-create
59 | ) "{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version={version}'
60 | ivobj_config = _objconfig
61 | ivt_templatecomponents = VALUE #( ( name = zif_peng_azoai_sdk_uripatterns=>template_ids-deploymentid value = deploymentid ) ) "Deployment ID.
62 | IMPORTING
63 | ov_url = DATA(actual_url)
64 | ovobj_http = DATA(lo_http)
65 | ovobj_http_rest = DATA(lo_http_rest)
66 | ).
67 |
68 | * Prepare the body and set it
69 | DATA(lo_request) = lo_http_rest->if_rest_client~create_request_entity( ).
70 | lo_request->set_content_type( iv_media_type = 'application/json' ).
71 | DATA(post_data) = to_lower( /ui2/cl_json=>serialize( data = l_completions_create compress = /ui2/cl_json=>c_bool-true ) ) .
72 | lo_request->set_string_data( iv_data = post_data ).
73 |
74 | * Trigger the network operation.
75 | lo_http_rest->if_rest_client~post( io_entity = lo_request ).
76 |
77 | * Get Status, results and error if any from helper layer.
78 | _objsdkhelper->do_receive(
79 | EXPORTING
80 | ivobj_http_client = lo_http
81 | ivobj_http_rest = lo_http_rest
82 | IMPORTING
83 | ov_statuscode = statuscode
84 | ov_statusdescr = statusreason
85 | ov_jsonstring = json
86 | CHANGING
87 | iov_result = response
88 | iov_error = error
89 | ).
90 |
91 |
92 | ENDMETHOD.
93 |
94 | ENDCLASS.
95 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/zcl_peng_ai_sdk_v1_chatcomplet.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCL_PENG_AI_SDK_V1_CHATCOMPLET
7 | E
8 | MSPENG:Azure OpenAI ABAP SDK Completions Component
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/zcl_peng_azoai_ctrl_denyall.clas.abap:
--------------------------------------------------------------------------------
1 | CLASS zcl_peng_azoai_ctrl_denyall DEFINITION
2 | PUBLIC
3 | INHERITING FROM zcl_peng_azoai_centralcontrol
4 | CREATE PUBLIC .
5 |
6 | PUBLIC SECTION.
7 | METHODS:
8 | zif_peng_azoai_centralcontrol~start_sdk REDEFINITION,
9 | zif_peng_azoai_centralcontrol~initialize_sdkcomponent REDEFINITION,
10 | zif_peng_azoai_centralcontrol~perform_operation REDEFINITION.
11 | PROTECTED SECTION.
12 | PRIVATE SECTION.
13 | ENDCLASS.
14 |
15 |
16 |
17 | CLASS zcl_peng_azoai_ctrl_denyall IMPLEMENTATION.
18 | METHOD zif_peng_azoai_centralcontrol~initialize_sdkcomponent.
19 | RAISE EXCEPTION TYPE zcx_peng_azoai_sdk_exception
20 | EXPORTING
21 | textid = zcx_peng_azoai_sdk_exception=>component_use_not_permitted
22 | iv_attr1 = CONV #( component_type ).
23 |
24 | ENDMETHOD.
25 |
26 | METHOD zif_peng_azoai_centralcontrol~perform_operation.
27 | RAISE EXCEPTION TYPE zcx_peng_azoai_sdk_exception
28 | EXPORTING
29 | textid = zcx_peng_azoai_sdk_exception=>component_use_not_permitted
30 | iv_attr1 = |{ component_type }/{ operation }|.
31 | ENDMETHOD.
32 |
33 | METHOD zif_peng_azoai_centralcontrol~start_sdk.
34 | RAISE EXCEPTION TYPE zcx_peng_azoai_sdk_exception
35 | EXPORTING
36 | textid = zcx_peng_azoai_sdk_exception=>component_use_not_permitted
37 | iv_attr1 = |AI SDK|.
38 | ENDMETHOD.
39 |
40 | ENDCLASS.
41 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/zcl_peng_azoai_ctrl_denyall.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCL_PENG_AZOAI_CTRL_DENYALL
7 | E
8 | MSPENG:AZOAISDK Central Control - Deny All Plugin
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/zcl_peng_azoai_sdk_v1.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCL_PENG_AZOAI_SDK_V1
7 | E
8 | MSPENG:Azure Open AI ABAP SDK
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/zcl_peng_azoai_sdk_v1_complet.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCL_PENG_AZOAI_SDK_V1_COMPLET
7 | E
8 | MSPENG:Azure OpenAI ABAP SDK Completions Component
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/zcl_peng_azoai_sdk_v1_config.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCL_PENG_AZOAI_SDK_V1_CONFIG
7 | E
8 | MSPENG:Azure OpenAI ABAP SDK Config
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 | _LOAD_SUPPORTED_AUTHSTRATEGIES
17 | E
18 | Load supported Auth Strategies.
19 |
20 |
21 | _LOAD_SUPPORTED_VERSIONS
22 | E
23 | Load supported versions
24 |
25 |
26 | _SET_API_BASE
27 | E
28 | Sets the API Base URL
29 |
30 |
31 | _SET_API_VERSION
32 | E
33 | Sets the API version into config object
34 |
35 |
36 | _SET_AUTHENTICATION
37 | E
38 | Sets Authentication strategy
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/zcl_peng_azoai_sdk_v1_deploy.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCL_PENG_AZOAI_SDK_V1_DEPLOY
7 | E
8 | MSPENG:Azure OpenAI ABAP SDK Deployments Component
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/zcl_peng_azoai_sdk_v1_embeding.clas.abap:
--------------------------------------------------------------------------------
1 | CLASS zcl_peng_azoai_sdk_v1_embeding DEFINITION
2 | PUBLIC
3 | INHERITING FROM zcl_peng_azoai_sdk_embed_base
4 | CREATE PUBLIC .
5 |
6 | PUBLIC SECTION.
7 | METHODS zif_peng_azoai_sdk_comp_embed~create REDEFINITION.
8 | PROTECTED SECTION.
9 | PRIVATE SECTION.
10 | ENDCLASS.
11 |
12 |
13 |
14 | CLASS zcl_peng_azoai_sdk_v1_embeding IMPLEMENTATION.
15 | METHOD zif_peng_azoai_sdk_comp_embed~create.
16 | *****************************************************************************************************************
17 | * Class : ZCL_PENG_AZOAI_SDK_V1_EMBEDING
18 | * Method : zif_peng_azoai_sdk_comp_embed~create
19 | * Created by : Gopal Nair
20 | * Date : Jun 2, 2023
21 | *-------------------------------------------------------------------------------------------------------------
22 | * Description
23 | *-------------------------------------------------------------------------------------------------------------
24 | *
25 | *-------------------------------------------------------------------------------------------------------------
26 | * Modification History
27 | *-------------------------------------------------------------------------------------------------------------
28 | * Jun 2, 2023 // GONAIR // Initial Version
29 | *****************************************************************************************************************
30 |
31 | * Check if the operation is permitted for the run profile by asking profile handler.
32 | _objconfig->get_runprofile_handler( )->zif_peng_azoai_centralcontrol~perform_operation(
33 | EXPORTING
34 | component_type = _component_type
35 | operation = zif_peng_azoai_sdk_constants=>c_component_operations-create
36 | ).
37 |
38 | * Get the actual URL and HTTP communication objects from helper layer.
39 | _objsdkhelper->get_httpobjs_from_uripattern(
40 | EXPORTING
41 | uri_pattern = _objconfig->get_accesspoint_provider( )->get_urltemplate(
42 | component = _component_type
43 | operation = zif_peng_azoai_sdk_constants=>c_component_operations-create
44 | ) "{endpoint}/openai/deployments/{deployment-id}/embeddings?api-version={version}'
45 | ivobj_config = _objconfig
46 | ivt_templatecomponents = VALUE #( ( name = zif_peng_azoai_sdk_uripatterns=>template_ids-deploymentid value = deploymentid ) ) "Deployment ID.
47 | IMPORTING
48 | ov_url = DATA(actual_url)
49 | ovobj_http = DATA(lo_http)
50 | ovobj_http_rest = DATA(lo_http_rest)
51 | ).
52 |
53 | * Prepare the body and set it
54 | DATA(lo_request) = lo_http_rest->if_rest_client~create_request_entity( ).
55 | lo_request->set_content_type( iv_media_type = 'application/json' ).
56 | DATA(post_data) = to_lower( /ui2/cl_json=>serialize( data = inputs ) ) .
57 | lo_request->set_string_data( iv_data = post_data ).
58 |
59 | * Trigger the network operation.
60 | lo_http_rest->if_rest_client~post( io_entity = lo_request ).
61 |
62 | * Get Status, results and error if any from helper layer.
63 | _objsdkhelper->do_receive(
64 | EXPORTING
65 | ivobj_http_client = lo_http
66 | ivobj_http_rest = lo_http_rest
67 | IMPORTING
68 | ov_statuscode = statuscode
69 | ov_statusdescr = statusreason
70 | ov_jsonstring = json
71 | CHANGING
72 | iov_result = response
73 | iov_error = error
74 | ).
75 |
76 |
77 | ENDMETHOD.
78 |
79 | ENDCLASS.
80 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/zcl_peng_azoai_sdk_v1_embeding.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCL_PENG_AZOAI_SDK_V1_EMBEDING
7 | E
8 | MSPENG:Azure OpenAI ABAP SDK Completions Component
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/zcl_peng_azoai_sdk_v1_file.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCL_PENG_AZOAI_SDK_V1_FILE
7 | E
8 | MSPENG:Azure Open AI SDK File Component
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/zcl_peng_azoai_sdk_v1_finetune.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCL_PENG_AZOAI_SDK_V1_FINETUNE
7 | E
8 | MSPENG:Azure Open AI SDK Fine Tune Component
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_azure/zpengg_ai_openai_azure_sdk/zpengg_azoai_sdk_v1/zcl_peng_azoai_sdk_v1_model.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCL_PENG_AZOAI_SDK_V1_MODEL
7 | E
8 | MSPENG:Azure Open AI SDK Model Component
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_utils/package.devc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MS Platform Engineering: Open AI Common Utils
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_utils/zcl_peng_aisdk_templprov_base.clas.abap:
--------------------------------------------------------------------------------
1 | CLASS zcl_peng_aisdk_templprov_base DEFINITION
2 | PUBLIC
3 | CREATE PUBLIC .
4 |
5 | PUBLIC SECTION.
6 |
7 | INTERFACES zif_peng_aisdk_endpt_provider .
8 | PROTECTED SECTION.
9 | DATA:
10 | _version TYPE string,
11 | _additional_init_params TYPE tihttpnvp,
12 | _t_endpoint_dictionary TYPE zif_peng_azoai_sdk_typinternal=>tty_endpoint_url_info.
13 |
14 | PRIVATE SECTION.
15 | ENDCLASS.
16 |
17 |
18 |
19 | CLASS zcl_peng_aisdk_templprov_base IMPLEMENTATION.
20 | METHOD zif_peng_aisdk_endpt_provider~get_endpoint_template.
21 | *****************************************************************************************************************
22 | * Class : ZCL_PENG_AISDK_TEMPLPROV_BASE
23 | * Method : zif_peng_aisdk_endpt_provider~get_endpoint_template
24 | * Created by : Gopal Nair
25 | * Date : Jun 5, 2023
26 | *-------------------------------------------------------------------------------------------------------------
27 | * Description
28 | *-------------------------------------------------------------------------------------------------------------
29 | * Gets the URL end point for a specific Component/Operation
30 | * This method returns the specific end point URL for an operation on an AI engine.
31 | *-------------------------------------------------------------------------------------------------------------
32 | * Modification History
33 | *-------------------------------------------------------------------------------------------------------------
34 | * Jun 5, 2023 // GONAIR // Initial Version
35 | *****************************************************************************************************************
36 |
37 | * Check if the component type + operation combo has an access URL available. If not, raise exception and exit.
38 |
39 | IF line_exists( _t_endpoint_dictionary[ version = _version component_type = component operation = operation ] ).
40 | endpoint_template = _t_endpoint_dictionary[ version = _version component_type = component operation = operation ]-access_url.
41 | ELSE.
42 | RAISE EXCEPTION TYPE zcx_peng_azoai_sdk_exception
43 | EXPORTING
44 | textid = zcx_peng_azoai_sdk_exception=>not_implemented.
45 |
46 | ENDIF.
47 | ENDMETHOD.
48 |
49 | METHOD zif_peng_aisdk_endpt_provider~initialize.
50 | *****************************************************************************************************************
51 | * Class : ZCL_PENG_AISDK_TEMPLPROV_BASE
52 | * Method : zif_peng_aisdk_endpt_provider~initialize
53 | * Created by : GONAIR (Gopal Nair)
54 | * Date : Jun 5, 2023
55 | *-------------------------------------------------------------------------------------------------------------
56 | * Description
57 | *-------------------------------------------------------------------------------------------------------------
58 | * Initialize the URL provider
59 | * This method is called by AI SDK core to initialize the URL provider. It passes in a version ID.
60 | * The version may/maynot play a role in the URL end point, but its there to use.
61 | *-------------------------------------------------------------------------------------------------------------
62 | * Modification History
63 | *-------------------------------------------------------------------------------------------------------------
64 | * Jun 5, 2023 // GONAIR // Initial Version
65 | *****************************************************************************************************************
66 | _version = api_version.
67 | _additional_init_params = additional_params.
68 | ENDMETHOD.
69 |
70 | ENDCLASS.
71 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_utils/zcl_peng_aisdk_templprov_base.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCL_PENG_AISDK_TEMPLPROV_BASE
7 | E
8 | MSPENG:AISDK: Base Class for Access Point URL provider
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_utils/zcl_peng_aisdk_templprovider.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCL_PENG_AISDK_TEMPLPROVIDER
7 | E
8 | MSPENG:AZOAISDK URL Template Provider (INTERNAL USE ONLY)
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 | CONSTRUCTOR
17 | E
18 | Creates and returns an instance of URL provider
19 |
20 |
21 | GET_URLTEMPLATE
22 | E
23 | Gets the URL Template if defined
24 |
25 |
26 |
27 |
28 | CONSTRUCTOR
29 | API_TYPE
30 | E
31 | API Type
32 |
33 |
34 | CONSTRUCTOR
35 | API_VERSION
36 | E
37 | API Version
38 |
39 |
40 | GET_URLTEMPLATE
41 | ADDITIONAL_PARAMS
42 | E
43 | Additional Parameters
44 |
45 |
46 | GET_URLTEMPLATE
47 | COMPONENT
48 | E
49 | Component ID
50 |
51 |
52 | GET_URLTEMPLATE
53 | OPERATION
54 | E
55 | Operation
56 |
57 |
58 | GET_URLTEMPLATE
59 | URL_TEMPLATE
60 | E
61 | URL Template, if defined
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/src/zpengg_ai_openai_main/zpengg_ai_openai_utils/zif_peng_aisdk_endpt_provider.intf.abap:
--------------------------------------------------------------------------------
1 | INTERFACE zif_peng_aisdk_endpt_provider
2 | PUBLIC .
3 |
4 | METHODS:
5 |
6 | "!
Initialize the URL provider
7 | "! Initialize the URL provider
8 | "!
9 | "! This method is called by AI SDK core to initialize the URL provider. It passes in a version
10 | "! ID. The version may/maynot play a role in the URL end point, but its there to use.
11 | "! @parameter api_version |