qtype 0.1.11__py3-none-any.whl → 0.1.13__py3-none-any.whl

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 (263) hide show
  1. qtype/` +0 -0
  2. qtype/application/__init__.py +0 -2
  3. qtype/application/converters/tools_from_api.py +67 -57
  4. qtype/application/converters/tools_from_module.py +66 -32
  5. qtype/base/types.py +6 -1
  6. qtype/commands/convert.py +3 -6
  7. qtype/commands/generate.py +97 -10
  8. qtype/commands/mcp.py +68 -0
  9. qtype/commands/run.py +116 -44
  10. qtype/commands/validate.py +4 -4
  11. qtype/docs/.pages +8 -0
  12. qtype/docs/Concepts/mental-model-and-philosophy.md +363 -0
  13. qtype/docs/Contributing/.pages +4 -0
  14. qtype/docs/Contributing/index.md +283 -0
  15. qtype/docs/Contributing/roadmap.md +81 -0
  16. qtype/docs/Decisions/ADR-001-Chat-vs-Completion-Endpoint-Features.md +56 -0
  17. qtype/docs/Gallery/dataflow_pipelines.md +81 -0
  18. qtype/docs/Gallery/dataflow_pipelines.mermaid +45 -0
  19. qtype/docs/Gallery/research_assistant.md +97 -0
  20. qtype/docs/Gallery/research_assistant.mermaid +42 -0
  21. qtype/docs/Gallery/simple_chatbot.md +38 -0
  22. qtype/docs/Gallery/simple_chatbot.mermaid +35 -0
  23. qtype/docs/How To/Authentication/configure_aws_authentication.md +60 -0
  24. qtype/docs/How To/Authentication/use_api_key_authentication.md +40 -0
  25. qtype/docs/How To/Command Line Usage/load_multiple_inputs_from_files.md +77 -0
  26. qtype/docs/How To/Command Line Usage/pass_inputs_on_the_cli.md +52 -0
  27. qtype/docs/How To/Command Line Usage/serve_with_auto_reload.md +27 -0
  28. qtype/docs/How To/Data Processing/adjust_concurrency.md +40 -0
  29. qtype/docs/How To/Data Processing/cache_step_results.md +71 -0
  30. qtype/docs/How To/Data Processing/decode_json_xml.md +24 -0
  31. qtype/docs/How To/Data Processing/explode_collections.md +40 -0
  32. qtype/docs/How To/Data Processing/gather_results.md +68 -0
  33. qtype/docs/How To/Data Processing/invoke_other_flows.md +71 -0
  34. qtype/docs/How To/Data Processing/load_data_from_athena.md +49 -0
  35. qtype/docs/How To/Data Processing/read_data_from_files.md +61 -0
  36. qtype/docs/How To/Data Processing/read_sql_databases.md +46 -0
  37. qtype/docs/How To/Data Processing/write_data_to_file.md +39 -0
  38. qtype/docs/How To/Invoke Models/call_large_language_models.md +51 -0
  39. qtype/docs/How To/Invoke Models/create_embeddings.md +49 -0
  40. qtype/docs/How To/Invoke Models/reuse_prompts_with_templates.md +38 -0
  41. qtype/docs/How To/Language Features/include_qtype_yaml.md +45 -0
  42. qtype/docs/How To/Language Features/include_raw_text_from_other_files.md +48 -0
  43. qtype/docs/How To/Language Features/reference_entities_by_id.md +51 -0
  44. qtype/docs/How To/Language Features/use_agent_skills.md +29 -0
  45. qtype/docs/How To/Language Features/use_environment_variables.md +48 -0
  46. qtype/docs/How To/Language Features/use_optional_variables.md +42 -0
  47. qtype/docs/How To/Language Features/use_qtype_mcp.md +59 -0
  48. qtype/docs/How To/Observability & Debugging/trace_calls_with_open_telemetry.md +49 -0
  49. qtype/docs/How To/Observability & Debugging/validate_qtype_yaml.md +36 -0
  50. qtype/docs/How To/Observability & Debugging/visualize_application_architecture.md +61 -0
  51. qtype/docs/How To/Observability & Debugging/visualize_example.mermaid +35 -0
  52. qtype/docs/How To/Qtype Server/flow_as_ui.png +0 -0
  53. qtype/docs/How To/Qtype Server/serve_flows_as_apis.md +40 -0
  54. qtype/docs/How To/Qtype Server/serve_flows_as_ui.md +41 -0
  55. qtype/docs/How To/Qtype Server/use_conversational_interfaces.md +56 -0
  56. qtype/docs/How To/Qtype Server/use_variables_with_ui_hints.md +48 -0
  57. qtype/docs/How To/Tools & Integration/bind_tool_inputs_and_outputs.md +47 -0
  58. qtype/docs/How To/Tools & Integration/create_tools_from_openapi_specifications.md +85 -0
  59. qtype/docs/How To/Tools & Integration/create_tools_from_python_modules.md +87 -0
  60. qtype/docs/Reference/cli.md +336 -0
  61. qtype/docs/Reference/plugins.md +99 -0
  62. qtype/docs/Reference/semantic-validation-rules.md +184 -0
  63. qtype/docs/Tutorials/.pages +1 -0
  64. qtype/docs/Tutorials/01-first-qtype-application.md +249 -0
  65. qtype/docs/Tutorials/02-conversational-chatbot.md +327 -0
  66. qtype/docs/Tutorials/03-structured-data.md +480 -0
  67. qtype/docs/Tutorials/04-tools-and-function-calling.md +476 -0
  68. qtype/docs/Tutorials/example_chat.png +0 -0
  69. qtype/docs/Tutorials/index.md +92 -0
  70. qtype/docs/components/APIKeyAuthProvider.md +7 -0
  71. qtype/docs/components/APITool.md +10 -0
  72. qtype/docs/components/AWSAuthProvider.md +13 -0
  73. qtype/docs/components/AWSSecretManager.md +5 -0
  74. qtype/docs/components/Agent.md +6 -0
  75. qtype/docs/components/Aggregate.md +7 -0
  76. qtype/docs/components/AggregateStats.md +7 -0
  77. qtype/docs/components/Application.md +22 -0
  78. qtype/docs/components/AuthorizationProvider.md +6 -0
  79. qtype/docs/components/AuthorizationProviderList.md +5 -0
  80. qtype/docs/components/BearerTokenAuthProvider.md +6 -0
  81. qtype/docs/components/BedrockReranker.md +8 -0
  82. qtype/docs/components/ChatContent.md +7 -0
  83. qtype/docs/components/ChatMessage.md +6 -0
  84. qtype/docs/components/Collect.md +6 -0
  85. qtype/docs/components/ConstantPath.md +5 -0
  86. qtype/docs/components/Construct.md +6 -0
  87. qtype/docs/components/CustomType.md +7 -0
  88. qtype/docs/components/Decoder.md +8 -0
  89. qtype/docs/components/DecoderFormat.md +8 -0
  90. qtype/docs/components/DocToTextConverter.md +7 -0
  91. qtype/docs/components/Document.md +7 -0
  92. qtype/docs/components/DocumentEmbedder.md +6 -0
  93. qtype/docs/components/DocumentIndex.md +7 -0
  94. qtype/docs/components/DocumentSearch.md +7 -0
  95. qtype/docs/components/DocumentSource.md +12 -0
  96. qtype/docs/components/DocumentSplitter.md +9 -0
  97. qtype/docs/components/Echo.md +8 -0
  98. qtype/docs/components/Embedding.md +7 -0
  99. qtype/docs/components/EmbeddingModel.md +6 -0
  100. qtype/docs/components/Explode.md +5 -0
  101. qtype/docs/components/FieldExtractor.md +21 -0
  102. qtype/docs/components/FileSource.md +6 -0
  103. qtype/docs/components/FileWriter.md +7 -0
  104. qtype/docs/components/Flow.md +14 -0
  105. qtype/docs/components/FlowInterface.md +7 -0
  106. qtype/docs/components/Index.md +8 -0
  107. qtype/docs/components/IndexUpsert.md +6 -0
  108. qtype/docs/components/InvokeEmbedding.md +7 -0
  109. qtype/docs/components/InvokeFlow.md +8 -0
  110. qtype/docs/components/InvokeTool.md +8 -0
  111. qtype/docs/components/LLMInference.md +9 -0
  112. qtype/docs/components/ListType.md +5 -0
  113. qtype/docs/components/Memory.md +8 -0
  114. qtype/docs/components/MessageRole.md +14 -0
  115. qtype/docs/components/Model.md +10 -0
  116. qtype/docs/components/ModelList.md +5 -0
  117. qtype/docs/components/OAuth2AuthProvider.md +9 -0
  118. qtype/docs/components/PrimitiveTypeEnum.md +20 -0
  119. qtype/docs/components/PromptTemplate.md +7 -0
  120. qtype/docs/components/PythonFunctionTool.md +7 -0
  121. qtype/docs/components/RAGChunk.md +7 -0
  122. qtype/docs/components/RAGDocument.md +10 -0
  123. qtype/docs/components/RAGSearchResult.md +8 -0
  124. qtype/docs/components/Reranker.md +5 -0
  125. qtype/docs/components/SQLSource.md +8 -0
  126. qtype/docs/components/Search.md +7 -0
  127. qtype/docs/components/SearchResult.md +7 -0
  128. qtype/docs/components/SecretManager.md +7 -0
  129. qtype/docs/components/SecretReference.md +7 -0
  130. qtype/docs/components/Source.md +5 -0
  131. qtype/docs/components/Step.md +8 -0
  132. qtype/docs/components/TelemetrySink.md +9 -0
  133. qtype/docs/components/Tool.md +9 -0
  134. qtype/docs/components/ToolList.md +5 -0
  135. qtype/docs/components/TypeList.md +5 -0
  136. qtype/docs/components/Variable.md +8 -0
  137. qtype/docs/components/VariableList.md +5 -0
  138. qtype/docs/components/VectorIndex.md +7 -0
  139. qtype/docs/components/VectorSearch.md +6 -0
  140. qtype/docs/components/VertexAuthProvider.md +9 -0
  141. qtype/docs/components/Writer.md +5 -0
  142. qtype/docs/example_ui.png +0 -0
  143. qtype/docs/index.md +81 -0
  144. qtype/docs/legacy_how_tos/.pages +6 -0
  145. qtype/docs/legacy_how_tos/Configuration/modular-yaml.md +366 -0
  146. qtype/docs/legacy_how_tos/Configuration/phoenix_projects.png +0 -0
  147. qtype/docs/legacy_how_tos/Configuration/phoenix_traces.png +0 -0
  148. qtype/docs/legacy_how_tos/Configuration/reference-by-id.md +251 -0
  149. qtype/docs/legacy_how_tos/Configuration/telemetry-setup.md +259 -0
  150. qtype/docs/legacy_how_tos/Data Types/custom-types.md +52 -0
  151. qtype/docs/legacy_how_tos/Data Types/domain-types.md +113 -0
  152. qtype/docs/legacy_how_tos/Debugging/visualize-apps.md +147 -0
  153. qtype/docs/legacy_how_tos/Tools/api-tools.md +29 -0
  154. qtype/docs/legacy_how_tos/Tools/python-tools.md +299 -0
  155. qtype/docs/skills/architect/SKILL.md +188 -0
  156. qtype/docs/skills/architect/references/cheatsheet.md +198 -0
  157. qtype/docs/skills/architect/references/patterns.md +29 -0
  158. qtype/docs/stylesheets/extra.css +27 -0
  159. qtype/dsl/custom_types.py +2 -1
  160. qtype/dsl/linker.py +23 -7
  161. qtype/dsl/loader.py +3 -3
  162. qtype/dsl/model.py +181 -67
  163. qtype/examples/authentication/aws_authentication.qtype.yaml +63 -0
  164. qtype/examples/conversational_ai/hello_world_chat.qtype.yaml +43 -0
  165. qtype/examples/conversational_ai/simple_chatbot.qtype.yaml +40 -0
  166. qtype/examples/data_processing/athena_query.qtype.yaml +56 -0
  167. qtype/examples/data_processing/batch_inputs.csv +5 -0
  168. qtype/examples/data_processing/batch_processing.qtype.yaml +54 -0
  169. qtype/examples/data_processing/cache_step_results.qtype.yaml +78 -0
  170. qtype/examples/data_processing/collect_results.qtype.yaml +55 -0
  171. qtype/examples/data_processing/create_sample_db.py +129 -0
  172. qtype/examples/data_processing/dataflow_pipelines.qtype.yaml +108 -0
  173. qtype/examples/data_processing/decode_json.qtype.yaml +23 -0
  174. qtype/examples/data_processing/explode_items.qtype.yaml +25 -0
  175. qtype/examples/data_processing/invoke_other_flows.qtype.yaml +98 -0
  176. qtype/examples/data_processing/read_file.qtype.yaml +60 -0
  177. qtype/examples/data_processing/reviews.db +0 -0
  178. qtype/examples/data_processing/sample_article.txt +1 -0
  179. qtype/examples/data_processing/sample_documents.jsonl +5 -0
  180. qtype/examples/invoke_models/create_embeddings.qtype.yaml +28 -0
  181. qtype/examples/invoke_models/simple_llm_call.qtype.yaml +32 -0
  182. qtype/examples/language_features/include_raw.qtype.yaml +27 -0
  183. qtype/examples/language_features/optional_variables.qtype.yaml +32 -0
  184. qtype/examples/language_features/story_prompt.txt +6 -0
  185. qtype/examples/language_features/ui_hints.qtype.yaml +52 -0
  186. qtype/examples/legacy/bedrock/data_analysis_with_telemetry.qtype.yaml +169 -0
  187. qtype/examples/legacy/bedrock/hello_world.qtype.yaml +39 -0
  188. qtype/examples/legacy/bedrock/hello_world_chat.qtype.yaml +37 -0
  189. qtype/examples/legacy/bedrock/hello_world_chat_with_telemetry.qtype.yaml +40 -0
  190. qtype/examples/legacy/bedrock/hello_world_chat_with_thinking.qtype.yaml +40 -0
  191. qtype/examples/legacy/bedrock/hello_world_completion.qtype.yaml +41 -0
  192. qtype/examples/legacy/bedrock/hello_world_completion_with_auth.qtype.yaml +44 -0
  193. qtype/examples/legacy/bedrock/simple_agent_chat.qtype.yaml +46 -0
  194. qtype/examples/legacy/chat_with_langfuse.qtype.yaml +50 -0
  195. qtype/examples/legacy/data/customers.csv +6 -0
  196. qtype/examples/legacy/data_processor.qtype.yaml +48 -0
  197. qtype/examples/legacy/echo/debug_example.qtype.yaml +59 -0
  198. qtype/examples/legacy/echo/prompt.qtype.yaml +22 -0
  199. qtype/examples/legacy/echo/readme.md +29 -0
  200. qtype/examples/legacy/echo/test.qtype.yaml +26 -0
  201. qtype/examples/legacy/echo/video.qtype.yaml +20 -0
  202. qtype/examples/legacy/field_extractor_example.qtype.yaml +137 -0
  203. qtype/examples/legacy/multi_flow_example.qtype.yaml +125 -0
  204. qtype/examples/legacy/openai/hello_world_chat.qtype.yaml +43 -0
  205. qtype/examples/legacy/openai/hello_world_chat_with_telemetry.qtype.yaml +46 -0
  206. qtype/examples/legacy/qtype_plugin_example.py +51 -0
  207. qtype/examples/legacy/rag.qtype.yaml +207 -0
  208. qtype/examples/legacy/sample_data.txt +43 -0
  209. qtype/examples/legacy/time_utilities.qtype.yaml +64 -0
  210. qtype/examples/legacy/vertex/README.md +11 -0
  211. qtype/examples/legacy/vertex/hello_world_chat.qtype.yaml +36 -0
  212. qtype/examples/legacy/vertex/hello_world_completion.qtype.yaml +40 -0
  213. qtype/examples/legacy/vertex/hello_world_completion_with_auth.qtype.yaml +45 -0
  214. qtype/examples/observability_debugging/trace_with_opentelemetry.qtype.yaml +40 -0
  215. qtype/examples/research_assistant/research_assistant.qtype.yaml +94 -0
  216. qtype/examples/research_assistant/tavily.oas.yaml +722 -0
  217. qtype/examples/research_assistant/tavily.qtype.yaml +216 -0
  218. qtype/examples/tutorials/01_hello_world.qtype.yaml +48 -0
  219. qtype/examples/tutorials/02_conversational_chat.qtype.yaml +37 -0
  220. qtype/examples/tutorials/03_structured_data.qtype.yaml +130 -0
  221. qtype/examples/tutorials/04_tools_and_function_calling.qtype.yaml +89 -0
  222. qtype/interpreter/api.py +4 -1
  223. qtype/interpreter/base/base_step_executor.py +3 -1
  224. qtype/interpreter/base/stream_emitter.py +19 -13
  225. qtype/interpreter/conversions.py +7 -3
  226. qtype/interpreter/converters.py +142 -26
  227. qtype/interpreter/executors/agent_executor.py +2 -3
  228. qtype/interpreter/executors/aggregate_executor.py +3 -4
  229. qtype/interpreter/executors/construct_executor.py +15 -15
  230. qtype/interpreter/executors/doc_to_text_executor.py +1 -3
  231. qtype/interpreter/executors/field_extractor_executor.py +13 -12
  232. qtype/interpreter/executors/file_source_executor.py +21 -34
  233. qtype/interpreter/executors/file_writer_executor.py +4 -4
  234. qtype/interpreter/executors/index_upsert_executor.py +1 -1
  235. qtype/interpreter/executors/invoke_embedding_executor.py +1 -4
  236. qtype/interpreter/executors/invoke_flow_executor.py +2 -2
  237. qtype/interpreter/executors/invoke_tool_executor.py +19 -18
  238. qtype/interpreter/executors/llm_inference_executor.py +16 -18
  239. qtype/interpreter/executors/prompt_template_executor.py +1 -3
  240. qtype/interpreter/executors/sql_source_executor.py +1 -1
  241. qtype/interpreter/resource_cache.py +3 -1
  242. qtype/interpreter/rich_progress.py +6 -3
  243. qtype/interpreter/stream/chat/converter.py +25 -17
  244. qtype/interpreter/stream/chat/ui_request_to_domain_type.py +2 -2
  245. qtype/interpreter/tools/function_tool_helper.py +11 -10
  246. qtype/interpreter/types.py +89 -4
  247. qtype/interpreter/typing.py +35 -38
  248. qtype/mcp/__init__.py +0 -0
  249. qtype/mcp/server.py +722 -0
  250. qtype/schema/qtype.schema.json +4016 -0
  251. qtype/semantic/checker.py +20 -1
  252. qtype/semantic/generate.py +6 -9
  253. qtype/semantic/model.py +26 -33
  254. qtype/semantic/resolver.py +7 -0
  255. qtype/semantic/visualize.py +45 -53
  256. {qtype-0.1.11.dist-info → qtype-0.1.13.dist-info}/METADATA +65 -44
  257. qtype-0.1.13.dist-info/RECORD +352 -0
  258. {qtype-0.1.11.dist-info → qtype-0.1.13.dist-info}/WHEEL +1 -2
  259. qtype/application/facade.py +0 -177
  260. qtype-0.1.11.dist-info/RECORD +0 -142
  261. qtype-0.1.11.dist-info/top_level.txt +0 -1
  262. {qtype-0.1.11.dist-info → qtype-0.1.13.dist-info}/entry_points.txt +0 -0
  263. {qtype-0.1.11.dist-info → qtype-0.1.13.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,56 @@
1
+ id: athena-query-example
2
+ description: Query AWS Athena database and process results
3
+
4
+ auths:
5
+ - type: aws
6
+ id: aws_auth
7
+ region: us-east-1
8
+ profile_name: default
9
+
10
+ flows:
11
+ - type: Flow
12
+ id: query-athena
13
+
14
+ variables:
15
+ - id: min_sales
16
+ type: int
17
+ - id: product_id
18
+ type: text
19
+ - id: product_name
20
+ type: text
21
+ - id: total_sales
22
+ type: int
23
+ - id: region
24
+ type: text
25
+
26
+ inputs:
27
+ - min_sales
28
+
29
+ outputs:
30
+ - product_id
31
+ - product_name
32
+ - total_sales
33
+ - region
34
+
35
+ steps:
36
+ - type: SQLSource
37
+ id: load_sales
38
+ connection: "awsathena+rest://:@athena.us-east-1.amazonaws.com:443/sales_db?s3_staging_dir=s3://my-results-bucket/athena-results/&work_group=primary&catalog_name=some_catalog""
39
+ auth: aws_auth
40
+ query: |
41
+ SELECT
42
+ product_id,
43
+ product_name,
44
+ total_sales,
45
+ region
46
+ FROM product_sales
47
+ WHERE total_sales >= :min_sales
48
+ ORDER BY total_sales DESC
49
+ LIMIT 100
50
+ inputs:
51
+ - min_sales
52
+ outputs:
53
+ - product_id
54
+ - product_name
55
+ - total_sales
56
+ - region
@@ -0,0 +1,5 @@
1
+ query,topic
2
+ What is machine learning?,Technology
3
+ Best pasta recipes,Cooking
4
+ How to train for a marathon,Fitness
5
+ Climate change solutions,Environment
@@ -0,0 +1,54 @@
1
+ id: batch_processing_example
2
+ description: Process multiple inputs loaded from a file
3
+
4
+ models:
5
+ - type: Model
6
+ id: nova_lite
7
+ provider: aws-bedrock
8
+ model_id: amazon.nova-lite-v1:0
9
+
10
+ flows:
11
+ - type: Flow
12
+ id: process_queries
13
+ description: Process multiple queries in batch
14
+
15
+ variables:
16
+ - id: query
17
+ type: text
18
+ - id: topic
19
+ type: text
20
+ - id: prompt
21
+ type: text
22
+ - id: response
23
+ type: text
24
+
25
+ inputs:
26
+ - query
27
+ - topic
28
+
29
+ outputs:
30
+ - query
31
+ - topic
32
+ - response
33
+
34
+ steps:
35
+ - id: create_prompt
36
+ type: PromptTemplate
37
+ template: |
38
+ Category: {topic}
39
+ Question: {query}
40
+
41
+ Provide a brief, helpful answer:
42
+ inputs:
43
+ - query
44
+ - topic
45
+ outputs:
46
+ - prompt
47
+
48
+ - id: answer_query
49
+ type: LLMInference
50
+ model: nova_lite
51
+ inputs:
52
+ - prompt
53
+ outputs:
54
+ - response
@@ -0,0 +1,78 @@
1
+ id: cache_step_demo
2
+ description: |
3
+ Demonstrates step caching to avoid redundant computation.
4
+ On first run, classifications are cached. On subsequent runs with same inputs,
5
+ results are retrieved from cache.
6
+
7
+ auths:
8
+ - type: aws
9
+ id: aws_auth
10
+ region: us-east-1
11
+
12
+ models:
13
+ - type: Model
14
+ id: nova
15
+ provider: aws-bedrock
16
+ model_id: us.amazon.nova-micro-v1:0
17
+ auth: aws_auth
18
+
19
+ flows:
20
+ - id: classify_documents
21
+ variables:
22
+ - id: file_path
23
+ type: text
24
+ - id: document
25
+ type: text
26
+ - id: prompt
27
+ type: text
28
+ - id: category
29
+ type: text
30
+ - id: output_file
31
+ type: text
32
+
33
+ inputs:
34
+ - file_path
35
+
36
+ outputs:
37
+ - output_file
38
+
39
+ steps:
40
+ - type: FileSource
41
+ id: load_docs
42
+ path: file_path
43
+ outputs: [document]
44
+
45
+ - type: PromptTemplate
46
+ id: create_classification_prompt
47
+ template: |
48
+ Classify this document into one of these categories:
49
+ - Technology
50
+ - Finance
51
+ - Healthcare
52
+ - Education
53
+
54
+ Document: {document}
55
+
56
+ Reply with only the category name.
57
+ inputs: [document]
58
+ outputs: [prompt]
59
+
60
+ - type: LLMInference
61
+ id: classify
62
+ model: nova
63
+ inputs: [prompt]
64
+ outputs: [category]
65
+ # Enable caching with configuration
66
+ cache_config:
67
+ namespace: document_classification # Logical separation for cache
68
+ version: "1.0" # Bump this to invalidate cache
69
+ on_error: Drop # Don't cache errors (default)
70
+ ttl: 3600 # Cache for 1 hour (seconds)
71
+ compress: false # Optionally compress cached data
72
+
73
+ - type: FileWriter
74
+ id: write_results
75
+ path:
76
+ uri: classification_results.parquet
77
+ inputs: [document, category]
78
+ outputs: [output_file]
@@ -0,0 +1,55 @@
1
+ id: collect_example
2
+ description: Aggregate fan-out results preserving only common ancestor variables
3
+
4
+ flows:
5
+ - type: Flow
6
+ id: main
7
+ description: Process products by category, then collect results
8
+
9
+ variables:
10
+ - id: category
11
+ type: text
12
+ - id: region
13
+ type: text
14
+ - id: products
15
+ type: list[text]
16
+ - id: product
17
+ type: text
18
+ - id: processed_product
19
+ type: text
20
+ - id: all_processed
21
+ type: list[text]
22
+
23
+ inputs:
24
+ - category
25
+ - region
26
+ - products
27
+
28
+ outputs:
29
+ - all_processed
30
+
31
+ steps:
32
+ # Explode creates multiple messages, each with:
33
+ # - category (same for all)
34
+ # - region (same for all)
35
+ # - product (different for each)
36
+ - type: Explode
37
+ id: fan_out
38
+ inputs: [products]
39
+ outputs: [product]
40
+
41
+ # Each message still has category, region, and its unique product
42
+ - type: PromptTemplate
43
+ id: process
44
+ inputs: [product]
45
+ outputs: [processed_product]
46
+ template: "Processed: {product}"
47
+
48
+ # Collect aggregates all processed_product values into a list
49
+ # Only category and region are preserved as "common ancestors"
50
+ # (same value across all messages)
51
+ # The unique product variable is NOT preserved (different in each)
52
+ - type: Collect
53
+ id: aggregate
54
+ inputs: [processed_product]
55
+ outputs: [all_processed]
@@ -0,0 +1,129 @@
1
+ """Create a sample SQLite database with product reviews for the example."""
2
+
3
+ import sqlite3
4
+ from pathlib import Path
5
+
6
+ # Sample product reviews data
7
+ SAMPLE_REVIEWS = [
8
+ (
9
+ 1,
10
+ "Wireless Headphones",
11
+ 5,
12
+ "Amazing sound quality! The noise cancellation is superb and "
13
+ "battery lasts all day. Highly recommend for music lovers.",
14
+ ),
15
+ (
16
+ 2,
17
+ "Wireless Headphones",
18
+ 2,
19
+ "Disappointed with the build quality. They broke after just 2 "
20
+ "weeks of normal use. Sound is okay but not worth the price.",
21
+ ),
22
+ (
23
+ 3,
24
+ "Smart Watch",
25
+ 4,
26
+ "Great fitness tracker with accurate heart rate monitoring. "
27
+ "Battery life could be better, but overall very satisfied.",
28
+ ),
29
+ (
30
+ 4,
31
+ "Smart Watch",
32
+ 5,
33
+ "Best smartwatch I've owned! Seamless integration with my phone, "
34
+ "tons of useful features, and looks professional.",
35
+ ),
36
+ (
37
+ 5,
38
+ "Laptop Stand",
39
+ 3,
40
+ "Does the job but feels flimsy. The adjustability is limited and "
41
+ "it wobbles a bit. Expected better quality for the price.",
42
+ ),
43
+ (
44
+ 6,
45
+ "Laptop Stand",
46
+ 5,
47
+ "Perfect for my home office setup! Sturdy construction, multiple "
48
+ "height options, and really helps with posture.",
49
+ ),
50
+ (
51
+ 7,
52
+ "USB-C Hub",
53
+ 4,
54
+ "Works well with all my devices. All ports function properly and "
55
+ "data transfer is fast. Gets a bit warm during heavy use.",
56
+ ),
57
+ (
58
+ 8,
59
+ "USB-C Hub",
60
+ 1,
61
+ "Stopped working after a week. One port was DOA and then the whole "
62
+ "hub died. Total waste of money.",
63
+ ),
64
+ (
65
+ 9,
66
+ "Mechanical Keyboard",
67
+ 5,
68
+ "Typing feels incredible! The switches are responsive and the build "
69
+ "quality is excellent. Worth every penny.",
70
+ ),
71
+ (
72
+ 10,
73
+ "Mechanical Keyboard",
74
+ 4,
75
+ "Great keyboard for coding. Switches are a bit loud for an office "
76
+ "environment but the tactile feedback is amazing.",
77
+ ),
78
+ ]
79
+
80
+
81
+ def create_database(db_path: Path | str) -> None:
82
+ """Create SQLite database with sample product reviews.
83
+
84
+ Args:
85
+ db_path: Path where the database file should be created
86
+ """
87
+ db_path = Path(db_path)
88
+
89
+ # Remove existing database if it exists
90
+ if db_path.exists():
91
+ db_path.unlink()
92
+
93
+ # Create database and table
94
+ conn = sqlite3.connect(db_path)
95
+ cursor = conn.cursor()
96
+
97
+ # Create reviews table
98
+ cursor.execute(
99
+ """
100
+ CREATE TABLE product_reviews (
101
+ review_id INTEGER PRIMARY KEY,
102
+ product_name TEXT NOT NULL,
103
+ rating INTEGER NOT NULL CHECK (rating >= 1 AND rating <= 5),
104
+ review_text TEXT NOT NULL,
105
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
106
+ )
107
+ """
108
+ )
109
+
110
+ # Insert sample data
111
+ cursor.executemany(
112
+ """
113
+ INSERT INTO product_reviews
114
+ (review_id, product_name, rating, review_text)
115
+ VALUES (?, ?, ?, ?)
116
+ """,
117
+ SAMPLE_REVIEWS,
118
+ )
119
+
120
+ conn.commit()
121
+ conn.close()
122
+
123
+ print(f"Created database at {db_path} with {len(SAMPLE_REVIEWS)} reviews")
124
+
125
+
126
+ if __name__ == "__main__":
127
+ # Create database in the data_processing examples directory
128
+ db_path = Path(__file__).parent / "reviews.db"
129
+ create_database(db_path)
@@ -0,0 +1,108 @@
1
+ id: review_analysis_pipeline
2
+ description: |
3
+ Automated product review analysis pipeline demonstrating dataflow processing.
4
+ Reads reviews from SQLite database, analyzes sentiment with LLM, and writes
5
+ enriched results to a Parquet file.
6
+
7
+ models:
8
+ - type: Model
9
+ id: nova_lite
10
+ provider: aws-bedrock
11
+ model_id: amazon.nova-lite-v1:0
12
+ inference_params:
13
+ temperature: 0.7
14
+ max_tokens: 256
15
+
16
+ flows:
17
+ - type: Flow
18
+ id: analyze_reviews
19
+ description: Batch process product reviews with LLM sentiment analysis
20
+
21
+ variables:
22
+ - id: review_id
23
+ type: int
24
+ - id: product_name
25
+ type: text
26
+ - id: rating
27
+ type: int
28
+ - id: review_text
29
+ type: text
30
+ - id: analysis_prompt
31
+ type: text
32
+ - id: llm_analysis
33
+ type: text
34
+ - id: output_path
35
+ type: text
36
+ - id: result_file
37
+ type: text
38
+
39
+ inputs:
40
+ - output_path
41
+
42
+ outputs:
43
+ - result_file
44
+
45
+ steps:
46
+ # Step 1: Read reviews from SQLite database
47
+ # SQLSource emits one message per database row
48
+ - id: load_reviews
49
+ type: SQLSource
50
+ connection: "sqlite:///examples/data_processing/reviews.db"
51
+ query: |
52
+ SELECT
53
+ review_id,
54
+ product_name,
55
+ rating,
56
+ review_text
57
+ FROM product_reviews
58
+ ORDER BY review_id
59
+ inputs: []
60
+ outputs:
61
+ - review_id
62
+ - product_name
63
+ - rating
64
+ - review_text
65
+
66
+ # Step 2: Format analysis prompt for each review
67
+ # PromptTemplate creates structured prompts from review data
68
+ - id: create_prompt
69
+ type: PromptTemplate
70
+ template: |
71
+ Analyze this product review in 1-2 sentences. Include:
72
+ - Overall sentiment (positive/negative/mixed)
73
+ - 2-3 key themes or points
74
+
75
+ Product: {product_name}
76
+ Rating: {rating}/5
77
+ Review: {review_text}
78
+ inputs:
79
+ - product_name
80
+ - rating
81
+ - review_text
82
+ outputs:
83
+ - analysis_prompt
84
+
85
+ # Step 3: Analyze each review with LLM
86
+ # LLMInference processes each message through the language model
87
+ - id: analyze_sentiment
88
+ type: LLMInference
89
+ model: nova_lite
90
+ inputs:
91
+ - analysis_prompt
92
+ outputs:
93
+ - llm_analysis
94
+
95
+ # Step 4: Write enriched results to Parquet file
96
+ # FileWriter batches all messages and writes once
97
+ - id: write_results
98
+ type: FileWriter
99
+ path: output_path
100
+ inputs:
101
+ - review_id
102
+ - product_name
103
+ - rating
104
+ - review_text
105
+ - llm_analysis
106
+ - output_path
107
+ outputs:
108
+ - result_file
@@ -0,0 +1,23 @@
1
+ id: decode_json_example
2
+ description: Decode JSON string into structured data
3
+
4
+ flows:
5
+ - id: decode_product
6
+ description: Parse JSON string into variables
7
+ inputs: [json_string]
8
+ outputs: [name, price]
9
+
10
+ variables:
11
+ - id: json_string
12
+ type: text
13
+ - id: name
14
+ type: text
15
+ - id: price
16
+ type: float
17
+
18
+ steps:
19
+ - type: Decoder
20
+ id: parse_json
21
+ format: json
22
+ inputs: [json_string]
23
+ outputs: [name, price]
@@ -0,0 +1,25 @@
1
+ id: explode_example
2
+ description: Explode a list into individual items for fan-out processing
3
+
4
+ flows:
5
+ - type: Flow
6
+ id: main
7
+ description: Takes a list and processes each item individually
8
+
9
+ variables:
10
+ - id: items
11
+ type: list[text]
12
+ - id: item
13
+ type: text
14
+
15
+ inputs:
16
+ - items
17
+
18
+ outputs:
19
+ - item
20
+
21
+ steps:
22
+ - type: Explode
23
+ id: fan_out
24
+ inputs: [items]
25
+ outputs: [item]
@@ -0,0 +1,98 @@
1
+ id: text_analysis_pipeline
2
+ description: Demonstrates invoking reusable flows for text analysis
3
+
4
+ models:
5
+ - type: Model
6
+ id: nova_lite
7
+ provider: aws-bedrock
8
+ model_id: amazon.nova-lite-v1:0
9
+
10
+ flows:
11
+ # Reusable flow for text summarization
12
+ - type: Flow
13
+ id: summarize_text
14
+ description: Summarizes input text
15
+ variables:
16
+ - id: input_text
17
+ type: text
18
+ - id: output_summary
19
+ type: text
20
+ inputs:
21
+ - input_text
22
+ outputs:
23
+ - output_summary
24
+ steps:
25
+ - type: LLMInference
26
+ id: summarize_step
27
+ model: nova_lite
28
+ system_message: "You provide concise summaries."
29
+ inputs: [input_text]
30
+ outputs: [output_summary]
31
+
32
+ # Reusable flow for sentiment analysis
33
+ - type: Flow
34
+ id: analyze_sentiment
35
+ description: Analyzes sentiment of text
36
+ variables:
37
+ - id: input_for_sentiment
38
+ type: text
39
+ - id: output_sentiment
40
+ type: text
41
+ inputs:
42
+ - input_for_sentiment
43
+ outputs:
44
+ - output_sentiment
45
+ steps:
46
+ - type: LLMInference
47
+ id: sentiment_step
48
+ model: nova_lite
49
+ system_message: "Analyze sentiment. Respond with only: positive, negative, or neutral."
50
+ inputs: [input_for_sentiment]
51
+ outputs: [output_sentiment]
52
+
53
+ # Main processing flow
54
+ - type: Flow
55
+ id: main
56
+ description: Orchestrates text analysis using multiple flows
57
+ variables:
58
+ - id: article_text
59
+ type: text
60
+ - id: summary
61
+ type: text
62
+ - id: sentiment
63
+ type: text
64
+ - id: report
65
+ type: text
66
+ inputs:
67
+ - article_text
68
+ outputs:
69
+ - report
70
+ steps:
71
+ # Invoke summarization flow
72
+ - type: InvokeFlow
73
+ id: get_summary
74
+ flow: summarize_text
75
+ input_bindings:
76
+ input_text: article_text
77
+ output_bindings:
78
+ output_summary: summary
79
+
80
+ # Invoke sentiment analysis flow
81
+ - type: InvokeFlow
82
+ id: get_sentiment
83
+ flow: analyze_sentiment
84
+ input_bindings:
85
+ input_for_sentiment: article_text
86
+ output_bindings:
87
+ output_sentiment: sentiment
88
+
89
+ # Combine results into a report
90
+ - type: PromptTemplate
91
+ id: create_report
92
+ template: |
93
+ Analysis Report
94
+ ---------------
95
+ Sentiment: {sentiment}
96
+ Summary: {summary}
97
+ inputs: [summary, sentiment]
98
+ outputs: [report]
@@ -0,0 +1,60 @@
1
+ id: read_file_example
2
+ description: Read data from a CSV file
3
+
4
+ models:
5
+ - type: Model
6
+ id: nova
7
+ provider: aws-bedrock
8
+ model_id: amazon.nova-lite-v1:0
9
+
10
+ flows:
11
+ - type: Flow
12
+ id: process_file_data
13
+ description: Read and process data from a CSV file
14
+
15
+ variables:
16
+ - id: query
17
+ type: text
18
+ - id: topic
19
+ type: text
20
+ - id: prompt
21
+ type: text
22
+ - id: answer
23
+ type: text
24
+
25
+ inputs: []
26
+
27
+ outputs:
28
+ - query
29
+ - topic
30
+ - answer
31
+
32
+ steps:
33
+ - id: read_data
34
+ type: FileSource
35
+ path:
36
+ uri: examples/data_processing/batch_inputs.csv
37
+ outputs:
38
+ - query
39
+ - topic
40
+
41
+ - id: create_prompt
42
+ type: PromptTemplate
43
+ template: |
44
+ Topic: {topic}
45
+ Question: {query}
46
+
47
+ Provide a concise answer:
48
+ inputs:
49
+ - query
50
+ - topic
51
+ outputs:
52
+ - prompt
53
+
54
+ - id: generate_answer
55
+ type: LLMInference
56
+ model: nova
57
+ inputs:
58
+ - prompt
59
+ outputs:
60
+ - answer
@@ -0,0 +1 @@
1
+ Artificial intelligence is revolutionizing healthcare by enabling faster diagnoses and personalized treatment plans. Machine learning algorithms can analyze medical images with incredible accuracy, helping doctors detect diseases earlier. This technology is improving patient outcomes and reducing healthcare costs.
@@ -0,0 +1,5 @@
1
+ {"document": "The new quantum computing breakthrough could revolutionize AI processing speeds."}
2
+ {"document": "Federal Reserve announces interest rate changes to combat inflation."}
3
+ {"document": "New clinical trial shows promising results for cancer treatment."}
4
+ {"document": "University expands online learning programs for remote students."}
5
+ {"document": "Cryptocurrency markets experience volatility amid regulatory concerns."}