@takeshape/schema 10.21.0 → 10.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WAAW,EAAC,MAAM,KAAK,CAAC;AAGvD,OAAO,EAAwB,KAAK,yBAAyB,EAAC,MAAM,mBAAmB,CAAC;AAKxF,OAAO,EAEL,KAAK,YAAY,EAKlB,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAC,KAAK,WAAW,EAAC,MAAM,WAAW,CAAC;AA6B3C,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EAYlB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAC,mBAAmB,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AAChF,OAAO,KAAK,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WAAW,EAAC,MAAM,KAAK,CAAC;AAGvD,OAAO,EAAwB,KAAK,yBAAyB,EAAC,MAAM,mBAAmB,CAAC;AAKxF,OAAO,EAEL,KAAK,YAAY,EAKlB,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAC,KAAK,WAAW,EAAC,MAAM,WAAW,CAAC;AA6B3C,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EAYlB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAC,mBAAmB,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AAChF,OAAO,KAAK,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAm3B1D,MAAM,MAAM,sBAAsB,GAC9B;IAAC,KAAK,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,oBAAoB,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAC,GAC9D;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,yBAAyB,EAAE,CAAA;CAAC,CAAC;AAE3E,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,yBAAyB,CAuBzE;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,CAAC,aAAa,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IAC/C,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,qBAAqB,KAAK,sBAAsB,CAAC;CACxF,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG;IAClC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAEpE,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,YAAY,EAAE,YAAY,CAAC;CAC5B,GAAG,qBAAqB,CAAC;AAE1B,MAAM,MAAM,yBAAyB,GAAG,WAAW,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;AAmHrF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,qBAA0B,GAAG,sBAAsB,CAW9G;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAgC5G;AAED,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,GAAG,iBAAiB,CAgB7E;AAgBD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,OAAO,GAAG,SAAS,CAQpE;AAgBD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,CAQrE;AAED,MAAM,MAAM,mCAAmC,GAC3C;IAAC,KAAK,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,mBAAmB,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAC,GAC7D;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,yBAAyB,EAAE,CAAA;CAAC,CAAC;AAE3E;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,OAAO,GAAG,mCAAmC,CAIrG;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,OAAO,GAAG,mBAAmB,CAQxF"}
|
package/dist/validate.js
CHANGED
|
@@ -544,7 +544,8 @@ async function validateRefs(context, projectSchema) {
|
|
|
544
544
|
path: item.path,
|
|
545
545
|
message: `Invalid ref "${(0, _get.default)(projectSchema, item.path)}"`
|
|
546
546
|
});
|
|
547
|
-
} else if (mustBeInterface(item)) {
|
|
547
|
+
} else if (mustBeInterface(item) && (layerId === 'local' || layer?.status === 'ok')) {
|
|
548
|
+
// only validate interfaces with connected layers isValidRef above handles when allowDisconnectedLayers false
|
|
548
549
|
const context = layer?.schema ?? projectSchema;
|
|
549
550
|
const shape = (0, _get.default)(context, item.path.slice(0, 2));
|
|
550
551
|
errors.push(...validateShapeImplementsInterface(context, shape, item, item.path));
|
package/es/validate.js
CHANGED
|
@@ -530,7 +530,8 @@ async function validateRefs(context, projectSchema) {
|
|
|
530
530
|
path: item.path,
|
|
531
531
|
message: `Invalid ref "${get(projectSchema, item.path)}"`
|
|
532
532
|
});
|
|
533
|
-
} else if (mustBeInterface(item)) {
|
|
533
|
+
} else if (mustBeInterface(item) && (layerId === 'local' || layer?.status === 'ok')) {
|
|
534
|
+
// only validate interfaces with connected layers isValidRef above handles when allowDisconnectedLayers false
|
|
534
535
|
const context = layer?.schema ?? projectSchema;
|
|
535
536
|
const shape = get(context, item.path.slice(0, 2));
|
|
536
537
|
errors.push(...validateShapeImplementsInterface(context, shape, item, item.path));
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
{
|
|
2
|
+
"projectId": "projectId",
|
|
3
|
+
"defaultLocale": "en-us",
|
|
4
|
+
"locales": ["en-us"],
|
|
5
|
+
"queries": {
|
|
6
|
+
"getIndexedBooksBookList": {
|
|
7
|
+
"shape": "books:BookPaginatedList",
|
|
8
|
+
"resolver": {
|
|
9
|
+
"shapeName": "Books_Book",
|
|
10
|
+
"name": "takeshape:queryApiIndex",
|
|
11
|
+
"service": "takeshape"
|
|
12
|
+
},
|
|
13
|
+
"description": "Fetch Books_Book data from the API Index.",
|
|
14
|
+
"args": "TSListArgs<Books_Book>"
|
|
15
|
+
},
|
|
16
|
+
"getRelatedBookList": {
|
|
17
|
+
"shape": "books:BookPaginatedList",
|
|
18
|
+
"resolver": {
|
|
19
|
+
"compose": [
|
|
20
|
+
{
|
|
21
|
+
"name": "delegate",
|
|
22
|
+
"id": "createEmbedding",
|
|
23
|
+
"to": "openai:Mutation.createEmbedding",
|
|
24
|
+
"args": {
|
|
25
|
+
"ops": [
|
|
26
|
+
{
|
|
27
|
+
"path": "input",
|
|
28
|
+
"value": {
|
|
29
|
+
"model": "text-embedding-3-small",
|
|
30
|
+
"encoding_format": "float"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{"path": "input.input", "mapping": "$args.text"}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"results": {
|
|
37
|
+
"ops": [
|
|
38
|
+
{
|
|
39
|
+
"path": "vector",
|
|
40
|
+
"mapping": "$currentResolver.data[0].embedding"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"shapeName": "Books_Book",
|
|
47
|
+
"name": "takeshape:vectorSearch",
|
|
48
|
+
"service": "takeshape",
|
|
49
|
+
"args": {
|
|
50
|
+
"ops": [
|
|
51
|
+
{"path": "vector.name", "value": "vector"},
|
|
52
|
+
{
|
|
53
|
+
"path": "vector.value",
|
|
54
|
+
"mapping": "$resolvers.createEmbedding.vector"
|
|
55
|
+
},
|
|
56
|
+
{"path": "size", "mapping": "$args.size"}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
"args": {
|
|
63
|
+
"type": "object",
|
|
64
|
+
"properties": {"text": {"type": "string"}, "size": {"type": "integer"}},
|
|
65
|
+
"required": ["text"]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"chat": {
|
|
69
|
+
"shape": "string",
|
|
70
|
+
"resolver": {
|
|
71
|
+
"compose": [
|
|
72
|
+
{
|
|
73
|
+
"name": "delegate",
|
|
74
|
+
"id": "getRelatedBookList",
|
|
75
|
+
"to": "Query.getRelatedBookList",
|
|
76
|
+
"options": {"selectionSet": "{ items {title bodyHtml} }"},
|
|
77
|
+
"args": {
|
|
78
|
+
"ops": [
|
|
79
|
+
{"path": "text", "mapping": "$args.text"},
|
|
80
|
+
{"path": "size", "value": 1}
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"results": {
|
|
84
|
+
"ops": [{"path": "$", "mapping": "$currentResolver.items[0]"}]
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"name": "delegate",
|
|
89
|
+
"to": "openai:Mutation.createChatCompletion",
|
|
90
|
+
"options": {
|
|
91
|
+
"selectionSet": "{ choices { message { role content } } }"
|
|
92
|
+
},
|
|
93
|
+
"args": {
|
|
94
|
+
"ops": [
|
|
95
|
+
{
|
|
96
|
+
"path": "input",
|
|
97
|
+
"value": {
|
|
98
|
+
"model": "gpt-3.5-turbo",
|
|
99
|
+
"messages": [
|
|
100
|
+
{
|
|
101
|
+
"role": "system",
|
|
102
|
+
"content": "You are a helpful assistant."
|
|
103
|
+
},
|
|
104
|
+
{"role": "user", "content": ""}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"path": "input.messages[1].content",
|
|
110
|
+
"mapping": [
|
|
111
|
+
[
|
|
112
|
+
"get",
|
|
113
|
+
{
|
|
114
|
+
"path": [
|
|
115
|
+
"$args.text",
|
|
116
|
+
"$resolvers.getRelatedBookList.title",
|
|
117
|
+
"$resolvers.getRelatedBookList.bodyHtml"
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
"format",
|
|
123
|
+
{
|
|
124
|
+
"template": "Answer the following question:\n %s\n by using the following text:\n %s %s"
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
"results": {
|
|
132
|
+
"ops": [
|
|
133
|
+
{
|
|
134
|
+
"path": "$",
|
|
135
|
+
"mapping": "$currentResolver.choices[0].message.content"
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
"args": {
|
|
143
|
+
"type": "object",
|
|
144
|
+
"properties": {"text": {"type": "string"}},
|
|
145
|
+
"required": ["text"]
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"Books_getBookList": {
|
|
149
|
+
"resolver": {
|
|
150
|
+
"name": "graphql:query",
|
|
151
|
+
"service": "books",
|
|
152
|
+
"fieldName": "getBookList"
|
|
153
|
+
},
|
|
154
|
+
"args": {
|
|
155
|
+
"type": "object",
|
|
156
|
+
"properties": {
|
|
157
|
+
"terms": {"type": "string"},
|
|
158
|
+
"from": {
|
|
159
|
+
"type": "integer",
|
|
160
|
+
"description": "The offset from the first result you want to fetch."
|
|
161
|
+
},
|
|
162
|
+
"size": {
|
|
163
|
+
"type": "integer",
|
|
164
|
+
"description": "The maximum number of items to return."
|
|
165
|
+
},
|
|
166
|
+
"filter": {
|
|
167
|
+
"description": "An elasticsearch style filter. Overrides onlyEnabled.",
|
|
168
|
+
"@tag": "JSONObject"
|
|
169
|
+
},
|
|
170
|
+
"sort": {
|
|
171
|
+
"type": "array",
|
|
172
|
+
"items": {"@ref": "books:TSSearchSortInput"},
|
|
173
|
+
"description": "An list of fields to sort by."
|
|
174
|
+
},
|
|
175
|
+
"locale": {"type": "string"},
|
|
176
|
+
"enableLocaleFallback": {"type": "boolean", "default": true},
|
|
177
|
+
"onlyEnabled": {
|
|
178
|
+
"type": "boolean",
|
|
179
|
+
"description": "Filter out content that is not enabled. Defaults to true.",
|
|
180
|
+
"default": true
|
|
181
|
+
},
|
|
182
|
+
"where": {
|
|
183
|
+
"@ref": "books:TSWhereBookInput",
|
|
184
|
+
"description": "The where clause uses the boolean AND, OR, and NOT parameters to construct complex filters based on the values of your fields. It applies an implicit AND to all the top-level keys. To avoid this, use a single OR or NOT key as the only top-level key."
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"shape": "books:BookPaginatedList"
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"mutations": {
|
|
192
|
+
"OpenAI_createEmbedding": {
|
|
193
|
+
"shape": "OpenAI_CreateEmbeddingResponse",
|
|
194
|
+
"resolver": {
|
|
195
|
+
"name": "rest:post",
|
|
196
|
+
"service": "openai",
|
|
197
|
+
"path": "/embeddings",
|
|
198
|
+
"body": {
|
|
199
|
+
"ops": [{"path": "$", "mapping": "$args.input"}],
|
|
200
|
+
"serialize": {"content": {"contentType": "application/json"}}
|
|
201
|
+
},
|
|
202
|
+
"headers": {
|
|
203
|
+
"ops": [{"path": "content-type", "value": "application/json"}]
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
"description": "Creates an embedding vector representing the input text.",
|
|
207
|
+
"args": {
|
|
208
|
+
"type": "object",
|
|
209
|
+
"properties": {"input": {"@ref": "openai:CreateEmbeddingInput"}},
|
|
210
|
+
"required": ["input"]
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"OpenAI_createChatCompletion": {
|
|
214
|
+
"shape": "OpenAI_CreateChatCompletionResponse",
|
|
215
|
+
"resolver": {
|
|
216
|
+
"name": "rest:post",
|
|
217
|
+
"service": "openai",
|
|
218
|
+
"path": "/chat/completions",
|
|
219
|
+
"body": {
|
|
220
|
+
"ops": [{"path": "$", "mapping": "$args.input"}],
|
|
221
|
+
"serialize": {"content": {"contentType": "application/json"}}
|
|
222
|
+
},
|
|
223
|
+
"headers": {
|
|
224
|
+
"ops": [{"path": "content-type", "value": "application/json"}]
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
"description": "Creates a model response for the given chat conversation.",
|
|
228
|
+
"args": {
|
|
229
|
+
"type": "object",
|
|
230
|
+
"properties": {"input": {"@ref": "openai:CreateChatCompletionInput"}},
|
|
231
|
+
"required": ["input"]
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
"shapes": {
|
|
236
|
+
"Books_Book": {
|
|
237
|
+
"id": "Books_Book",
|
|
238
|
+
"name": "Books_Book",
|
|
239
|
+
"title": "Books Book",
|
|
240
|
+
"cache": {
|
|
241
|
+
"enabled": true,
|
|
242
|
+
"triggers": [{"type": "schedule", "loader": "list", "interval": 1440}],
|
|
243
|
+
"fragment": {"maxDepth": 2}
|
|
244
|
+
},
|
|
245
|
+
"loaders": {"list": {"query": "books:Query.getBookList"}},
|
|
246
|
+
"schema": {
|
|
247
|
+
"extends": [
|
|
248
|
+
{"@ref": "books:Book"},
|
|
249
|
+
{
|
|
250
|
+
"type": "object",
|
|
251
|
+
"properties": {
|
|
252
|
+
"vector": {
|
|
253
|
+
"type": "array",
|
|
254
|
+
"items": {"type": "number"},
|
|
255
|
+
"title": "Vector",
|
|
256
|
+
"@tag": "vector",
|
|
257
|
+
"@dependencies": "{title bodyHtml}",
|
|
258
|
+
"@resolver": {
|
|
259
|
+
"name": "delegate",
|
|
260
|
+
"to": "openai:Mutation.createEmbedding",
|
|
261
|
+
"options": {"selectionSet": "{ data { embedding } }"},
|
|
262
|
+
"args": {
|
|
263
|
+
"ops": [
|
|
264
|
+
{
|
|
265
|
+
"path": "input",
|
|
266
|
+
"value": {
|
|
267
|
+
"model": "text-embedding-3-small",
|
|
268
|
+
"encoding_format": "float"
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"path": "input.input",
|
|
273
|
+
"mapping": [
|
|
274
|
+
[
|
|
275
|
+
"get",
|
|
276
|
+
{"path": ["$source.title", "$source.bodyHtml"]}
|
|
277
|
+
],
|
|
278
|
+
["format", {"template": "%s %s"}]
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
]
|
|
282
|
+
},
|
|
283
|
+
"results": {
|
|
284
|
+
"ops": [
|
|
285
|
+
{
|
|
286
|
+
"path": "$",
|
|
287
|
+
"mapping": "$finalResolver.data[0].embedding"
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
]
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
"workflows": {},
|
|
300
|
+
"forms": {
|
|
301
|
+
"Books_Book": {
|
|
302
|
+
"default": {
|
|
303
|
+
"properties": {
|
|
304
|
+
"content": {"widget": "singleLineText"},
|
|
305
|
+
"vector": {"widget": "singleLineText"}
|
|
306
|
+
},
|
|
307
|
+
"order": ["content", "vector"]
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
"schemaVersion": "3.41.0",
|
|
312
|
+
"apiVersion": "2",
|
|
313
|
+
"services": {
|
|
314
|
+
"openai": {
|
|
315
|
+
"id": "openai",
|
|
316
|
+
"title": "OpenAI",
|
|
317
|
+
"namespace": "OpenAI",
|
|
318
|
+
"provider": "openai",
|
|
319
|
+
"serviceType": "openapi",
|
|
320
|
+
"authenticationType": "bearer",
|
|
321
|
+
"options": {
|
|
322
|
+
"endpoint": "https://api.openai.com/v1/",
|
|
323
|
+
"spec": "https://raw.githubusercontent.com/takeshape/openapi-specs/813784d8fcac5b3fd4e468ce6f715b89c9fcb73f/specs/openai/v2.yml",
|
|
324
|
+
"transformVersion": "2.0.0",
|
|
325
|
+
"introspectedAt": "2024-04-15T20:22:53.202Z"
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
"books": {
|
|
329
|
+
"id": "books",
|
|
330
|
+
"title": "Books",
|
|
331
|
+
"namespace": "Books",
|
|
332
|
+
"provider": "graphql",
|
|
333
|
+
"serviceType": "graphql",
|
|
334
|
+
"authenticationType": "bearer",
|
|
335
|
+
"options": {
|
|
336
|
+
"endpoint": "https://api.takeshape.io/project/18f690a1-3977-4dc9-a888-bee3293b12e2/production/graphql",
|
|
337
|
+
"introspectedAt": "2024-04-16T02:55:23.258Z"
|
|
338
|
+
},
|
|
339
|
+
"healthCheck": {"checkName": "graphqlIntrospection"}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
{
|
|
2
|
+
"projectId": "projectId",
|
|
3
|
+
"defaultLocale": "en-us",
|
|
4
|
+
"locales": ["en-us"],
|
|
5
|
+
"queries": {
|
|
6
|
+
"getIndexedBooksBookList": {
|
|
7
|
+
"shape": "books:BookPaginatedList",
|
|
8
|
+
"resolver": {
|
|
9
|
+
"shapeName": "Books_Book",
|
|
10
|
+
"name": "takeshape:queryApiIndex",
|
|
11
|
+
"service": "takeshape"
|
|
12
|
+
},
|
|
13
|
+
"description": "Fetch Books_Book data from the API Index.",
|
|
14
|
+
"args": "TSListArgs<Books_Book>"
|
|
15
|
+
},
|
|
16
|
+
"getRelatedBookList": {
|
|
17
|
+
"shape": "books:BookPaginatedList",
|
|
18
|
+
"resolver": {
|
|
19
|
+
"compose": [
|
|
20
|
+
{
|
|
21
|
+
"name": "delegate",
|
|
22
|
+
"id": "createEmbedding",
|
|
23
|
+
"to": "openai:Mutation.createEmbedding",
|
|
24
|
+
"args": {
|
|
25
|
+
"ops": [
|
|
26
|
+
{
|
|
27
|
+
"path": "input",
|
|
28
|
+
"value": {
|
|
29
|
+
"model": "text-embedding-3-small",
|
|
30
|
+
"encoding_format": "float"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{"path": "input.input", "mapping": "$args.text"}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"results": {
|
|
37
|
+
"ops": [
|
|
38
|
+
{
|
|
39
|
+
"path": "vector",
|
|
40
|
+
"mapping": "$currentResolver.data[0].embedding"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"shapeName": "Books_Book",
|
|
47
|
+
"name": "takeshape:vectorSearch",
|
|
48
|
+
"service": "takeshape",
|
|
49
|
+
"args": {
|
|
50
|
+
"ops": [
|
|
51
|
+
{"path": "vector.name", "value": "vector"},
|
|
52
|
+
{
|
|
53
|
+
"path": "vector.value",
|
|
54
|
+
"mapping": "$resolvers.createEmbedding.vector"
|
|
55
|
+
},
|
|
56
|
+
{"path": "size", "mapping": "$args.size"}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
"args": {
|
|
63
|
+
"type": "object",
|
|
64
|
+
"properties": {"text": {"type": "string"}, "size": {"type": "integer"}},
|
|
65
|
+
"required": ["text"]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"chat": {
|
|
69
|
+
"shape": "string",
|
|
70
|
+
"resolver": {
|
|
71
|
+
"compose": [
|
|
72
|
+
{
|
|
73
|
+
"name": "delegate",
|
|
74
|
+
"id": "getRelatedBookList",
|
|
75
|
+
"to": "Query.getRelatedBookList",
|
|
76
|
+
"options": {"selectionSet": "{ items {title bodyHtml} }"},
|
|
77
|
+
"args": {
|
|
78
|
+
"ops": [
|
|
79
|
+
{"path": "text", "mapping": "$args.text"},
|
|
80
|
+
{"path": "size", "value": 1}
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"results": {
|
|
84
|
+
"ops": [{"path": "$", "mapping": "$currentResolver.items[0]"}]
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"name": "delegate",
|
|
89
|
+
"to": "openai:Mutation.createChatCompletion",
|
|
90
|
+
"options": {
|
|
91
|
+
"selectionSet": "{ choices { message { role content } } }"
|
|
92
|
+
},
|
|
93
|
+
"args": {
|
|
94
|
+
"ops": [
|
|
95
|
+
{
|
|
96
|
+
"path": "input",
|
|
97
|
+
"value": {
|
|
98
|
+
"model": "gpt-3.5-turbo",
|
|
99
|
+
"messages": [
|
|
100
|
+
{
|
|
101
|
+
"role": "system",
|
|
102
|
+
"content": "You are a helpful assistant."
|
|
103
|
+
},
|
|
104
|
+
{"role": "user", "content": ""}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"path": "input.messages[1].content",
|
|
110
|
+
"mapping": [
|
|
111
|
+
[
|
|
112
|
+
"get",
|
|
113
|
+
{
|
|
114
|
+
"path": [
|
|
115
|
+
"$args.text",
|
|
116
|
+
"$resolvers.getRelatedBookList.title",
|
|
117
|
+
"$resolvers.getRelatedBookList.bodyHtml"
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
"format",
|
|
123
|
+
{
|
|
124
|
+
"template": "Answer the following question:\n %s\n by using the following text:\n %s %s"
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
"results": {
|
|
132
|
+
"ops": [
|
|
133
|
+
{
|
|
134
|
+
"path": "$",
|
|
135
|
+
"mapping": "$currentResolver.choices[0].message.content"
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
"args": {
|
|
143
|
+
"type": "object",
|
|
144
|
+
"properties": {"text": {"type": "string"}},
|
|
145
|
+
"required": ["text"]
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"Books_getBookList": {
|
|
149
|
+
"resolver": {
|
|
150
|
+
"name": "graphql:query",
|
|
151
|
+
"service": "books",
|
|
152
|
+
"fieldName": "getBookList"
|
|
153
|
+
},
|
|
154
|
+
"args": {
|
|
155
|
+
"type": "object",
|
|
156
|
+
"properties": {
|
|
157
|
+
"terms": {"type": "string"},
|
|
158
|
+
"from": {
|
|
159
|
+
"type": "integer",
|
|
160
|
+
"description": "The offset from the first result you want to fetch."
|
|
161
|
+
},
|
|
162
|
+
"size": {
|
|
163
|
+
"type": "integer",
|
|
164
|
+
"description": "The maximum number of items to return."
|
|
165
|
+
},
|
|
166
|
+
"filter": {
|
|
167
|
+
"description": "An elasticsearch style filter. Overrides onlyEnabled.",
|
|
168
|
+
"@tag": "JSONObject"
|
|
169
|
+
},
|
|
170
|
+
"sort": {
|
|
171
|
+
"type": "array",
|
|
172
|
+
"items": {"@ref": "books:TSSearchSortInput"},
|
|
173
|
+
"description": "An list of fields to sort by."
|
|
174
|
+
},
|
|
175
|
+
"locale": {"type": "string"},
|
|
176
|
+
"enableLocaleFallback": {"type": "boolean", "default": true},
|
|
177
|
+
"onlyEnabled": {
|
|
178
|
+
"type": "boolean",
|
|
179
|
+
"description": "Filter out content that is not enabled. Defaults to true.",
|
|
180
|
+
"default": true
|
|
181
|
+
},
|
|
182
|
+
"where": {
|
|
183
|
+
"@ref": "books:TSWhereBookInput",
|
|
184
|
+
"description": "The where clause uses the boolean AND, OR, and NOT parameters to construct complex filters based on the values of your fields. It applies an implicit AND to all the top-level keys. To avoid this, use a single OR or NOT key as the only top-level key."
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"shape": "books:BookPaginatedList"
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"mutations": {
|
|
192
|
+
"OpenAI_createEmbedding": {
|
|
193
|
+
"shape": "OpenAI_CreateEmbeddingResponse",
|
|
194
|
+
"resolver": {
|
|
195
|
+
"name": "rest:post",
|
|
196
|
+
"service": "openai",
|
|
197
|
+
"path": "/embeddings",
|
|
198
|
+
"body": {
|
|
199
|
+
"ops": [{"path": "$", "mapping": "$args.input"}],
|
|
200
|
+
"serialize": {"content": {"contentType": "application/json"}}
|
|
201
|
+
},
|
|
202
|
+
"headers": {
|
|
203
|
+
"ops": [{"path": "content-type", "value": "application/json"}]
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
"description": "Creates an embedding vector representing the input text.",
|
|
207
|
+
"args": {
|
|
208
|
+
"type": "object",
|
|
209
|
+
"properties": {"input": {"@ref": "openai:CreateEmbeddingInput"}},
|
|
210
|
+
"required": ["input"]
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"OpenAI_createChatCompletion": {
|
|
214
|
+
"shape": "OpenAI_CreateChatCompletionResponse",
|
|
215
|
+
"resolver": {
|
|
216
|
+
"name": "rest:post",
|
|
217
|
+
"service": "openai",
|
|
218
|
+
"path": "/chat/completions",
|
|
219
|
+
"body": {
|
|
220
|
+
"ops": [{"path": "$", "mapping": "$args.input"}],
|
|
221
|
+
"serialize": {"content": {"contentType": "application/json"}}
|
|
222
|
+
},
|
|
223
|
+
"headers": {
|
|
224
|
+
"ops": [{"path": "content-type", "value": "application/json"}]
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
"description": "Creates a model response for the given chat conversation.",
|
|
228
|
+
"args": {
|
|
229
|
+
"type": "object",
|
|
230
|
+
"properties": {"input": {"@ref": "openai:CreateChatCompletionInput"}},
|
|
231
|
+
"required": ["input"]
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
"shapes": {
|
|
236
|
+
"Books_Book": {
|
|
237
|
+
"id": "Books_Book",
|
|
238
|
+
"name": "Books_Book",
|
|
239
|
+
"title": "Books Book",
|
|
240
|
+
"cache": {
|
|
241
|
+
"enabled": true,
|
|
242
|
+
"triggers": [{"type": "schedule", "loader": "list", "interval": 1440}],
|
|
243
|
+
"fragment": {"maxDepth": 2}
|
|
244
|
+
},
|
|
245
|
+
"loaders": {"list": {"query": "books:Query.getBookList"}},
|
|
246
|
+
"schema": {
|
|
247
|
+
"extends": [
|
|
248
|
+
{"@ref": "books:Book"},
|
|
249
|
+
{
|
|
250
|
+
"type": "object",
|
|
251
|
+
"properties": {
|
|
252
|
+
"vector": {
|
|
253
|
+
"type": "array",
|
|
254
|
+
"items": {"type": "number"},
|
|
255
|
+
"title": "Vector",
|
|
256
|
+
"@tag": "vector",
|
|
257
|
+
"@dependencies": "{title bodyHtml}",
|
|
258
|
+
"@resolver": {
|
|
259
|
+
"name": "delegate",
|
|
260
|
+
"to": "openai:Mutation.createEmbedding",
|
|
261
|
+
"options": {"selectionSet": "{ data { embedding } }"},
|
|
262
|
+
"args": {
|
|
263
|
+
"ops": [
|
|
264
|
+
{
|
|
265
|
+
"path": "input",
|
|
266
|
+
"value": {
|
|
267
|
+
"model": "text-embedding-3-small",
|
|
268
|
+
"encoding_format": "float"
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"path": "input.input",
|
|
273
|
+
"mapping": [
|
|
274
|
+
[
|
|
275
|
+
"get",
|
|
276
|
+
{"path": ["$source.title", "$source.bodyHtml"]}
|
|
277
|
+
],
|
|
278
|
+
["format", {"template": "%s %s"}]
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
]
|
|
282
|
+
},
|
|
283
|
+
"results": {
|
|
284
|
+
"ops": [
|
|
285
|
+
{
|
|
286
|
+
"path": "$",
|
|
287
|
+
"mapping": "$finalResolver.data[0].embedding"
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
]
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
"workflows": {},
|
|
300
|
+
"forms": {
|
|
301
|
+
"Books_Book": {
|
|
302
|
+
"default": {
|
|
303
|
+
"properties": {
|
|
304
|
+
"content": {"widget": "singleLineText"},
|
|
305
|
+
"vector": {"widget": "singleLineText"}
|
|
306
|
+
},
|
|
307
|
+
"order": ["content", "vector"]
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
"schemaVersion": "3.41.0",
|
|
312
|
+
"apiVersion": "2",
|
|
313
|
+
"services": {
|
|
314
|
+
"openai": {
|
|
315
|
+
"id": "openai",
|
|
316
|
+
"title": "OpenAI",
|
|
317
|
+
"namespace": "OpenAI",
|
|
318
|
+
"provider": "openai",
|
|
319
|
+
"serviceType": "openapi",
|
|
320
|
+
"authenticationType": "bearer",
|
|
321
|
+
"options": {
|
|
322
|
+
"endpoint": "https://api.openai.com/v1/",
|
|
323
|
+
"spec": "https://raw.githubusercontent.com/takeshape/openapi-specs/813784d8fcac5b3fd4e468ce6f715b89c9fcb73f/specs/openai/v2.yml",
|
|
324
|
+
"transformVersion": "2.0.0",
|
|
325
|
+
"introspectedAt": "2024-04-15T20:22:53.202Z"
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
"books": {
|
|
329
|
+
"id": "books",
|
|
330
|
+
"title": "Books",
|
|
331
|
+
"namespace": "Books",
|
|
332
|
+
"provider": "graphql",
|
|
333
|
+
"serviceType": "graphql",
|
|
334
|
+
"authenticationType": "bearer",
|
|
335
|
+
"options": {
|
|
336
|
+
"endpoint": "https://api.takeshape.io/project/18f690a1-3977-4dc9-a888-bee3293b12e2/production/graphql",
|
|
337
|
+
"introspectedAt": "2024-04-16T02:55:23.258Z"
|
|
338
|
+
},
|
|
339
|
+
"healthCheck": {"checkName": "graphqlIntrospection"}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/schema",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.22.0",
|
|
4
4
|
"description": "TakeShape Schema",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"p-reduce": "^2.1.0",
|
|
29
29
|
"semver": "^7.3.2",
|
|
30
30
|
"tiny-invariant": "^1.2.0",
|
|
31
|
-
"@takeshape/
|
|
32
|
-
"@takeshape/
|
|
33
|
-
"@takeshape/util": "10.
|
|
31
|
+
"@takeshape/json-schema": "10.22.0",
|
|
32
|
+
"@takeshape/errors": "10.22.0",
|
|
33
|
+
"@takeshape/util": "10.22.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@takeshape/json-schema-to-typescript": "^11.0.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"meow": "^9.0.0",
|
|
47
47
|
"p-map": "^5.0.0",
|
|
48
48
|
"shortid": "^2.2.15",
|
|
49
|
-
"@takeshape/infra": "10.
|
|
49
|
+
"@takeshape/infra": "10.22.0"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=18"
|