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,363 @@
1
+ # Mental Model & Philosophy
2
+
3
+ ## What is QType?
4
+
5
+ **QType is a domain-specific language (DSL) for rapid prototyping of AI applications.**
6
+
7
+ Qtype is a declarative, text-based language that lets you specify *what* your AI application should do, not *how* to do it. You write YAML specifications that describe flows, steps, models, and data transformations, and QType handles the execution.
8
+
9
+ **Elevator pitch:** QType turns AI application prototypes from days of Python coding into hours of YAML configuration, without sacrificing maintainability or requiring you to learn yet another GUI tool.
10
+
11
+ ---
12
+
13
+ ## Core Mental Model: The Three Primitives
14
+
15
+ Understanding QType requires understanding three core concepts and how they relate:
16
+
17
+ **Think of QType like this:**
18
+
19
+ **Variables** are your data containers (typed boxes)
20
+ **Steps** are your transformations (functions on boxes)
21
+ **Flows** are your pipelines (sequences of transformations)
22
+ **The DSL** is your specification language (what you write)
23
+ **The Semantic layer** is your validator (what checks it)
24
+ **The Interpreter** is your executor (what runs it)
25
+
26
+ **You declare what you want, QType handles how to do it.**
27
+
28
+
29
+ ### 1. Variables: The Data
30
+
31
+ **Variables are typed data containers** that hold values as they move through your application.
32
+
33
+ ```yaml
34
+ variables:
35
+ - id: question # A variable named "question"
36
+ type: text # It holds text data
37
+ - id: answer
38
+ type: text
39
+ - id: reviews
40
+ type: list[text] # Can hold complex types like lists
41
+ ```
42
+
43
+ **Key insight:** Variables are *declared* upfront, making data flow explicit before runtime.
44
+
45
+ **Types matter:** Every variable has a type (primitive like `text`/`int`, domain-specific like `ChatMessage`, or custom types you define).
46
+
47
+ ---
48
+
49
+ ### 2. Steps: The Transformations
50
+
51
+ **Steps are individual operations** that take input variables and produce output variables.
52
+
53
+ ```yaml
54
+ steps:
55
+ - id: format_prompt
56
+ type: PromptTemplate
57
+ template: "Answer this: {question}"
58
+ inputs:
59
+ - question # Consumes the question variable
60
+ outputs:
61
+ - prompt # Produces a prompt variable
62
+ ```
63
+
64
+ **Each step:**
65
+ - Has a specific type (`PromptTemplate`, `LLMInference`, `InvokeTool`, etc.)
66
+ - Declares which variables it reads (`inputs`)
67
+ - Declares which variables it produces (`outputs`)
68
+ - Performs one focused transformation
69
+
70
+ **Key insight:** Steps are pure transformations. Everything is declared, making flows inspectable and debuggable.
71
+
72
+ **Step types are extensible:** QType ships with ~25 step types (LLMs, tools, data processing, RAG operations), and you can write custom tools for domain-specific operations.
73
+
74
+ ---
75
+
76
+ ### 3. Flows: The Orchestration
77
+
78
+ **Flows are sequences of steps** that form complete processing pipelines.
79
+
80
+ ```yaml
81
+ flows:
82
+ - id: answer_question
83
+ inputs:
84
+ - question # What comes in
85
+ outputs:
86
+ - answer # What goes out
87
+ variables: # All data containers
88
+ - id: question
89
+ type: text
90
+ - id: prompt
91
+ type: text
92
+ - id: answer
93
+ type: text
94
+ steps:
95
+ - id: format_prompt
96
+ type: PromptTemplate
97
+ # ... (transforms question → prompt)
98
+ - id: get_answer
99
+ type: LLMInference
100
+ # ... (transforms prompt → answer)
101
+ ```
102
+
103
+ **Flows are data pipelines:**
104
+ - They receive input variables
105
+ - Pass them through a sequence of steps
106
+ - Each step transforms data from one form to another
107
+ - Final outputs are extracted and returned
108
+
109
+ **Key insight:** Flows are *stateless* by default - each execution is independent. Use Memory or external storage for stateful applications (like chatbots). This makes flows easy to reason about, test, and parallelize.
110
+
111
+ ---
112
+
113
+ ## The Data Flow Model
114
+
115
+ Here's how data moves through a QType application:
116
+
117
+ ```
118
+ Input Variables
119
+
120
+ Step 1 (transforms A → B)
121
+
122
+ Step 2 (transforms B → C)
123
+
124
+ Step 3 (transforms C → D)
125
+
126
+ Output Variables
127
+ ```
128
+
129
+ **Linear execution:** Steps run sequentially in declaration order. Each step waits for its inputs to be available. Parallelism is supported for multiple inputs.
130
+
131
+ **1-to-many cardinality:** Some steps (like `Explode`) can produce multiple outputs for one input, creating fan-out patterns. Other steps (like `Collect`) gather many inputs into one collection. This enables batch processing patterns.
132
+
133
+ ---
134
+
135
+ ## Architecture: The Three Layers
136
+
137
+ QType is built in three distinct layers, each with a specific responsibility:
138
+
139
+ ```
140
+ ┌─────────────────────────────────────────────┐
141
+ │ CLI Commands │
142
+ │ (validate, run, serve) │
143
+ ├─────────────────────────────────────────────┤
144
+ │ Interpreter │
145
+ │ (execution engine) │
146
+ ├─────────────────────────────────────────────┤
147
+ │ Semantic │
148
+ │ (linking & validation) │
149
+ ├─────────────────────────────────────────────┤
150
+ │ DSL │
151
+ │ (core data models) │
152
+ └─────────────────────────────────────────────┘
153
+ ```
154
+
155
+ ### Layer 1: DSL (Domain-Specific Language)
156
+
157
+ **Responsibility:** Define the data structures that represent QType specifications.
158
+
159
+ - Pure Pydantic models
160
+ - No business logic, just structure
161
+ - Represents YAML as typed Python objects
162
+ - References are strings (like `model: "gpt-4"`)
163
+
164
+ **Example:** The `Flow` model has `steps: list[Step]`, `variables: list[Variable]`, etc.
165
+
166
+ ---
167
+
168
+ ### Layer 2: Semantic
169
+
170
+ **Responsibility:** Transform DSL objects into resolved, validated representations.
171
+
172
+ **The pipeline:**
173
+
174
+ 1. **Parse** - Load YAML and build DSL objects
175
+ 2. **Link** - Resolve string references to actual objects (`"gpt-4"` → `Model` object)
176
+ 3. **Resolve** - Build semantic IR (intermediate representation) where all IDs become object references
177
+ 4. **Check** - Validate semantic rules (no missing variables, types match, etc.)
178
+
179
+ **Key insight:** This layer catches errors *before* execution. You get fast feedback without running expensive LLM calls.
180
+
181
+ **Symbol table:** During linking, QType builds a map of all components by ID.
182
+
183
+ ---
184
+
185
+ ### Layer 3: Interpreter
186
+
187
+ **Responsibility:** Execute flows by running steps with real resources.
188
+
189
+ - Creates executors for each step type
190
+ - Manages resources (models, indexes, caches)
191
+ - Handles streaming and progress tracking
192
+ - Emits telemetry events
193
+ - Orchestrates async execution
194
+
195
+ **Executor pattern:** Each step type has an executor class (`LLMInferenceExecutor`, `InvokeToolExecutor`, etc.) that knows how to run that specific operation. Executors receive `ExecutorContext` with cross-cutting concerns like auth, telemetry, and progress tracking.
196
+
197
+ **Key insight:** The interpreter layer is optional - you could generate code from semantic IR, compile to a different runtime, or build alternative execution strategies. The DSL and semantic layers are independent of execution.
198
+
199
+ ---
200
+
201
+ ## The Loading Pipeline
202
+
203
+ When you run `qtype validate` or `qtype run`, here's what happens:
204
+
205
+ ```
206
+ YAML File
207
+
208
+ 1. Load (expand env vars, includes)
209
+
210
+ 2. Parse (YAML → DSL models)
211
+
212
+ 3. Link (resolve ID references)
213
+
214
+ 4. Resolve (DSL → Semantic IR)
215
+
216
+ 5. Check (validate semantics)
217
+
218
+ 6. Execute (run the flow)
219
+ ```
220
+ Each stage builds on the previous, and errors are caught as early as possible.
221
+
222
+ ---
223
+
224
+ ## Philosophy: Why QType Exists
225
+
226
+ ### 1. **Code is a Liability**
227
+
228
+ Every line of Python code you write is something you have to maintain, debug, and explain to colleagues. QType shifts complexity from *imperative code* (how to do it) to *declarative specification* (what to do).
229
+
230
+ **Example:** Instead of writing Python to:
231
+ - Initialize an LLM client
232
+ - Format prompts
233
+ - Handle streaming
234
+ - Parse JSON responses
235
+ - Construct typed objects
236
+ - Log telemetry
237
+
238
+ You write YAML that *declares* these operations, and QType handles the implementation.
239
+
240
+ ---
241
+
242
+ ### 2. **Modularity and Composability**
243
+
244
+ QType applications are built from composable pieces:
245
+ - **Flows** can invoke other flows
246
+ - **Tools** are reusable functions
247
+ - **Types** define domain models
248
+ - **Models** and **Memories** are shared resources
249
+
250
+ You can build libraries of flows, tools, and types that work together like Lego blocks.
251
+
252
+ ---
253
+
254
+ ### 3. **Traceability and Observability**
255
+
256
+ Because everything is declared:
257
+ - You can visualize the entire application structure
258
+ - Trace data flow through the system
259
+ - Emit structured telemetry
260
+ - Understand what's happening without reading code
261
+
262
+ Otel Observability is supported by default.
263
+
264
+ QType makes the *implicit* (hidden in code) *explicit* (visible in YAML).
265
+
266
+ ---
267
+
268
+ ### 4. **Rapid Iteration**
269
+
270
+ Changing a QType application is fast:
271
+ - Edit YAML
272
+ - Validate
273
+ - Run
274
+
275
+ No recompiling, no virtual environment issues, no import errors. The feedback loop is seconds, not minutes.
276
+
277
+ ---
278
+
279
+ ## What QType Is NOT
280
+
281
+ ### ❌ Not a Low-Code/No-Code Tool
282
+
283
+ QType is not Flowise, Dify, LangFlow, or similar GUI-based agent builders.
284
+
285
+ **Why not:**
286
+ - **Audience:** QType targets *engineers* who want text-based specifications they can version control, code review, and integrate into CI/CD
287
+ - **Control:** GUI tools trade precision and flexibility for convenience. QType gives you full control via explicit configuration, and can connect to apis or your code.
288
+ - **Complexity ceiling:** GUIs work great for simple flows but become unwieldy for complex applications with dozens of components. YAML scales better for large systems
289
+
290
+ **When to use GUI tools:** If you're non-technical or building simple demo flows, GUI tools are faster. If you're an engineer building prototype systems, QType is more maintainable.
291
+
292
+ ---
293
+
294
+ ### ❌ Not a General Data Engineering Tool
295
+
296
+ **What it is:** QType is not Dagster, Prefect, Airflow, or similar orchestration frameworks.
297
+
298
+ **Why not:**
299
+ - **Focus:** Data engineering tools excel at *data pipelines* (ETL, batch processing, scheduling). QType excels at *AI workflows* (LLM calls, vector search, tool calling, agents)
300
+ - **Features:** Dagster has sophisticated scheduling, retries, dependency management, and data lineage. QType has LLM abstractions, type systems for AI data (ChatMessage, RAGDocument), and streaming support
301
+ - **Overlap:** Both can process data in pipelines, but the primitives are different
302
+
303
+ **When to use data engineering tools:** If your workflow is primarily data transformation, aggregation, and movement without AI components, use Dagster/Airflow. They're better at traditional ETL.
304
+
305
+ **When to use QType:** If your workflow involves LLMs, embeddings, vector search, tool calling, or agents, QType gives you purpose-built primitives. You *could* build these in Dagster, but QType makes it easier.
306
+
307
+ **Can they coexist?** Yes! Use Dagster to orchestrate data pipelines that feed into QType applications, or use QType flows as Dagster ops for AI-specific processing.
308
+
309
+ ---
310
+
311
+ ## When to Use QType
312
+
313
+ ### ✅ Use QType When:
314
+
315
+ **You're prototyping AI applications**
316
+ - Quickly try different LLMs, prompts, and flows
317
+ - Iterate on application structure without Python boilerplate
318
+ - Get validation feedback instantly
319
+
320
+ **You want type-safe AI workflows**
321
+ - Explicit data flow with typed variables
322
+ - Catch errors before runtime
323
+ - Understand what data flows where
324
+
325
+ **You're building modular AI systems**
326
+ - Reusable flows, tools, and types
327
+ - Compose applications from libraries
328
+ - Share components across projects
329
+
330
+ **You value maintainability**
331
+ - YAML specs are easier to review than Python
332
+ - Version control shows exactly what changed
333
+ - Generate documentation automatically
334
+
335
+ **You need observability**
336
+ - Built-in telemetry and tracing
337
+ - Visualize application structure
338
+ - Understand execution patterns
339
+
340
+ ---
341
+
342
+ ### 🤔 Consider Alternatives When:
343
+
344
+ **You need complete Python control**
345
+ - Complex branching logic
346
+ - Dynamic behavior based on runtime conditions
347
+ - Integration with Python-specific libraries
348
+
349
+ **You're building pure data pipelines**
350
+ - No LLM or AI components
351
+ - Traditional ETL operations
352
+ - Dagster/Airflow are better fits
353
+
354
+ **You prefer visual tools**
355
+ - GUI-based development
356
+ - Non-technical users
357
+ - Flowise/Dify are more appropriate
358
+
359
+ **Your workflow is extremely simple**
360
+ - Single LLM call, no orchestration
361
+ - Direct API usage is simpler
362
+ - QType adds unnecessary structure
363
+
@@ -0,0 +1,4 @@
1
+ title: Contributing
2
+ nav:
3
+ - index.md
4
+ - roadmap.md
@@ -0,0 +1,283 @@
1
+ # Contributing
2
+
3
+ Welcome to the QType development guide! This document provides comprehensive instructions for setting up your development environment and contributing to the project.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Prerequisites](#prerequisites)
8
+ - [Development Environment Setup](#development-environment-setup)
9
+ - [Using QType Commands](#using-qtype-commands)
10
+ - [Running Tests](#running-tests)
11
+ - [Code Quality and Standards](#code-quality-and-standards)
12
+ - [Project Structure](#project-structure)
13
+ - [Making Changes](#making-changes)
14
+ - [Next Steps](#next-steps)
15
+
16
+ ## Prerequisites
17
+
18
+ - **Python 3.10 or higher** (this project targets Python 3.10+)
19
+ - **uv** package manager (recommended) or **pip**
20
+ - **Git** for version control
21
+
22
+ ## Development Environment Setup
23
+
24
+ ### 1. Clone the Repository
25
+
26
+ ```bash
27
+ git clone https://github.com/yourusername/qtype.git
28
+ cd qtype
29
+ ```
30
+
31
+ ### 2. Set Up Python Environment
32
+
33
+ We recommend using `uv` for dependency management as it's faster and more reliable:
34
+
35
+ ```bash
36
+ # Install uv if you haven't already
37
+ curl -LsSf https://astral.sh/uv/install.sh | sh
38
+
39
+ # Install all dependencies, development tools, and qtype in editable mode
40
+ uv sync --extra interpreter --extra mcp
41
+ ```
42
+
43
+ This single command installs everything you need, including the `qtype` package in editable mode so changes to the source code are immediately reflected.
44
+
45
+ ## Using QType Commands
46
+
47
+ After installation, activate the virtual environment:
48
+ ```bash
49
+ source ./venv/bin/activate
50
+ ```
51
+
52
+ You may see `(qtype)` on yout terminal if you are in bash
53
+
54
+ After installation, you should be able to run the `qtype` command from anywhere:
55
+
56
+ ```bash
57
+ qtype --help
58
+ ```
59
+
60
+ ## Running the MCP In Dev Mode
61
+
62
+ To start it in `dev` mode with the inspector:
63
+ ```
64
+ mcp dev qtype/mcp/server.py:mcp
65
+ ```
66
+
67
+
68
+ ## Running Tests
69
+
70
+ The project uses pytest for testing with coverage measurement:
71
+
72
+ ```bash
73
+ # Run all tests
74
+ uv run pytest
75
+
76
+ # Run tests with coverage
77
+ uv run pytest --cov=qtype
78
+
79
+ # Run tests with coverage and generate HTML report
80
+ uv run pytest --cov=qtype --cov-report=html
81
+
82
+ # Run tests with verbose output
83
+ uv run pytest -v
84
+
85
+ # Run specific test file
86
+ uv run pytest tests/test_loader_file_inclusion.py
87
+
88
+ # Run specific test class
89
+ uv run pytest tests/test_loader_file_inclusion.py::TestFileIncludeLoader
90
+
91
+ # Run specific test method
92
+ uv run pytest tests/test_loader_file_inclusion.py::TestFileIncludeLoader::test_include_yaml_file
93
+
94
+ # Run tests matching a pattern
95
+ uv run pytest -k "test_include"
96
+
97
+ # Run tests with specific markers
98
+ uv run pytest -m "not network" # Skip network tests
99
+ uv run pytest -m "not slow" # Skip slow tests
100
+
101
+ # Run tests in parallel (if pytest-xdist is installed)
102
+ uv run pytest -n auto
103
+ ```
104
+
105
+ ### Coverage Reports
106
+
107
+ Coverage reports show:
108
+ - Which lines of code are executed during tests
109
+ - Which lines are missing test coverage
110
+ - Overall coverage percentage for each module
111
+ - HTML report with line-by-line coverage highlighting
112
+
113
+ The HTML coverage report (`htmlcov/index.html`) provides the most detailed view, showing exactly which lines need more test coverage.
114
+
115
+ ### Test Markers
116
+
117
+ The project uses pytest markers to categorize tests:
118
+ - `@pytest.mark.slow`: Tests that take longer to run
119
+ - `@pytest.mark.network`: Tests requiring network access
120
+
121
+ Skip specific test categories:
122
+ ```bash
123
+ # Skip slow tests
124
+ uv run pytest -m "not slow"
125
+
126
+ # Skip network tests
127
+ uv run pytest -m "not network"
128
+
129
+ # Run only network tests
130
+ uv run pytest -m "network"
131
+ ```
132
+
133
+ ## Code Quality and Standards
134
+
135
+ This project follows strict Python coding standards:
136
+
137
+ ### Code Style Requirements
138
+
139
+ - **PEP 8** compliance for all Python code
140
+ - **Type hints** for all function signatures and class attributes
141
+ - **Docstrings** for all public functions, classes, and modules
142
+ - **Clear naming** using snake_case for functions/variables, PascalCase for classes
143
+ - **Line length** limit of 79 characters (as per PEP 8)
144
+ - **f-strings** for string interpolation
145
+ - **Explicit over implicit** code style
146
+
147
+ #### Format code automatically:
148
+
149
+ ```bash
150
+ # Format with ruff
151
+ ruff format qtype/ tests/
152
+
153
+ # Lint with ruff
154
+ ruff check qtype/ tests/
155
+
156
+ # Sort imports
157
+ isort qtype/ tests/
158
+
159
+ # Type checking with mypy
160
+ mypy qtype/ tests/
161
+ ```
162
+
163
+ #### Pre-commit hooks (Optional but recommended):
164
+
165
+ ```bash
166
+ uv pip install pre-commit
167
+ pre-commit install
168
+ ```
169
+
170
+ Settings are in `.pre-commit-config.yaml`:
171
+
172
+ ## Project Structure
173
+
174
+ - `qtype/` – Python package for parsing, validating, and interpreting QType specs
175
+ - `examples/` – Example `.qtype.yaml` specs
176
+ - `schema/` – JSON Schema auto-generated from the DSL
177
+ - `docs/` – Documentation
178
+ - `tests/` – Unit and integration tests
179
+
180
+ ## Making Changes
181
+
182
+ ### Development Workflow
183
+
184
+ 1. **Create a feature branch:**
185
+ ```bash
186
+ git checkout -b feature/your-feature-name
187
+ ```
188
+
189
+ 2. **Make your changes** following the coding standards
190
+
191
+ 3. **Write or update tests** for your changes
192
+
193
+ 4. **Run tests** to ensure nothing is broken:
194
+ ```bash
195
+ uv run pytest --cov=qtype
196
+ ```
197
+
198
+ 5. **Check code quality:**
199
+ ```bash
200
+ ruff format qtype/ tests/
201
+ ruff check qtype/ tests/
202
+ isort qtype/ tests/
203
+ mypy qtype/
204
+ ```
205
+
206
+ 6. **Test CLI functionality:**
207
+ ```bash
208
+ # Generate schema
209
+ ptython -m qtype.cli generate-schema -o schema/test.json
210
+
211
+ # Validate example spec
212
+ ptython -m qtype.cli validate examples/hello_world.qtype.yaml
213
+ ```
214
+
215
+ 7. **Update documentation** if needed
216
+
217
+ 8. **Commit your changes:**
218
+ ```bash
219
+ git add .
220
+ git commit -m "feat: add your feature description"
221
+ ```
222
+
223
+ ### How To: Expand The DSL
224
+
225
+ The core of qtype is the DSL specified in [qtype/dsl/model.py](https://github.com/bazaarvoice/qtype/blob/main/qtype/dsl/model.py). All functionality is rooted in the pydantic classes in that file. To expand the dsl with new classes, types, etc., edit this file. If your new class is a subtype (like a Step, etc) you should make sure you update any unions (like `StepType` etc)
226
+
227
+ Once you have it to your liking, you can generate the new schema:
228
+ ```
229
+ qtype generate schema -o schema/qtype.schema.json
230
+ ```
231
+
232
+ You can make vscode validate it with your newly generated schema by adding it to your `settings.json`:
233
+ ```
234
+ "yaml.schemas" : {
235
+ "schema/qtype.schema.json": ["qtype.config.yaml", "*.qtype.yaml"],
236
+ },
237
+ ```
238
+
239
+ The semantic version of [qtype/semantic/model.py](https://github.com/bazaarvoice/qtype/blob/main/qtype/semantic/model.py) can also be automatically generated:
240
+ ```
241
+ qtype generate semantic-model
242
+ ```
243
+
244
+ Next, update [qtype/semantic/checker.py](https://github.com/bazaarvoice/qtype/blob/main/qtype/semantic/checker.py) to enforce any semantic rules for your step.
245
+
246
+ Next, make a canonical example of your new type in the `examples` folder (e.g., `examples/new_type_example.qtype.yaml`) and it can be validated:
247
+ ```
248
+ qtype validate examples/new_type_example.qtype.yaml
249
+ ```
250
+
251
+ The docstrings in the types are used to update the documentation with:
252
+ ```
253
+ qtype generate dsl-docs
254
+ ```
255
+
256
+ Finally, if desired, you can update the interpreter to support your new type. If your new type is a `Step`, you can add an `executor` in the [qtype/interpreter/executors](https://github.com/bazaarvoice/qtype/tree/main/qtype/interpreter/executors) folder and then update the [qtype/interpreter/base/factory.py](https://github.com/bazaarvoice/qtype/blob/main/qtype/interpreter/base/factory.py).
257
+
258
+
259
+ ### Adding New Dependencies
260
+
261
+ When adding new dependencies, use uv to add to `pyproject.toml`:
262
+
263
+ ```bash
264
+ uv add <dependency>
265
+ ```
266
+
267
+ Then update the lock file:
268
+
269
+ ```bash
270
+ uv lock
271
+ ```
272
+
273
+ ## Next Steps
274
+
275
+ After setting up your development environment:
276
+
277
+ 1. Explore the `examples/` directory to understand QType specifications
278
+ 2. Run the existing tests to ensure everything works
279
+ 3. Read the documentation in `docs/`
280
+ 4. Look at open issues for contribution opportunities
281
+ 5. Start with small improvements or bug fixes
282
+
283
+ Happy coding! 🚀