-
Notifications
You must be signed in to change notification settings - Fork 1
/
watsonx-api-appconnect.yaml
303 lines (303 loc) · 10.7 KB
/
watsonx-api-appconnect.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
$integration: http://ibm.com/appconnect/integration/v2/integrationFile
integration:
type: api
trigger-interfaces:
trigger-interface-1:
triggers:
submitChatRequest:
assembly:
$ref: '#/integration/assemblies/assembly-1'
input-context:
data: ChatRequest
output-context:
data: ChatResponse
options:
resources:
- business-object: ChatRequest
model:
$ref: '#/models/ChatRequest'
triggers:
submit: submitChatRequest
- business-object: ChatResponse
model:
$ref: '#/models/ChatResponse'
triggers: {}
type: api-trigger
action-interfaces:
action-interface-1:
type: api-action
business-object: request
connector-type: http
account-name: watsonx
actions:
INVOKE: {}
assemblies:
assembly-1:
assembly:
execute:
- set-variable:
name: Set variable
map:
$map: http://ibm.com/appconnect/map/v1
customSchemas:
properties.`variable`:
type: object
properties:
role:
type: string
content:
type: string
input:
- variable: Request
$ref: '#/trigger/payload'
- variable: flowDetails
$ref: '#/flowDetails'
mappings:
- variable:
mappings:
- content:
template: '{{$Request.prompt}}'
- role:
template: user
- set-variable:
name: Set variable 2
map:
$map: http://ibm.com/appconnect/map/v1
customSchemas:
properties.`variable`:
type: object
properties:
model_id:
type: string
messages:
type: array
items:
type: object
properties:
role:
type: string
content:
type: string
parameters:
type: object
properties:
decoding_method:
type: string
repetition_penalty:
type: number
stop_sequences:
type: array
items:
type: string
include_stop_sequence:
type: boolean
min_new_tokens:
type: number
max_new_tokens:
type: number
moderations:
type: string
input:
- variable: Request
$ref: '#/trigger/payload'
- variable: Setvariable
$ref: '#/node-output/Set variable/response/payload'
- variable: flowDetails
$ref: '#/flowDetails'
mappings:
- variable:
mappings:
- messages:
foreach:
input: '$Setvariable.variable '
iterator: messagesItem
mappings:
- content:
template: '{{$messagesItem.content}}'
- role:
template: '{{$messagesItem.role}}'
- model_id:
template: '{{$Request.model}}'
- parameters:
mappings:
- decoding_method:
template: greedy
- include_stop_sequence:
expression: 'false'
- max_new_tokens:
expression: '1024'
- min_new_tokens:
expression: '1'
- repetition_penalty:
expression: '1.05'
- stop_sequences:
expression: '["<|endoftext|>"]'
- custom-action:
name: HTTP Invoke method
target:
$ref: '#/integration/action-interfaces/action-interface-1'
action: INVOKE
map:
customSchemas:
properties.`requestHeaders`:
type: object
properties:
Authorization:
type: string
Content-Type:
type: string
Accept:
type: string
mappings:
- method:
template: POST
- requestBody:
template: '{{$Setvariable2.variable}}'
- requestHeaders:
mappings:
- Accept:
template: application/json
- Authorization:
template: PLACEHOLDER FOR CREDENTIALS
- Content-Type:
template: application/json
- url:
template: PLACEHOLDER FOR API URL
$map: http://ibm.com/appconnect/map/v1
input:
- variable: Request
$ref: '#/trigger/payload'
- variable: Setvariable
$ref: '#/node-output/Set variable/response/payload'
- variable: Setvariable2
$ref: '#/node-output/Set variable 2/response/payload'
- variable: flowDetails
$ref: '#/flowDetails'
- parse:
name: JSON Parser Parse
parse-format: json
source:
template: '{{$HTTPInvokemethod.responseBody}}'
input:
- variable: Request
$ref: '#/trigger/payload'
- variable: Setvariable
$ref: '#/node-output/Set variable/response/payload'
- variable: Setvariable2
$ref: '#/node-output/Set variable 2/response/payload'
- variable: HTTPInvokemethod
$ref: '#/node-output/HTTP Invoke method/response/payload'
- variable: HTTPInvokemethodMetadata
$ref: '#/node-output/HTTP Invoke method/response'
- variable: flowDetails
$ref: '#/flowDetails'
sample-data: ''
output-schema:
$schema: http://json-schema.org/draft-04/schema#
type: object
properties:
id:
type: string
model_id:
type: string
created_at:
type: string
results:
type: array
items:
type: object
properties:
generated_text:
type: string
generated_token_count:
type: number
input_token_count:
type: number
stop_reason:
type: string
conversation_id:
type: string
title: Parsed JSON
- response:
name: response-1
reply-maps:
- title: ChatRequest successfully add custom operation
status-code: 200
map:
mappings:
- model:
template: '{{$Request.model}}'
- prompt:
template: '{{$Request.prompt}}'
- response:
template: '{{$JSONParserParse.results.generated_text}}'
$map: http://ibm.com/appconnect/map/v1
input:
- variable: Request
$ref: '#/trigger/payload'
- variable: Setvariable
$ref: '#/node-output/Set variable/response/payload'
- variable: Setvariable2
$ref: '#/node-output/Set variable 2/response/payload'
- variable: HTTPInvokemethod
$ref: '#/node-output/HTTP Invoke method/response/payload'
- variable: HTTPInvokemethodMetadata
$ref: '#/node-output/HTTP Invoke method/response'
- variable: JSONParserParse
$ref: '#/node-output/JSON Parser Parse/response/payload'
- variable: flowDetails
$ref: '#/flowDetails'
input: []
name: watsonx
models:
ChatRequest:
name: ChatRequest
properties:
prompt:
required: false
id: true
type: string
model:
required: false
id: false
type: string
plural: ChatRequest
description: ' '
operations:
submit: '#/integration/assemblies/assembly-1'
methods:
submit:
name: submit
display:
name: Submit prompt
accessType: WRITE
accepts:
- arg: data
type: ChatRequest
http:
source: body
returns:
arg: data
type: ChatResponse
root: true
http:
verb: POST
path: /submit
ChatResponse:
name: ChatResponse
properties:
prompt:
required: false
id: true
type: string
model:
required: false
id: false
type: string
response:
required: false
id: false
type: string
plural: ChatResponse
description: ' '
operations: {}