flowquery 1.0.15 → 1.0.17

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.
Files changed (333) hide show
  1. package/.github/workflows/python-publish.yml +97 -0
  2. package/dist/compute/runner.d.ts +3 -2
  3. package/dist/compute/runner.d.ts.map +1 -1
  4. package/dist/compute/runner.js +7 -7
  5. package/dist/compute/runner.js.map +1 -1
  6. package/dist/flowquery.min.js +1 -1
  7. package/dist/graph/data.d.ts +31 -0
  8. package/dist/graph/data.d.ts.map +1 -0
  9. package/dist/graph/data.js +110 -0
  10. package/dist/graph/data.js.map +1 -0
  11. package/dist/graph/database.d.ts +20 -0
  12. package/dist/graph/database.d.ts.map +1 -0
  13. package/dist/graph/database.js +77 -0
  14. package/dist/graph/database.js.map +1 -0
  15. package/dist/graph/hops.d.ts +11 -0
  16. package/dist/graph/hops.d.ts.map +1 -0
  17. package/dist/graph/hops.js +25 -0
  18. package/dist/graph/hops.js.map +1 -0
  19. package/dist/graph/node.d.ts +35 -0
  20. package/dist/graph/node.d.ts.map +1 -0
  21. package/dist/graph/node.js +113 -0
  22. package/dist/graph/node.js.map +1 -0
  23. package/dist/graph/node_data.d.ts +11 -0
  24. package/dist/graph/node_data.d.ts.map +1 -0
  25. package/dist/graph/node_data.js +20 -0
  26. package/dist/graph/node_data.js.map +1 -0
  27. package/dist/graph/node_reference.d.ts +10 -0
  28. package/dist/graph/node_reference.d.ts.map +1 -0
  29. package/dist/graph/node_reference.js +52 -0
  30. package/dist/graph/node_reference.js.map +1 -0
  31. package/dist/graph/pattern.d.ts +18 -0
  32. package/dist/graph/pattern.d.ts.map +1 -0
  33. package/dist/graph/pattern.js +114 -0
  34. package/dist/graph/pattern.js.map +1 -0
  35. package/dist/graph/pattern_expression.d.ts +14 -0
  36. package/dist/graph/pattern_expression.d.ts.map +1 -0
  37. package/dist/graph/pattern_expression.js +58 -0
  38. package/dist/graph/pattern_expression.js.map +1 -0
  39. package/dist/graph/patterns.d.ts +11 -0
  40. package/dist/graph/patterns.d.ts.map +1 -0
  41. package/dist/graph/patterns.js +49 -0
  42. package/dist/graph/patterns.js.map +1 -0
  43. package/dist/graph/physical_node.d.ts +10 -0
  44. package/dist/graph/physical_node.d.ts.map +1 -0
  45. package/dist/graph/physical_node.js +40 -0
  46. package/dist/graph/physical_node.js.map +1 -0
  47. package/dist/graph/physical_relationship.d.ts +10 -0
  48. package/dist/graph/physical_relationship.d.ts.map +1 -0
  49. package/dist/graph/physical_relationship.js +40 -0
  50. package/dist/graph/physical_relationship.js.map +1 -0
  51. package/dist/graph/relationship.d.ts +40 -0
  52. package/dist/graph/relationship.d.ts.map +1 -0
  53. package/dist/graph/relationship.js +124 -0
  54. package/dist/graph/relationship.js.map +1 -0
  55. package/dist/graph/relationship_data.d.ts +12 -0
  56. package/dist/graph/relationship_data.d.ts.map +1 -0
  57. package/dist/graph/relationship_data.js +40 -0
  58. package/dist/graph/relationship_data.js.map +1 -0
  59. package/dist/graph/relationship_match_collector.d.ts +19 -0
  60. package/dist/graph/relationship_match_collector.d.ts.map +1 -0
  61. package/dist/graph/relationship_match_collector.js +55 -0
  62. package/dist/graph/relationship_match_collector.js.map +1 -0
  63. package/dist/graph/relationship_reference.d.ts +8 -0
  64. package/dist/graph/relationship_reference.d.ts.map +1 -0
  65. package/dist/graph/relationship_reference.js +37 -0
  66. package/dist/graph/relationship_reference.js.map +1 -0
  67. package/dist/parsing/base_parser.d.ts +1 -0
  68. package/dist/parsing/base_parser.d.ts.map +1 -1
  69. package/dist/parsing/base_parser.js +4 -1
  70. package/dist/parsing/base_parser.js.map +1 -1
  71. package/dist/parsing/context.d.ts +2 -2
  72. package/dist/parsing/context.js +5 -5
  73. package/dist/parsing/expressions/boolean.d.ts +8 -0
  74. package/dist/parsing/expressions/boolean.d.ts.map +1 -0
  75. package/dist/parsing/expressions/boolean.js +26 -0
  76. package/dist/parsing/expressions/boolean.js.map +1 -0
  77. package/dist/parsing/expressions/expression.d.ts +4 -1
  78. package/dist/parsing/expressions/expression.d.ts.map +1 -1
  79. package/dist/parsing/expressions/expression.js +15 -8
  80. package/dist/parsing/expressions/expression.js.map +1 -1
  81. package/dist/parsing/expressions/expression_map.d.ts +1 -0
  82. package/dist/parsing/expressions/expression_map.d.ts.map +1 -1
  83. package/dist/parsing/expressions/expression_map.js +3 -0
  84. package/dist/parsing/expressions/expression_map.js.map +1 -1
  85. package/dist/parsing/expressions/operator.d.ts +1 -1
  86. package/dist/parsing/expressions/operator.d.ts.map +1 -1
  87. package/dist/parsing/expressions/operator.js.map +1 -1
  88. package/dist/parsing/functions/function_factory.d.ts +13 -13
  89. package/dist/parsing/functions/function_factory.d.ts.map +1 -1
  90. package/dist/parsing/functions/function_factory.js +20 -18
  91. package/dist/parsing/functions/function_factory.js.map +1 -1
  92. package/dist/parsing/operations/call.d.ts.map +1 -1
  93. package/dist/parsing/operations/call.js +3 -1
  94. package/dist/parsing/operations/call.js.map +1 -1
  95. package/dist/parsing/operations/create_node.d.ts +14 -0
  96. package/dist/parsing/operations/create_node.d.ts.map +1 -0
  97. package/dist/parsing/operations/create_node.js +51 -0
  98. package/dist/parsing/operations/create_node.js.map +1 -0
  99. package/dist/parsing/operations/create_relationship.d.ts +14 -0
  100. package/dist/parsing/operations/create_relationship.d.ts.map +1 -0
  101. package/dist/parsing/operations/create_relationship.js +51 -0
  102. package/dist/parsing/operations/create_relationship.js.map +1 -0
  103. package/dist/parsing/operations/match.d.ts +15 -0
  104. package/dist/parsing/operations/match.d.ts.map +1 -0
  105. package/dist/parsing/operations/match.js +45 -0
  106. package/dist/parsing/operations/match.js.map +1 -0
  107. package/dist/parsing/operations/operation.d.ts +1 -0
  108. package/dist/parsing/operations/operation.d.ts.map +1 -1
  109. package/dist/parsing/operations/operation.js +6 -0
  110. package/dist/parsing/operations/operation.js.map +1 -1
  111. package/dist/parsing/operations/return.d.ts +1 -0
  112. package/dist/parsing/operations/return.d.ts.map +1 -1
  113. package/dist/parsing/operations/return.js +7 -1
  114. package/dist/parsing/operations/return.js.map +1 -1
  115. package/dist/parsing/operations/where.d.ts +1 -1
  116. package/dist/parsing/operations/where.d.ts.map +1 -1
  117. package/dist/parsing/operations/where.js +4 -0
  118. package/dist/parsing/operations/where.js.map +1 -1
  119. package/dist/parsing/parser.d.ts +10 -0
  120. package/dist/parsing/parser.d.ts.map +1 -1
  121. package/dist/parsing/parser.js +344 -5
  122. package/dist/parsing/parser.js.map +1 -1
  123. package/dist/parsing/token_to_node.d.ts.map +1 -1
  124. package/dist/parsing/token_to_node.js +7 -0
  125. package/dist/parsing/token_to_node.js.map +1 -1
  126. package/dist/tokenization/keyword.d.ts +1 -0
  127. package/dist/tokenization/keyword.d.ts.map +1 -1
  128. package/dist/tokenization/keyword.js +1 -0
  129. package/dist/tokenization/keyword.js.map +1 -1
  130. package/dist/tokenization/token.d.ts +4 -0
  131. package/dist/tokenization/token.d.ts.map +1 -1
  132. package/dist/tokenization/token.js +14 -1
  133. package/dist/tokenization/token.js.map +1 -1
  134. package/dist/tokenization/token_type.d.ts +1 -0
  135. package/dist/tokenization/token_type.d.ts.map +1 -1
  136. package/dist/tokenization/token_type.js +1 -0
  137. package/dist/tokenization/token_type.js.map +1 -1
  138. package/dist/tokenization/tokenizer.d.ts +2 -1
  139. package/dist/tokenization/tokenizer.d.ts.map +1 -1
  140. package/dist/tokenization/tokenizer.js +25 -12
  141. package/dist/tokenization/tokenizer.js.map +1 -1
  142. package/docs/flowquery.min.js +1 -1
  143. package/flowquery-py/README.md +166 -0
  144. package/flowquery-py/pyproject.toml +75 -0
  145. package/flowquery-py/setup_env.ps1 +92 -0
  146. package/flowquery-py/setup_env.sh +87 -0
  147. package/flowquery-py/src/__init__.py +34 -0
  148. package/flowquery-py/src/__main__.py +10 -0
  149. package/flowquery-py/src/compute/__init__.py +5 -0
  150. package/flowquery-py/src/compute/runner.py +60 -0
  151. package/flowquery-py/src/extensibility.py +52 -0
  152. package/flowquery-py/src/graph/__init__.py +31 -0
  153. package/flowquery-py/src/graph/data.py +118 -0
  154. package/flowquery-py/src/graph/database.py +82 -0
  155. package/flowquery-py/src/graph/hops.py +43 -0
  156. package/flowquery-py/src/graph/node.py +112 -0
  157. package/flowquery-py/src/graph/node_data.py +26 -0
  158. package/flowquery-py/src/graph/node_reference.py +49 -0
  159. package/flowquery-py/src/graph/pattern.py +125 -0
  160. package/flowquery-py/src/graph/pattern_expression.py +62 -0
  161. package/flowquery-py/src/graph/patterns.py +42 -0
  162. package/flowquery-py/src/graph/physical_node.py +40 -0
  163. package/flowquery-py/src/graph/physical_relationship.py +36 -0
  164. package/flowquery-py/src/graph/relationship.py +135 -0
  165. package/flowquery-py/src/graph/relationship_data.py +33 -0
  166. package/flowquery-py/src/graph/relationship_match_collector.py +77 -0
  167. package/flowquery-py/src/graph/relationship_reference.py +21 -0
  168. package/flowquery-py/src/io/__init__.py +5 -0
  169. package/flowquery-py/src/io/command_line.py +67 -0
  170. package/flowquery-py/src/parsing/__init__.py +17 -0
  171. package/flowquery-py/src/parsing/alias.py +20 -0
  172. package/flowquery-py/src/parsing/alias_option.py +11 -0
  173. package/flowquery-py/src/parsing/ast_node.py +146 -0
  174. package/flowquery-py/src/parsing/base_parser.py +84 -0
  175. package/flowquery-py/src/parsing/components/__init__.py +19 -0
  176. package/flowquery-py/src/parsing/components/csv.py +8 -0
  177. package/flowquery-py/src/parsing/components/from_.py +10 -0
  178. package/flowquery-py/src/parsing/components/headers.py +12 -0
  179. package/flowquery-py/src/parsing/components/json.py +8 -0
  180. package/flowquery-py/src/parsing/components/null.py +10 -0
  181. package/flowquery-py/src/parsing/components/post.py +8 -0
  182. package/flowquery-py/src/parsing/components/text.py +8 -0
  183. package/flowquery-py/src/parsing/context.py +50 -0
  184. package/flowquery-py/src/parsing/data_structures/__init__.py +15 -0
  185. package/flowquery-py/src/parsing/data_structures/associative_array.py +41 -0
  186. package/flowquery-py/src/parsing/data_structures/json_array.py +30 -0
  187. package/flowquery-py/src/parsing/data_structures/key_value_pair.py +38 -0
  188. package/flowquery-py/src/parsing/data_structures/lookup.py +49 -0
  189. package/flowquery-py/src/parsing/data_structures/range_lookup.py +42 -0
  190. package/flowquery-py/src/parsing/expressions/__init__.py +57 -0
  191. package/flowquery-py/src/parsing/expressions/boolean.py +20 -0
  192. package/flowquery-py/src/parsing/expressions/expression.py +138 -0
  193. package/flowquery-py/src/parsing/expressions/expression_map.py +26 -0
  194. package/flowquery-py/src/parsing/expressions/f_string.py +27 -0
  195. package/flowquery-py/src/parsing/expressions/identifier.py +20 -0
  196. package/flowquery-py/src/parsing/expressions/number.py +32 -0
  197. package/flowquery-py/src/parsing/expressions/operator.py +169 -0
  198. package/flowquery-py/src/parsing/expressions/reference.py +47 -0
  199. package/flowquery-py/src/parsing/expressions/string.py +27 -0
  200. package/flowquery-py/src/parsing/functions/__init__.py +75 -0
  201. package/flowquery-py/src/parsing/functions/aggregate_function.py +60 -0
  202. package/flowquery-py/src/parsing/functions/async_function.py +62 -0
  203. package/flowquery-py/src/parsing/functions/avg.py +55 -0
  204. package/flowquery-py/src/parsing/functions/collect.py +75 -0
  205. package/flowquery-py/src/parsing/functions/function.py +68 -0
  206. package/flowquery-py/src/parsing/functions/function_factory.py +173 -0
  207. package/flowquery-py/src/parsing/functions/function_metadata.py +149 -0
  208. package/flowquery-py/src/parsing/functions/functions.py +59 -0
  209. package/flowquery-py/src/parsing/functions/join.py +47 -0
  210. package/flowquery-py/src/parsing/functions/keys.py +34 -0
  211. package/flowquery-py/src/parsing/functions/predicate_function.py +46 -0
  212. package/flowquery-py/src/parsing/functions/predicate_sum.py +47 -0
  213. package/flowquery-py/src/parsing/functions/rand.py +28 -0
  214. package/flowquery-py/src/parsing/functions/range_.py +34 -0
  215. package/flowquery-py/src/parsing/functions/reducer_element.py +15 -0
  216. package/flowquery-py/src/parsing/functions/replace.py +37 -0
  217. package/flowquery-py/src/parsing/functions/round_.py +32 -0
  218. package/flowquery-py/src/parsing/functions/size.py +32 -0
  219. package/flowquery-py/src/parsing/functions/split.py +47 -0
  220. package/flowquery-py/src/parsing/functions/stringify.py +47 -0
  221. package/flowquery-py/src/parsing/functions/sum.py +51 -0
  222. package/flowquery-py/src/parsing/functions/to_json.py +33 -0
  223. package/flowquery-py/src/parsing/functions/type_.py +47 -0
  224. package/flowquery-py/src/parsing/functions/value_holder.py +24 -0
  225. package/flowquery-py/src/parsing/logic/__init__.py +15 -0
  226. package/flowquery-py/src/parsing/logic/case.py +29 -0
  227. package/flowquery-py/src/parsing/logic/else_.py +12 -0
  228. package/flowquery-py/src/parsing/logic/end.py +8 -0
  229. package/flowquery-py/src/parsing/logic/then.py +12 -0
  230. package/flowquery-py/src/parsing/logic/when.py +10 -0
  231. package/flowquery-py/src/parsing/operations/__init__.py +35 -0
  232. package/flowquery-py/src/parsing/operations/aggregated_return.py +24 -0
  233. package/flowquery-py/src/parsing/operations/aggregated_with.py +22 -0
  234. package/flowquery-py/src/parsing/operations/call.py +74 -0
  235. package/flowquery-py/src/parsing/operations/create_node.py +34 -0
  236. package/flowquery-py/src/parsing/operations/create_relationship.py +34 -0
  237. package/flowquery-py/src/parsing/operations/group_by.py +130 -0
  238. package/flowquery-py/src/parsing/operations/limit.py +22 -0
  239. package/flowquery-py/src/parsing/operations/load.py +140 -0
  240. package/flowquery-py/src/parsing/operations/match.py +29 -0
  241. package/flowquery-py/src/parsing/operations/operation.py +69 -0
  242. package/flowquery-py/src/parsing/operations/projection.py +21 -0
  243. package/flowquery-py/src/parsing/operations/return_op.py +50 -0
  244. package/flowquery-py/src/parsing/operations/unwind.py +37 -0
  245. package/flowquery-py/src/parsing/operations/where.py +41 -0
  246. package/flowquery-py/src/parsing/operations/with_op.py +18 -0
  247. package/flowquery-py/src/parsing/parser.py +1011 -0
  248. package/flowquery-py/src/parsing/token_to_node.py +109 -0
  249. package/flowquery-py/src/tokenization/__init__.py +23 -0
  250. package/flowquery-py/src/tokenization/keyword.py +48 -0
  251. package/flowquery-py/src/tokenization/operator.py +29 -0
  252. package/flowquery-py/src/tokenization/string_walker.py +158 -0
  253. package/flowquery-py/src/tokenization/symbol.py +19 -0
  254. package/flowquery-py/src/tokenization/token.py +659 -0
  255. package/flowquery-py/src/tokenization/token_mapper.py +52 -0
  256. package/flowquery-py/src/tokenization/token_type.py +21 -0
  257. package/flowquery-py/src/tokenization/tokenizer.py +214 -0
  258. package/flowquery-py/src/tokenization/trie.py +124 -0
  259. package/flowquery-py/src/utils/__init__.py +6 -0
  260. package/flowquery-py/src/utils/object_utils.py +20 -0
  261. package/flowquery-py/src/utils/string_utils.py +113 -0
  262. package/flowquery-py/tests/__init__.py +1 -0
  263. package/flowquery-py/tests/compute/__init__.py +1 -0
  264. package/flowquery-py/tests/compute/test_runner.py +1335 -0
  265. package/flowquery-py/tests/graph/__init__.py +1 -0
  266. package/flowquery-py/tests/graph/test_create.py +56 -0
  267. package/flowquery-py/tests/graph/test_data.py +73 -0
  268. package/flowquery-py/tests/graph/test_match.py +40 -0
  269. package/flowquery-py/tests/parsing/__init__.py +1 -0
  270. package/flowquery-py/tests/parsing/test_context.py +34 -0
  271. package/flowquery-py/tests/parsing/test_expression.py +49 -0
  272. package/flowquery-py/tests/parsing/test_parser.py +674 -0
  273. package/flowquery-py/tests/test_extensibility.py +611 -0
  274. package/flowquery-py/tests/tokenization/__init__.py +1 -0
  275. package/flowquery-py/tests/tokenization/test_token_mapper.py +60 -0
  276. package/flowquery-py/tests/tokenization/test_tokenizer.py +164 -0
  277. package/flowquery-py/tests/tokenization/test_trie.py +30 -0
  278. package/flowquery-vscode/flowQueryEngine/flowquery.min.js +1 -1
  279. package/misc/apps/RAG/package.json +1 -1
  280. package/misc/apps/RAG/src/components/AdaptiveCardRenderer.tsx +76 -8
  281. package/misc/apps/RAG/src/components/index.ts +19 -10
  282. package/misc/apps/RAG/src/plugins/loaders/CatFacts.ts +21 -26
  283. package/misc/apps/RAG/src/plugins/loaders/FetchJson.ts +24 -25
  284. package/misc/apps/RAG/src/plugins/loaders/Form.ts +163 -147
  285. package/misc/apps/RAG/src/plugins/loaders/Llm.ts +103 -90
  286. package/misc/apps/RAG/src/plugins/loaders/MockData.ts +80 -130
  287. package/misc/apps/RAG/src/plugins/loaders/Table.ts +104 -101
  288. package/misc/apps/RAG/src/plugins/loaders/Weather.ts +47 -36
  289. package/misc/apps/RAG/src/prompts/FlowQuerySystemPrompt.ts +89 -78
  290. package/package.json +1 -1
  291. package/src/compute/runner.ts +24 -19
  292. package/src/graph/data.ts +112 -0
  293. package/src/graph/database.ts +63 -0
  294. package/src/graph/hops.ts +22 -0
  295. package/src/graph/node.ts +99 -0
  296. package/src/graph/node_data.ts +18 -0
  297. package/src/graph/node_reference.ts +33 -0
  298. package/src/graph/pattern.ts +101 -0
  299. package/src/graph/pattern_expression.ts +37 -0
  300. package/src/graph/patterns.ts +36 -0
  301. package/src/graph/physical_node.ts +23 -0
  302. package/src/graph/physical_relationship.ts +23 -0
  303. package/src/graph/relationship.ts +116 -0
  304. package/src/graph/relationship_data.ts +27 -0
  305. package/src/graph/relationship_match_collector.ts +58 -0
  306. package/src/graph/relationship_reference.ts +24 -0
  307. package/src/parsing/base_parser.ts +20 -14
  308. package/src/parsing/context.ts +14 -14
  309. package/src/parsing/expressions/boolean.ts +21 -0
  310. package/src/parsing/expressions/expression.ts +34 -26
  311. package/src/parsing/expressions/expression_map.ts +3 -0
  312. package/src/parsing/expressions/operator.ts +19 -1
  313. package/src/parsing/functions/function_factory.ts +45 -45
  314. package/src/parsing/operations/call.ts +3 -1
  315. package/src/parsing/operations/create_node.ts +39 -0
  316. package/src/parsing/operations/create_relationship.ts +38 -0
  317. package/src/parsing/operations/match.ts +31 -0
  318. package/src/parsing/operations/operation.ts +3 -0
  319. package/src/parsing/operations/return.ts +11 -7
  320. package/src/parsing/operations/where.ts +10 -6
  321. package/src/parsing/parser.ts +346 -8
  322. package/src/parsing/token_to_node.ts +6 -0
  323. package/src/tokenization/keyword.ts +41 -40
  324. package/src/tokenization/token.ts +21 -1
  325. package/src/tokenization/token_type.ts +2 -1
  326. package/src/tokenization/tokenizer.ts +52 -31
  327. package/tests/compute/runner.test.ts +660 -6
  328. package/tests/extensibility.test.ts +97 -93
  329. package/tests/graph/create.test.ts +36 -0
  330. package/tests/graph/data.test.ts +58 -0
  331. package/tests/graph/match.test.ts +29 -0
  332. package/tests/parsing/parser.test.ts +276 -8
  333. package/tests/tokenization/tokenizer.test.ts +107 -17
