Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INTM] Add new object type INTM #671

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions file-formats/intm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# INTM File Format

File | Cardinality | Definition | Schema | Example
:--- | :--- | :--- | :--- | :---
`<name>.intm.json` | 1 | [`zif_aff_intm_v1.intf.abap`](./type/zif_aff_intm_v1.intf.abap) | [`intm-v1.json`](./intm-v1.json) | [`sapj97myt5r25l0v2ijp2rt1pko4.intm.json`](./examples/sapj97myt5r25l0v2ijp2rt1pko4.intm.json)
35 changes: 35 additions & 0 deletions file-formats/intm/examples/sapj97myt5r25l0v2ijp2rt1pko4.intm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"formatVersion": "1",
"header": {
"description": "Intelligent Scenario Model via ADT",
"originalLanguage": "en"
},
"generalInformation": {
"modelName": "RM_TEST_ADT_976_MOD",
"modelType": "SAPGENAI",
"intelligentScenario": "RM_TEST_ADT_976",
"modellingContextId": "7FD071C0C04C56148FE3424E30FFB40B",
"adapterId": "SAPGENAI.Default",
"nativeModelType": "SAPGENAI.Default",
"state": "Published",
"executableId": "azure-openai",
"llmName": "gpt-4",
"llmVersion": "0613"
},
"modelPromptTemplates": [
{
"promptTemplateName": "SYSTEM_PROMPT",
"promptTemplateDescription": "System prompt",
"prompt": "You are a sales executive who is responsible for reaching out to customers for confirming or declining their orders. Evaluate the size of the delivery vehicle based on the number of items. Calculate the distance between the billing and delivery location in kilometers. \r\n\r\nThe subject of email should be of format <Confirmation on order number: {order_number} placed on {booking_date}> \r\nThe body of email should be of format: \"\"SO contains <Category> to be delivered to <Location>. And will be delivered via a <size> vehicle. \r\nIF <distance between source address and delivery address> > 100 kms THEN include a message about potential delivery delays ELSE congratulate on being eligible for one day delivery",
"promptParameters": "[]",
"isVisible": true
},
{
"promptTemplateName": "USER_PROMPT",
"promptTemplateDescription": "User prompt",
"prompt": "Build a confirmation mail for a sales order containing {ISLM_Items} where the items are categorized for example pencil and paper will be stationary, printer and mouse will be electronics. The source address contains {ISLM_Source} and the delivery address is in {ISLM_Destination}.",
"promptParameters": "[{\"Name\":\"ISLM_Items\",\"Value\":\"\"},{\"Name\":\"ISLM_Source\",\"Value\":\"\"},{\"Name\":\"ISLM_Destination\",\"Value\":\"\"}]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to #671 (comment). If it is always name-value or an empty list , it could look like this in AFF:

Suggested change
"promptParameters": "[{\"Name\":\"ISLM_Items\",\"Value\":\"\"},{\"Name\":\"ISLM_Source\",\"Value\":\"\"},{\"Name\":\"ISLM_Destination\",\"Value\":\"\"}]",
"promptParameters": [
{ "Name": "ISLM_Items",
"Value": ""
},
{ "Name": "ISLM_Source",
"Value ": ""
},
{ "Name ": "ISLM_Destination",
"Value": ""
}
]",

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be discussed next week

Copy link

@raghav6676 raghav6676 Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, our logic in AFF persistence class only builds the JSON and pass to string field, which is necessary for passing the parameters in the prompt execution.
image

image

Does AFF/ADT framework stringify the JSON in the source? I mean the / in the output.

Also another comment on this VALUE field - This is empty as of now, but as I mentioned earlier, we will definitely implement the default values option as user input in the ADT UI. Similar to our Fiori UI,
image
So, this default parameters is future scope for ADT.

Copy link
Contributor

@schneidermic0 schneidermic0 Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does AFF/ADT framework stringify the JSON in the source? I mean the / in the output.

Since you put JSON in a string field consisting of certain characters (to be precise: quotes (")), these quotes must be escaped by \.

Nevertheless, even without escaping, it would be nicer if you don't put the JSON into a string, but just using it as real JSON. Still, I am not sure whether this is possible in your case, but maybe it's worth to discuss.

Did you get my idea?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I got your point that you want to keep it as real JSON. We kept it as string because we do store the prompt parameters in DB as a string.
If we keep it as real JSON, then we need to serialize it and store in the DB.
Also, AFF has to be changed for prompt_parameters field, which needs to be declared as a deep table within prompts table. Is it possible?

"isVisible": true
}
]
}
233 changes: 233 additions & 0 deletions file-formats/intm/intm-v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
{
"$comment": "This file is autogenerated, do not edit manually, see https://github.com/SAP/abap-file-formats for more information.",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/intm/intm-v1.json",
"title": "Intelligent scenario Model",
"description": "Intelligent scenario model",
"type": "object",
"properties": {
"formatVersion": {
"title": "ABAP File Format Version",
"description": "The ABAP file format version",
"type": "string",
"const": "1"
},
"header": {
"title": "Header",
"description": "Header",
"type": "object",
"properties": {
"description": {
"title": "Description",
"description": "Description of the ABAP object",
"type": "string",
"maxLength": 60
},
"originalLanguage": {
"title": "Original Language",
"description": "Original language of the ABAP object",
"type": "string",
"minLength": 2
},
"abapLanguageVersion": {
"title": "ABAP Language Version",
"description": "ABAP language version",
"type": "string",
"enum": [
"standard",
"keyUser",
"cloudDevelopment"
],
"enumTitles": [
"Standard",
"ABAP for Key Users",
"ABAP Cloud Development"
],
"enumDescriptions": [
"Standard",
"ABAP for key user extensibility",
"ABAP cloud development"
],
"default": "standard"
}
},
"additionalProperties": false,
"required": [
"description",
"originalLanguage"
]
},
"generalInformation": {
"title": "General Information",
"description": "General information",
"type": "object",
"properties": {
"modelName": {
"title": "Model Name",
"description": "Model name",
"type": "string",
"maxLength": 30
},
"modelType": {
"title": "Model Type",
"description": "Model type",
"type": "string",
"maxLength": 256
},
"intelligentScenario": {
"title": "Intelligent Scenario",
"description": "Intelligent scenario of the model",
"type": "string",
"maxLength": 20
},
"modellingContextId": {
"title": "Modelling Context ID",
"description": "Modelling context ID which is the parent of the model",
"type": "string",
"maxLength": 36
},
"adapterId": {
"title": "Adapter ID",
"description": "Adapter ID",
"type": "string",
"maxLength": 32
},
"nativeModelType": {
"title": "Native Model Type",
"description": "Native model type",
"type": "string",
"maxLength": 256
},
"modelSpecification": {
"title": "Model Specification",
"description": "Model specification",
"type": "string"
},
"modelDefinition": {
"title": "Model Definition",
"description": "Model definition",
"type": "string"
},
"state": {
"title": "State",
"description": "State of the model",
"type": "string",
"maxLength": 10
},
"signature": {
"title": "Signature",
"description": "Model signature",
"type": "string"
},
"bindings": {
"title": "Bindings",
"description": "Model bindings",
"type": "string"
},
"isEnhancement": {
"title": "Is Enhancement",
"description": "If true, the model is an enhancement, if false the model is a new model.",
"type": "boolean"
},
"executableId": {
"title": "Executable ID",
"description": "Executable ID",
"type": "string",
"maxLength": 64
},
"llmName": {
"title": "Large Language Model Name",
"description": "Large language model name",
"type": "string"
},
"llmVersion": {
"title": "Large Language Model Version",
"description": "Large language model version",
"type": "string",
"maxLength": 30
}
},
"additionalProperties": false
},
"modelSegmentFields": {
"title": "Model Segment Fields",
"description": "Model segment fields",
"type": "array",
"items": {
"title": "Segment Field",
"description": "Model segment field",
"type": "object",
"properties": {
"fieldName": {
"title": "Field Name",
"description": "Table or view field name",
"type": "string",
"maxLength": 30
},
"fieldPosition": {
"title": "Field Position",
"description": "Field position",
"type": "integer",
"minimum": -2147483648,
"maximum": 2147483647
},
"isKey": {
"title": "Is Key Field",
"description": "If true, the field is a key field",
"type": "boolean"
}
},
"additionalProperties": false
}
},
"modelPromptTemplates": {
"title": "Model Prompt Templates",
"description": "Model prompt templates",
"type": "array",
"items": {
"title": "Model Prompt Template",
"description": "Model prompt template",
"type": "object",
"properties": {
"promptTemplateName": {
"title": "Prompt Template Name",
"description": "Prompt template name",
"type": "string",
"maxLength": 30
},
"promptTemplateDescription": {
"title": "Prompt Template Description",
"description": "Description of prompt template",
"type": "string"
},
"prompt": {
"title": "Prompt",
"description": "Prompt",
"type": "string"
},
"promptParameters": {
"title": "Prompt Parameters",
"description": "Prompt parameters",
"type": "string"
},
"isVisible": {
"title": "Prompt Visibility",
"description": "If true, the prompt is visible",
"type": "boolean"
}
},
"additionalProperties": false,
"required": [
"promptTemplateName",
"prompt"
]
}
}
},
"additionalProperties": false,
"required": [
"formatVersion",
"header",
"generalInformation"
]
}
111 changes: 111 additions & 0 deletions file-formats/intm/type/zif_aff_intm_v1.intf.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
INTERFACE zif_aff_intm_v1
PUBLIC.

TYPES:
"! <p class="shorttext">General Information</p>
"! General information
BEGIN OF ty_general_information,
"! <p class="shorttext">Model Name</p>
"! Model name
model_name TYPE c LENGTH 30,
"! <p class="shorttext">Model Type</p>
"! Model type
model_type TYPE c LENGTH 256,
"! <p class="shorttext">Intelligent Scenario</p>
"! Intelligent scenario of the model
intelligent_scenario TYPE c LENGTH 20,
"! <p class="shorttext">Modelling Context ID</p>
"! Modelling context ID which is the parent of the model
modelling_context_id TYPE c LENGTH 36,
"! <p class="shorttext">Adapter ID</p>
"! Adapter ID
adapter_id TYPE c LENGTH 32,
"! <p class="shorttext">Native Model Type</p>
"! Native model type
native_model_type TYPE c LENGTH 256,
"! <p class="shorttext">Model Specification</p>
"! Model specification
model_specification TYPE string,
raghav6686 marked this conversation as resolved.
Show resolved Hide resolved
"! <p class="shorttext">Model Definition</p>
"! Model definition
model_definition TYPE string,
"! <p class="shorttext">State</p>
"! State of the model
state TYPE c LENGTH 10,
raghav6686 marked this conversation as resolved.
Show resolved Hide resolved
"! <p class="shorttext">Signature</p>
"! Model signature
signature TYPE string,
"! <p class="shorttext">Bindings</p>
"! Model bindings
bindings TYPE string,
"! <p class="shorttext">Is Enhancement</p>
"! If true, the model is an enhancement, if false the model is a new model.
is_enhancement TYPE abap_bool,
"! <p class="shorttext">Executable ID</p>
"! Executable ID
executable_id TYPE c LENGTH 64,
"! <p class="shorttext">Large Language Model Name</p>
"! Large language model name
llm_name TYPE string,
"! <p class="shorttext">Large Language Model Version</p>
"! Large language model version
llm_version TYPE c LENGTH 30,
END OF ty_general_information,

"! <p class="shorttext">Segment Field</p>
"! Model segment field
BEGIN OF ty_segment_field,
"! <p class="shorttext">Field Name</p>
"! Table or view field name
field_name TYPE c LENGTH 30,
"! <p class="shorttext">Field Position</p>
"! Field position
field_position TYPE i,
schneidermic0 marked this conversation as resolved.
Show resolved Hide resolved
"! <p class="shorttext">Is Key Field</p>
"! If true, the field is a key field
is_key TYPE abap_bool,
END OF ty_segment_field,

"! <p class="shorttext">Model Prompt Template</p>
"! Model prompt template
BEGIN OF ty_prompt_template,
"! <p class="shorttext">Prompt Template Name</p>
"! Prompt template name
"! $required
prompt_template_name TYPE c LENGTH 30,
"! <p class="shorttext">Prompt Template Description</p>
"! Description of prompt template
prompt_template_description TYPE string,
"! <p class="shorttext">Prompt</p>
"! Prompt
"! $required
prompt TYPE string,
"! <p class="shorttext">Prompt Parameters</p>
"! Prompt parameters
prompt_parameters TYPE string,
"! <p class="shorttext">Prompt Visibility</p>
"! If true, the prompt is visible
is_visible TYPE abap_bool,
END OF ty_prompt_template,

"! <p class="shorttext">Intelligent scenario Model</p>
"! Intelligent scenario model
BEGIN OF ty_main,
"! $required
format_version TYPE zif_aff_types_v1=>ty_format_version,
"! <p class="shorttext">Header</p>
"! Header
"! $required
header TYPE zif_aff_types_v1=>ty_header_60,
"! <p class="shorttext">General Information</p>
"! General information
"! $required
general_information TYPE ty_general_information,
"! <p class="shorttext">Model Segment Fields</p>
"! Model segment fields
model_segment_fields TYPE STANDARD TABLE OF ty_segment_field WITH DEFAULT KEY,
"! <p class="shorttext">Model Prompt Templates</p>
"! Model prompt templates
model_prompt_templates TYPE STANDARD TABLE OF ty_prompt_template WITH DEFAULT KEY,
END OF ty_main.
ENDINTERFACE.
7 changes: 7 additions & 0 deletions file-formats/intm/type/zif_aff_intm_v1.intf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"formatVersion": "1",
"header": {
"description": "Intelligent Scenario Model (INTM)",
"originalLanguage": "en"
}
}
Loading