@@ -1,27 +1,24 @@
1
1
  /**
2
2
  * OpenAI LLM Plugin: Call OpenAI-compatible APIs for chat completions.
3
- *
3
+ *
4
4
  * Usage in FlowQuery:
5
- * LOAD JSON FROM llm('What is the capital of France?') AS response
6
- * RETURN response.choices[0].message.content
7
- *
5
+ * CALL llm('What is the capital of France?') YIELD choices
6
+ *
8
7
  * With custom options:
9
- * LOAD JSON FROM llm('Translate to French: Hello', { model: 'gpt-4o', temperature: 0.3 }) AS response
10
- * RETURN response.choices[0].message.content
11
- *
8
+ * CALL llm('Translate to French: Hello', { model: 'gpt-4o', temperature: 0.3 }) YIELD choices, usage
9
+ *
12
10
  * This class can also be used standalone outside of FlowQuery:
13
11
  * import { Llm } from './plugins/loaders/Llm';
14
12
  * const llmInstance = new Llm();
15
13
  * const response = await llmInstance.complete('What is 2+2?');
16
14
  * console.log(response.choices[0].message.content);
17
15
  */
18
-
19
- import { FunctionDef, AsyncFunction } from 'flowquery/extensibility';
16
+ import { AsyncFunction, FunctionDef } from "flowquery/extensibility";
20
17
 
21
18
  // Default configuration - can be overridden via options
22
19
  const DEFAULT_CONFIG = {
23
- apiUrl: 'https://api.openai.com/v1/chat/completions',
24
- model: 'gpt-4o-mini',
20
+ apiUrl: "https://api.openai.com/v1/chat/completions",
21
+ model: "gpt-4o-mini",
25
22
  temperature: 0.7,
26
23
  maxTokens: undefined as number | undefined,
27
24
  };
@@ -43,7 +40,7 @@ export interface LlmOptions {
43
40
  /** System prompt to set context for the conversation. */
44
41
  systemPrompt?: string;
45
42
  /** Additional messages to include in the conversation. */
46
- messages?: Array<{ role: 'system' | 'user' | 'assistant'; content: string }>;
43
+ messages?: Array<{ role: "system" | "user" | "assistant"; content: string }>;
47
44
  /** Organization ID for OpenAI API. */
48
45
  organizationId?: string;
49
46
  /** Additional headers to include in the request. */
@@ -81,56 +78,65 @@ export interface LlmResponse {
81
78
  * Llm class - calls OpenAI-compatible APIs for chat completions.
82
79
  */
83
80
  @FunctionDef({
84
- description: 'Calls OpenAI-compatible chat completion APIs. Supports GPT models and any OpenAI-compatible endpoint.',
85
- category: 'async',
81
+ description:
82
+ "Calls OpenAI-compatible chat completion APIs. Supports GPT models and any OpenAI-compatible endpoint.",
83
+ category: "async",
86
84
  parameters: [
87
85
  {
88
- name: 'prompt',
89
- description: 'The user prompt to send to the LLM',
90
- type: 'string',
86
+ name: "prompt",
87
+ description: "The user prompt to send to the LLM",
88
+ type: "string",
91
89
  required: true,
92
- example: 'What is the capital of France?'
90
+ example: "What is the capital of France?",
93
91
  },
94
92
  {
95
- name: 'options',
96
- description: 'Optional configuration for the LLM request',
97
- type: 'object',
93
+ name: "options",
94
+ description: "Optional configuration for the LLM request",
95
+ type: "object",
98
96
  required: false,
99
97
  properties: {
100
- apiKey: { description: 'OpenAI API key', type: 'string' },
101
- apiUrl: { description: 'API endpoint URL (defaults to OpenAI chat completions)', type: 'string' },
102
- model: { description: 'Model to use (defaults to gpt-4o-mini)', type: 'string' },
103
- temperature: { description: 'Sampling temperature 0-2 (defaults to 0.7)', type: 'number' },
104
- maxTokens: { description: 'Maximum tokens to generate', type: 'number' },
105
- systemPrompt: { description: 'System prompt to set context', type: 'string' },
106
- messages: { description: 'Additional conversation messages', type: 'array' },
107
- organizationId: { description: 'OpenAI organization ID', type: 'string' },
108
- headers: { description: 'Additional request headers', type: 'object' },
109
- stream: { description: 'Enable streaming response', type: 'boolean' },
110
- additionalParams: { description: 'Additional API parameters', type: 'object' }
111
- }
112
- }
98
+ apiKey: { description: "OpenAI API key", type: "string" },
99
+ apiUrl: {
100
+ description: "API endpoint URL (defaults to OpenAI chat completions)",
101
+ type: "string",
102
+ },
103
+ model: { description: "Model to use (defaults to gpt-4o-mini)", type: "string" },
104
+ temperature: {
105
+ description: "Sampling temperature 0-2 (defaults to 0.7)",
106
+ type: "number",
107
+ },
108
+ maxTokens: { description: "Maximum tokens to generate", type: "number" },
109
+ systemPrompt: { description: "System prompt to set context", type: "string" },
110
+ messages: { description: "Additional conversation messages", type: "array" },
111
+ organizationId: { description: "OpenAI organization ID", type: "string" },
112
+ headers: { description: "Additional request headers", type: "object" },
113
+ stream: { description: "Enable streaming response", type: "boolean" },
114
+ additionalParams: { description: "Additional API parameters", type: "object" },
115
+ },
116
+ },
113
117
  ],
114
118
  output: {
115
- description: 'OpenAI chat completion response',
116
- type: 'object',
119
+ description: "OpenAI chat completion response",
120
+ type: "object",
117
121
  properties: {
118
- id: { description: 'Unique identifier for the completion', type: 'string' },
119
- model: { description: 'Model used for completion', type: 'string' },
120
- choices: {
121
- description: 'Array of completion choices',
122
- type: 'array',
123
- example: [{ message: { role: 'assistant', content: 'Paris is the capital of France.' } }]
122
+ id: { description: "Unique identifier for the completion", type: "string" },
123
+ model: { description: "Model used for completion", type: "string" },
124
+ choices: {
125
+ description: "Array of completion choices",
126
+ type: "array",
127
+ example: [
128
+ { message: { role: "assistant", content: "Paris is the capital of France." } },
129
+ ],
124
130
  },
125
- usage: { description: 'Token usage statistics', type: 'object' }
126
- }
131
+ usage: { description: "Token usage statistics", type: "object" },
132
+ },
127
133
  },
128
134
  examples: [
129
- "LOAD JSON FROM llm('What is 2+2?') AS response RETURN response.choices[0].message.content",
130
- "LOAD JSON FROM llm('Translate to French: Hello', { model: 'gpt-4o', temperature: 0.3 }) AS response RETURN response.choices[0].message.content",
131
- "LOAD JSON FROM llm('Write a haiku', { systemPrompt: 'You are a poet' }) AS response RETURN response.choices[0].message.content"
135
+ "CALL llm('What is 2+2?') YIELD choices",
136
+ "CALL llm('Translate to French: Hello', { model: 'gpt-4o', temperature: 0.3 }) YIELD choices, usage",
137
+ "CALL llm('Write a haiku', { systemPrompt: 'You are a poet' }) YIELD choices",
132
138
  ],
133
- notes: 'Requires API key configured in Settings or passed as apiKey option. Works with any OpenAI-compatible API by setting the apiUrl option.'
139
+ notes: "Requires API key configured in Settings or passed as apiKey option. Works with any OpenAI-compatible API by setting the apiUrl option.",
134
140
  })
135
141
  export class Llm extends AsyncFunction {
136
142
  private readonly defaultOptions: Partial<LlmOptions>;
@@ -148,22 +154,22 @@ export class Llm extends AsyncFunction {
148
154
  if (options?.apiKey) {
149
155
  return options.apiKey;
150
156
  }
151
-
157
+
152
158
  // Check default options
153
159
  if (this.defaultOptions.apiKey) {
154
160
  return this.defaultOptions.apiKey;
155
161
  }
156
-
162
+
157
163
  // In browser, check localStorage
158
- if (typeof window !== 'undefined' && typeof localStorage !== 'undefined') {
159
- const storedKey = localStorage.getItem('flowquery_openai_api_key');
164
+ if (typeof window !== "undefined" && typeof localStorage !== "undefined") {
165
+ const storedKey = localStorage.getItem("flowquery_openai_api_key");
160
166
  if (storedKey) {
161
167
  return storedKey;
162
168
  }
163
169
  }
164
-
170
+
165
171
  throw new Error(
166
- 'OpenAI API key is required. Configure it in Settings or pass apiKey in options.'
172
+ "OpenAI API key is required. Configure it in Settings or pass apiKey in options."
167
173
  );
168
174
  }
169
175
 
@@ -171,13 +177,13 @@ export class Llm extends AsyncFunction {
171
177
  * Get stored configuration from localStorage (browser only).
172
178
  */
173
179
  private getStoredConfig(): Partial<LlmOptions> {
174
- if (typeof window === 'undefined' || typeof localStorage === 'undefined') {
180
+ if (typeof window === "undefined" || typeof localStorage === "undefined") {
175
181
  return {};
176
182
  }
177
-
183
+
178
184
  return {
179
- organizationId: localStorage.getItem('flowquery_openai_org_id') || undefined,
180
- model: localStorage.getItem('flowquery_openai_model') || undefined,
185
+ organizationId: localStorage.getItem("flowquery_openai_org_id") || undefined,
186
+ model: localStorage.getItem("flowquery_openai_model") || undefined,
181
187
  };
182
188
  }
183
189
 
@@ -189,7 +195,7 @@ export class Llm extends AsyncFunction {
189
195
 
190
196
  // Add system prompt if provided
191
197
  if (options?.systemPrompt) {
192
- messages.push({ role: 'system', content: options.systemPrompt });
198
+ messages.push({ role: "system", content: options.systemPrompt });
193
199
  }
194
200
 
195
201
  // Add any additional messages
@@ -198,17 +204,21 @@ export class Llm extends AsyncFunction {
198
204
  }
199
205
 
200
206
  // Add the user prompt
201
- messages.push({ role: 'user', content: prompt });
207
+ messages.push({ role: "user", content: prompt });
202
208
 
203
209
  const body: Record<string, any> = {
204
210
  model: options?.model || this.defaultOptions.model || DEFAULT_CONFIG.model,
205
211
  messages,
206
- temperature: options?.temperature ?? this.defaultOptions.temperature ?? DEFAULT_CONFIG.temperature,
212
+ temperature:
213
+ options?.temperature ??
214
+ this.defaultOptions.temperature ??
215
+ DEFAULT_CONFIG.temperature,
207
216
  ...(options?.additionalParams || {}),
208
217
  };
209
218
 
210
219
  if (options?.maxTokens || this.defaultOptions.maxTokens || DEFAULT_CONFIG.maxTokens) {
211
- body.max_tokens = options?.maxTokens || this.defaultOptions.maxTokens || DEFAULT_CONFIG.maxTokens;
220
+ body.max_tokens =
221
+ options?.maxTokens || this.defaultOptions.maxTokens || DEFAULT_CONFIG.maxTokens;
212
222
  }
213
223
 
214
224
  if (options?.stream) {
@@ -223,13 +233,13 @@ export class Llm extends AsyncFunction {
223
233
  */
224
234
  private buildHeaders(apiKey: string, options?: LlmOptions): Record<string, string> {
225
235
  const headers: Record<string, string> = {
226
- 'Content-Type': 'application/json',
227
- 'Authorization': `Bearer ${apiKey}`,
236
+ "Content-Type": "application/json",
237
+ Authorization: `Bearer ${apiKey}`,
228
238
  ...(options?.headers || {}),
229
239
  };
230
240
 
231
241
  if (options?.organizationId) {
232
- headers['OpenAI-Organization'] = options.organizationId;
242
+ headers["OpenAI-Organization"] = options.organizationId;
233
243
  }
234
244
 
235
245
  return headers;
@@ -237,11 +247,11 @@ export class Llm extends AsyncFunction {
237
247
 
238
248
  /**
239
249
  * Call the OpenAI-compatible API and return the full response.
240
- *
250
+ *
241
251
  * @param prompt - The user prompt to send to the LLM
242
252
  * @param options - Optional configuration for the request
243
253
  * @returns The full API response
244
- *
254
+ *
245
255
  * @example
246
256
  * ```typescript
247
257
  * const llmInstance = new Llm();
@@ -253,14 +263,14 @@ export class Llm extends AsyncFunction {
253
263
  // Merge stored config with provided options (options take precedence)
254
264
  const storedConfig = this.getStoredConfig();
255
265
  const mergedOptions = { ...this.defaultOptions, ...storedConfig, ...options };
256
-
266
+
257
267
  const apiKey = this.getApiKey(mergedOptions);
258
268
  const apiUrl = mergedOptions?.apiUrl || DEFAULT_CONFIG.apiUrl;
259
269
  const headers = this.buildHeaders(apiKey, mergedOptions);
260
270
  const body = this.buildRequestBody(prompt, mergedOptions);
261
271
 
262
272
  const response = await fetch(apiUrl, {
263
- method: 'POST',
273
+ method: "POST",
264
274
  headers,
265
275
  body: JSON.stringify(body),
266
276
  });
@@ -275,11 +285,11 @@ export class Llm extends AsyncFunction {
275
285
 
276
286
  /**
277
287
  * Call the OpenAI-compatible API with streaming and yield each chunk.
278
- *
288
+ *
279
289
  * @param prompt - The user prompt to send to the LLM
280
290
  * @param options - Optional configuration for the request
281
291
  * @yields Parsed SSE data chunks from the stream
282
- *
292
+ *
283
293
  * @example
284
294
  * ```typescript
285
295
  * const llmInstance = new Llm();
@@ -294,14 +304,14 @@ export class Llm extends AsyncFunction {
294
304
  // Merge stored config with provided options (options take precedence)
295
305
  const storedConfig = this.getStoredConfig();
296
306
  const mergedOptions = { ...this.defaultOptions, ...storedConfig, ...options };
297
-
307
+
298
308
  const apiKey = this.getApiKey(mergedOptions);
299
309
  const apiUrl = mergedOptions?.apiUrl || DEFAULT_CONFIG.apiUrl;
300
310
  const headers = this.buildHeaders(apiKey, mergedOptions);
301
311
  const body = this.buildRequestBody(prompt, { ...mergedOptions, stream: true });
302
312
 
303
313
  const response = await fetch(apiUrl, {
304
- method: 'POST',
314
+ method: "POST",
305
315
  headers,
306
316
  body: JSON.stringify(body),
307
317
  });
@@ -312,12 +322,12 @@ export class Llm extends AsyncFunction {
312
322
  }
313
323
 
314
324
  if (!response.body) {
315
- throw new Error('Response body is null');
325
+ throw new Error("Response body is null");
316
326
  }
317
327
 
318
328
  const reader = response.body.getReader();
319
329
  const decoder = new TextDecoder();
320
- let buffer = '';
330
+ let buffer = "";
321
331
 
322
332
  try {
323
333
  while (true) {
@@ -325,14 +335,14 @@ export class Llm extends AsyncFunction {
325
335
  if (done) break;
326
336
 
327
337
  buffer += decoder.decode(value, { stream: true });
328
- const lines = buffer.split('\n');
329
- buffer = lines.pop() || '';
338
+ const lines = buffer.split("\n");
339
+ buffer = lines.pop() || "";
330
340
 
331
341
  for (const line of lines) {
332
342
  const trimmed = line.trim();
333
- if (trimmed.startsWith('data: ')) {
343
+ if (trimmed.startsWith("data: ")) {
334
344
  const data = trimmed.slice(6);
335
- if (data === '[DONE]') {
345
+ if (data === "[DONE]") {
336
346
  return;
337
347
  }
338
348
  try {
@@ -363,31 +373,31 @@ export class Llm extends AsyncFunction {
363
373
  /**
364
374
  * Extract just the text content from an LLM response.
365
375
  * Convenience method for common use case.
366
- *
376
+ *
367
377
  * @param response - The LLM response object
368
378
  * @returns The text content from the first choice
369
379
  */
370
380
  static extractContent(response: LlmResponse): string {
371
- return response.choices?.[0]?.message?.content || '';
381
+ return response.choices?.[0]?.message?.content || "";
372
382
  }
373
383
  }
374
384
 
375
385
  /**
376
386
  * Call the OpenAI-compatible API and return the full response.
377
387
  * This function can be used standalone outside of FlowQuery.
378
- *
388
+ *
379
389
  * @param prompt - The user prompt to send to the LLM
380
390
  * @param options - Optional configuration for the request
381
391
  * @returns The full API response
382
- *
392
+ *
383
393
  * @example
384
394
  * ```typescript
385
395
  * import { llm } from './plugins/loaders/Llm';
386
- *
396
+ *
387
397
  * // Simple usage
388
398
  * const response = await llm('What is the capital of France?');
389
399
  * console.log(response.choices[0].message.content);
390
- *
400
+ *
391
401
  * // With options
392
402
  * const response = await llm('Translate to Spanish: Hello', {
393
403
  * model: 'gpt-4o',
@@ -403,15 +413,15 @@ export async function llm(prompt: string, options?: LlmOptions): Promise<LlmResp
403
413
  /**
404
414
  * Call the OpenAI-compatible API with streaming and yield each chunk.
405
415
  * This function can be used standalone outside of FlowQuery.
406
- *
416
+ *
407
417
  * @param prompt - The user prompt to send to the LLM
408
418
  * @param options - Optional configuration for the request
409
419
  * @yields Parsed SSE data chunks from the stream
410
- *
420
+ *
411
421
  * @example
412
422
  * ```typescript
413
423
  * import { llmStream } from './plugins/loaders/Llm';
414
- *
424
+ *
415
425
  * for await (const chunk of llmStream('Tell me a story')) {
416
426
  * if (chunk.choices?.[0]?.delta?.content) {
417
427
  * process.stdout.write(chunk.choices[0].delta.content);
@@ -419,14 +429,17 @@ export async function llm(prompt: string, options?: LlmOptions): Promise<LlmResp
419
429
  * }
420
430
  * ```
421
431
  */
422
- export async function* llmStream(prompt: string, options?: LlmOptions): AsyncGenerator<any, void, unknown> {
432
+ export async function* llmStream(
433
+ prompt: string,
434
+ options?: LlmOptions
435
+ ): AsyncGenerator<any, void, unknown> {
423
436
  yield* new Llm().stream(prompt, options);
424
437
  }
425
438
 
426
439
  /**
427
440
  * Extract just the text content from an LLM response.
428
441
  * Convenience function for common use case.
429
- *
442
+ *
430
443
  * @param response - The LLM response object
431
444
  * @returns The text content from the first choice
432
445
  */
@@ -1,151 +1,101 @@
1
- /**
2
- * Example plugin: Generate mock data for testing.
3
- *
4
- * Usage in FlowQuery:
5
- * LOAD JSON FROM mockUsers(10) AS user
6
- * RETURN user.name, user.email
7
- */
1
+ import { AsyncFunction, FunctionDef } from "flowquery/extensibility";
8
2
 
9
- import { FunctionDef, AsyncFunction } from 'flowquery/extensibility';
3
+ const usersData = [
4
+ { id: 1, name: "Alice Johnson", email: "alice@example.com", age: 28 },
5
+ { id: 2, name: "Bob Smith", email: "bob@example.com", age: 34 },
6
+ { id: 3, name: "Charlie Brown", email: "charlie@example.com", age: 22 },
7
+ { id: 4, name: "Diana Ross", email: "diana@example.com", age: 45 },
8
+ { id: 5, name: "Eve Wilson", email: "eve@example.com", age: 31 },
9
+ ];
10
+
11
+ const productsData = [
12
+ { id: 101, name: "Laptop", price: 999.99, category: "Electronics", stock: 50 },
13
+ { id: 102, name: "Headphones", price: 149.99, category: "Electronics", stock: 200 },
14
+ { id: 103, name: "Coffee Mug", price: 12.99, category: "Kitchen", stock: 500 },
15
+ { id: 104, name: "Notebook", price: 8.99, category: "Office", stock: 300 },
16
+ { id: 105, name: "Backpack", price: 59.99, category: "Accessories", stock: 75 },
17
+ ];
18
+
19
+ const ordersData = [
20
+ { id: 1001, userId: 1, productId: 101, quantity: 1, total: 999.99, date: "2025-12-01" },
21
+ { id: 1002, userId: 2, productId: 102, quantity: 2, total: 299.98, date: "2025-12-05" },
22
+ { id: 1003, userId: 1, productId: 103, quantity: 4, total: 51.96, date: "2025-12-10" },
23
+ { id: 1004, userId: 3, productId: 104, quantity: 10, total: 89.9, date: "2025-12-15" },
24
+ { id: 1005, userId: 4, productId: 105, quantity: 1, total: 59.99, date: "2025-12-20" },
25
+ { id: 1006, userId: 5, productId: 101, quantity: 1, total: 999.99, date: "2025-12-25" },
26
+ ];
10
27
 
11
- /**
12
- * MockUsers class - generates mock user data for testing.
13
- */
14
28
  @FunctionDef({
15
- description: 'Generates mock user data for testing purposes',
16
- category: 'async',
17
- parameters: [
18
- {
19
- name: 'count',
20
- description: 'Number of mock users to generate',
21
- type: 'number',
22
- required: false,
23
- default: 5
24
- }
25
- ],
29
+ description: "Returns mock user data",
30
+ category: "async",
31
+ parameters: [],
26
32
  output: {
27
- description: 'Mock user object',
28
- type: 'object',
33
+ description: "User object",
34
+ type: "object",
29
35
  properties: {
30
- id: { description: 'User ID', type: 'number' },
31
- name: { description: 'Full name', type: 'string' },
32
- email: { description: 'Email address', type: 'string' },
33
- age: { description: 'Age in years', type: 'number' },
34
- active: { description: 'Whether user is active', type: 'boolean' }
35
- }
36
+ id: { description: "User ID", type: "number" },
37
+ name: { description: "User name", type: "string" },
38
+ email: { description: "User email", type: "string" },
39
+ age: { description: "User age", type: "number" },
40
+ },
36
41
  },
37
- examples: [
38
- "LOAD JSON FROM mockUsers(10) AS user RETURN user.name, user.email",
39
- "LOAD JSON FROM mockUsers(20) AS user RETURN user WHERE user.active = true"
40
- ]
42
+ examples: ["CALL users() YIELD id, name, email, age"],
41
43
  })
42
- export class MockUsers extends AsyncFunction {
43
- private readonly firstNames: string[];
44
- private readonly lastNames: string[];
45
- private readonly domains: string[];
46
-
47
- constructor(
48
- firstNames: string[] = ['Alice', 'Bob', 'Charlie', 'Diana', 'Eve', 'Frank', 'Grace', 'Henry', 'Ivy', 'Jack'],
49
- lastNames: string[] = ['Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Garcia', 'Miller', 'Davis', 'Rodriguez', 'Martinez'],
50
- domains: string[] = ['example.com', 'test.org', 'demo.net']
51
- ) {
52
- super();
53
- this.firstNames = firstNames;
54
- this.lastNames = lastNames;
55
- this.domains = domains;
56
- }
57
-
58
- /**
59
- * Generates mock user data.
60
- *
61
- * @param count - Number of mock users to generate
62
- */
63
- async *generate(count: number = 5): AsyncGenerator<any, void, unknown> {
64
- for (let i = 0; i < count; i++) {
65
- const firstName = this.firstNames[Math.floor(Math.random() * this.firstNames.length)];
66
- const lastName = this.lastNames[Math.floor(Math.random() * this.lastNames.length)];
67
- const domain = this.domains[Math.floor(Math.random() * this.domains.length)];
68
-
69
- yield {
70
- id: i + 1,
71
- name: `${firstName} ${lastName}`,
72
- email: `${firstName.toLowerCase()}.${lastName.toLowerCase()}@${domain}`,
73
- age: Math.floor(Math.random() * 50) + 18,
74
- active: Math.random() > 0.3
75
- };
44
+ export class Users extends AsyncFunction {
45
+ async *generate(): AsyncGenerator<any, void, unknown> {
46
+ for (const user of usersData) {
47
+ yield user;
76
48
  }
77
49
  }
78
50
  }
79
51
 
80
- /**
81
- * MockProducts class - generates mock product data for testing.
82
- */
83
52
  @FunctionDef({
84
- description: 'Generates mock product data for testing purposes',
85
- category: 'async',
86
- parameters: [
87
- {
88
- name: 'count',
89
- description: 'Number of mock products to generate',
90
- type: 'number',
91
- required: false,
92
- default: 5
93
- }
94
- ],
53
+ description: "Returns mock product data",
54
+ category: "async",
55
+ parameters: [],
95
56
  output: {
96
- description: 'Mock product object',
97
- type: 'object',
57
+ description: "Product object",
58
+ type: "object",
98
59
  properties: {
99
- id: { description: 'Product ID', type: 'number' },
100
- name: { description: 'Product name', type: 'string' },
101
- category: { description: 'Product category', type: 'string' },
102
- price: { description: 'Price in dollars', type: 'number' },
103
- inStock: { description: 'Whether product is in stock', type: 'boolean' },
104
- rating: { description: 'Customer rating (0-5)', type: 'number' }
105
- }
60
+ id: { description: "Product ID", type: "number" },
61
+ name: { description: "Product name", type: "string" },
62
+ price: { description: "Product price", type: "number" },
63
+ category: { description: "Product category", type: "string" },
64
+ stock: { description: "Stock quantity", type: "number" },
65
+ },
106
66
  },
107
- examples: [
108
- "LOAD JSON FROM mockProducts(10) AS p RETURN p.name, p.price",
109
- "LOAD JSON FROM mockProducts(50) AS p RETURN p WHERE p.category = 'Electronics'"
110
- ]
67
+ examples: ["CALL products() YIELD id, name, price, category, stock"],
111
68
  })
112
- export class MockProducts extends AsyncFunction {
113
- private readonly categories: string[];
114
- private readonly adjectives: string[];
115
- private readonly nouns: string[];
116
-
117
- constructor(
118
- categories: string[] = ['Electronics', 'Clothing', 'Books', 'Home', 'Sports'],
119
- adjectives: string[] = ['Premium', 'Basic', 'Pro', 'Ultra', 'Classic'],
120
- nouns: string[] = ['Widget', 'Gadget', 'Item', 'Product', 'Thing']
121
- ) {
122
- super();
123
- this.categories = categories;
124
- this.adjectives = adjectives;
125
- this.nouns = nouns;
69
+ export class Products extends AsyncFunction {
70
+ async *generate(): AsyncGenerator<any, void, unknown> {
71
+ for (const product of productsData) {
72
+ yield product;
73
+ }
126
74
  }
75
+ }
127
76
 
128
- /**
129
- * Generates mock product data.
130
- *
131
- * @param count - Number of mock products to generate
132
- */
133
- async *generate(count: number = 5): AsyncGenerator<any, void, unknown> {
134
- for (let i = 0; i < count; i++) {
135
- const adj = this.adjectives[Math.floor(Math.random() * this.adjectives.length)];
136
- const noun = this.nouns[Math.floor(Math.random() * this.nouns.length)];
137
- const category = this.categories[Math.floor(Math.random() * this.categories.length)];
138
-
139
- yield {
140
- id: i + 1,
141
- name: `${adj} ${noun} ${i + 1}`,
142
- category,
143
- price: Math.round(Math.random() * 1000 * 100) / 100,
144
- inStock: Math.random() > 0.2,
145
- rating: Math.round(Math.random() * 50) / 10
146
- };
77
+ @FunctionDef({
78
+ description: "Returns mock order data",
79
+ category: "async",
80
+ parameters: [],
81
+ output: {
82
+ description: "Order object",
83
+ type: "object",
84
+ properties: {
85
+ id: { description: "Order ID", type: "number" },
86
+ userId: { description: "User ID who placed the order", type: "number" },
87
+ productId: { description: "Product ID ordered", type: "number" },
88
+ quantity: { description: "Quantity ordered", type: "number" },
89
+ total: { description: "Order total", type: "number" },
90
+ date: { description: "Order date", type: "string" },
91
+ },
92
+ },
93
+ examples: ["CALL orders() YIELD id, userId, productId, quantity, total, date"],
94
+ })
95
+ export class Orders extends AsyncFunction {
96
+ async *generate(): AsyncGenerator<any, void, unknown> {
97
+ for (const order of ordersData) {
98
+ yield order;
147
99
  }
148
100
  }
149
101
  }
150
-
151
- export { MockUsers as default };