qtype 0.1.10__py3-none-any.whl → 0.1.12__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 (216) hide show
  1. docs/Concepts/mental-model-and-philosophy.md +363 -0
  2. docs/Contributing/index.md +276 -0
  3. docs/Contributing/roadmap.md +81 -0
  4. docs/Decisions/ADR-001-Chat-vs-Completion-Endpoint-Features.md +56 -0
  5. docs/Gallery/dataflow_pipelines.md +80 -0
  6. docs/Gallery/dataflow_pipelines.mermaid +45 -0
  7. docs/Gallery/research_assistant.md +98 -0
  8. docs/Gallery/research_assistant.mermaid +42 -0
  9. docs/Gallery/simple_chatbot.md +36 -0
  10. docs/Gallery/simple_chatbot.mermaid +35 -0
  11. docs/How To/Authentication/configure_aws_authentication.md +60 -0
  12. docs/How To/Authentication/use_api_key_authentication.md +40 -0
  13. docs/How To/Command Line Usage/load_multiple_inputs_from_files.md +62 -0
  14. docs/How To/Command Line Usage/pass_inputs_on_the_cli.md +52 -0
  15. docs/How To/Command Line Usage/serve_with_auto_reload.md +26 -0
  16. docs/How To/Data Processing/adjust_concurrency.md +41 -0
  17. docs/How To/Data Processing/cache_step_results.md +71 -0
  18. docs/How To/Data Processing/decode_json_xml.md +24 -0
  19. docs/How To/Data Processing/explode_collections.md +40 -0
  20. docs/How To/Data Processing/gather_results.md +68 -0
  21. docs/How To/Data Processing/read_data_from_files.md +35 -0
  22. docs/How To/Data Processing/read_sql_databases.md +47 -0
  23. docs/How To/Data Processing/write_data_to_file.md +40 -0
  24. docs/How To/Invoke Models/call_large_language_models.md +51 -0
  25. docs/How To/Invoke Models/create_embeddings.md +49 -0
  26. docs/How To/Invoke Models/reuse_prompts_with_templates.md +39 -0
  27. docs/How To/Language Features/include_qtype_yaml.md +45 -0
  28. docs/How To/Language Features/include_raw_text_from_other_files.md +47 -0
  29. docs/How To/Language Features/reference_entities_by_id.md +51 -0
  30. docs/How To/Language Features/use_environment_variables.md +47 -0
  31. docs/How To/Language Features/use_qtype_mcp.md +59 -0
  32. docs/How To/Observability & Debugging/trace_calls_with_open_telemetry.md +49 -0
  33. docs/How To/Observability & Debugging/validate_qtype_yaml.md +35 -0
  34. docs/How To/Observability & Debugging/visualize_application_architecture.md +61 -0
  35. docs/How To/Observability & Debugging/visualize_example.mermaid +35 -0
  36. docs/How To/Qtype Server/flow_as_ui.png +0 -0
  37. docs/How To/Qtype Server/serve_flows_as_apis.md +40 -0
  38. docs/How To/Qtype Server/serve_flows_as_ui.md +42 -0
  39. docs/How To/Qtype Server/use_conversational_interfaces.md +59 -0
  40. docs/How To/Qtype Server/use_variables_with_ui_hints.md +47 -0
  41. docs/How To/Tools & Integration/bind_tool_inputs_and_outputs.md +48 -0
  42. docs/How To/Tools & Integration/create_tools_from_openapi_specifications.md +89 -0
  43. docs/How To/Tools & Integration/create_tools_from_python_modules.md +90 -0
  44. docs/Reference/cli.md +338 -0
  45. docs/Reference/plugins.md +95 -0
  46. docs/Reference/semantic-validation-rules.md +179 -0
  47. docs/Tutorials/01-first-qtype-application.md +248 -0
  48. docs/Tutorials/02-conversational-chatbot.md +327 -0
  49. docs/Tutorials/03-structured-data.md +481 -0
  50. docs/Tutorials/04-tools-and-function-calling.md +483 -0
  51. docs/Tutorials/example_chat.png +0 -0
  52. docs/Tutorials/index.md +92 -0
  53. docs/components/APIKeyAuthProvider.md +7 -0
  54. docs/components/APITool.md +10 -0
  55. docs/components/AWSAuthProvider.md +13 -0
  56. docs/components/AWSSecretManager.md +5 -0
  57. docs/components/Agent.md +6 -0
  58. docs/components/Aggregate.md +8 -0
  59. docs/components/AggregateStats.md +7 -0
  60. docs/components/Application.md +22 -0
  61. docs/components/AuthorizationProvider.md +6 -0
  62. docs/components/AuthorizationProviderList.md +5 -0
  63. docs/components/BearerTokenAuthProvider.md +6 -0
  64. docs/components/BedrockReranker.md +8 -0
  65. docs/components/ChatContent.md +7 -0
  66. docs/components/ChatMessage.md +6 -0
  67. docs/components/ConstantPath.md +5 -0
  68. docs/components/CustomType.md +7 -0
  69. docs/components/Decoder.md +8 -0
  70. docs/components/DecoderFormat.md +8 -0
  71. docs/components/DocToTextConverter.md +7 -0
  72. docs/components/Document.md +7 -0
  73. docs/components/DocumentEmbedder.md +7 -0
  74. docs/components/DocumentIndex.md +7 -0
  75. docs/components/DocumentSearch.md +7 -0
  76. docs/components/DocumentSource.md +12 -0
  77. docs/components/DocumentSplitter.md +10 -0
  78. docs/components/Echo.md +8 -0
  79. docs/components/Embedding.md +7 -0
  80. docs/components/EmbeddingModel.md +6 -0
  81. docs/components/FieldExtractor.md +20 -0
  82. docs/components/FileSource.md +6 -0
  83. docs/components/FileWriter.md +7 -0
  84. docs/components/Flow.md +14 -0
  85. docs/components/FlowInterface.md +7 -0
  86. docs/components/Index.md +8 -0
  87. docs/components/IndexUpsert.md +6 -0
  88. docs/components/InvokeEmbedding.md +7 -0
  89. docs/components/InvokeFlow.md +8 -0
  90. docs/components/InvokeTool.md +8 -0
  91. docs/components/LLMInference.md +9 -0
  92. docs/components/ListType.md +5 -0
  93. docs/components/Memory.md +8 -0
  94. docs/components/MessageRole.md +14 -0
  95. docs/components/Model.md +10 -0
  96. docs/components/ModelList.md +5 -0
  97. docs/components/OAuth2AuthProvider.md +9 -0
  98. docs/components/PrimitiveTypeEnum.md +21 -0
  99. docs/components/PromptTemplate.md +7 -0
  100. docs/components/PythonFunctionTool.md +7 -0
  101. docs/components/RAGChunk.md +7 -0
  102. docs/components/RAGDocument.md +10 -0
  103. docs/components/RAGSearchResult.md +8 -0
  104. docs/components/Reranker.md +5 -0
  105. docs/components/SQLSource.md +8 -0
  106. docs/components/Search.md +7 -0
  107. docs/components/SearchResult.md +7 -0
  108. docs/components/SecretManager.md +7 -0
  109. docs/components/SecretReference.md +7 -0
  110. docs/components/Source.md +6 -0
  111. docs/components/Step.md +9 -0
  112. docs/components/TelemetrySink.md +9 -0
  113. docs/components/Tool.md +9 -0
  114. docs/components/ToolList.md +5 -0
  115. docs/components/ToolParameter.md +6 -0
  116. docs/components/TypeList.md +5 -0
  117. docs/components/Variable.md +6 -0
  118. docs/components/VariableList.md +5 -0
  119. docs/components/VectorIndex.md +7 -0
  120. docs/components/VectorSearch.md +6 -0
  121. docs/components/VertexAuthProvider.md +9 -0
  122. docs/components/Writer.md +5 -0
  123. docs/example_ui.png +0 -0
  124. docs/index.md +81 -0
  125. docs/legacy_how_tos/Configuration/modular-yaml.md +366 -0
  126. docs/legacy_how_tos/Configuration/phoenix_projects.png +0 -0
  127. docs/legacy_how_tos/Configuration/phoenix_traces.png +0 -0
  128. docs/legacy_how_tos/Configuration/reference-by-id.md +251 -0
  129. docs/legacy_how_tos/Configuration/telemetry-setup.md +259 -0
  130. docs/legacy_how_tos/Data Types/custom-types.md +52 -0
  131. docs/legacy_how_tos/Data Types/domain-types.md +113 -0
  132. docs/legacy_how_tos/Debugging/visualize-apps.md +147 -0
  133. docs/legacy_how_tos/Tools/api-tools.md +29 -0
  134. docs/legacy_how_tos/Tools/python-tools.md +299 -0
  135. examples/authentication/aws_authentication.qtype.yaml +63 -0
  136. examples/conversational_ai/hello_world_chat.qtype.yaml +43 -0
  137. examples/conversational_ai/simple_chatbot.qtype.yaml +40 -0
  138. examples/data_processing/batch_processing.qtype.yaml +54 -0
  139. examples/data_processing/cache_step_results.qtype.yaml +78 -0
  140. examples/data_processing/collect_results.qtype.yaml +55 -0
  141. examples/data_processing/dataflow_pipelines.qtype.yaml +108 -0
  142. examples/data_processing/decode_json.qtype.yaml +23 -0
  143. examples/data_processing/explode_items.qtype.yaml +25 -0
  144. examples/data_processing/read_file.qtype.yaml +60 -0
  145. examples/invoke_models/create_embeddings.qtype.yaml +28 -0
  146. examples/invoke_models/simple_llm_call.qtype.yaml +32 -0
  147. examples/language_features/include_raw.qtype.yaml +27 -0
  148. examples/language_features/ui_hints.qtype.yaml +52 -0
  149. examples/legacy/bedrock/data_analysis_with_telemetry.qtype.yaml +169 -0
  150. examples/legacy/bedrock/hello_world.qtype.yaml +39 -0
  151. examples/legacy/bedrock/hello_world_chat.qtype.yaml +37 -0
  152. examples/legacy/bedrock/hello_world_chat_with_telemetry.qtype.yaml +40 -0
  153. examples/legacy/bedrock/hello_world_chat_with_thinking.qtype.yaml +40 -0
  154. examples/legacy/bedrock/hello_world_completion.qtype.yaml +41 -0
  155. examples/legacy/bedrock/hello_world_completion_with_auth.qtype.yaml +44 -0
  156. examples/legacy/bedrock/simple_agent_chat.qtype.yaml +46 -0
  157. examples/legacy/chat_with_langfuse.qtype.yaml +50 -0
  158. examples/legacy/data_processor.qtype.yaml +48 -0
  159. examples/legacy/echo/debug_example.qtype.yaml +59 -0
  160. examples/legacy/echo/prompt.qtype.yaml +22 -0
  161. examples/legacy/echo/test.qtype.yaml +26 -0
  162. examples/legacy/echo/video.qtype.yaml +20 -0
  163. examples/legacy/field_extractor_example.qtype.yaml +137 -0
  164. examples/legacy/multi_flow_example.qtype.yaml +125 -0
  165. examples/legacy/openai/hello_world_chat.qtype.yaml +43 -0
  166. examples/legacy/openai/hello_world_chat_with_telemetry.qtype.yaml +46 -0
  167. examples/legacy/rag.qtype.yaml +207 -0
  168. examples/legacy/time_utilities.qtype.yaml +64 -0
  169. examples/legacy/vertex/hello_world_chat.qtype.yaml +36 -0
  170. examples/legacy/vertex/hello_world_completion.qtype.yaml +40 -0
  171. examples/legacy/vertex/hello_world_completion_with_auth.qtype.yaml +45 -0
  172. examples/observability_debugging/trace_with_opentelemetry.qtype.yaml +40 -0
  173. examples/research_assistant/research_assistant.qtype.yaml +94 -0
  174. examples/research_assistant/tavily.oas.yaml +722 -0
  175. examples/research_assistant/tavily.qtype.yaml +289 -0
  176. examples/tutorials/01_hello_world.qtype.yaml +48 -0
  177. examples/tutorials/02_conversational_chat.qtype.yaml +37 -0
  178. examples/tutorials/03_structured_data.qtype.yaml +130 -0
  179. examples/tutorials/04_tools_and_function_calling.qtype.yaml +89 -0
  180. qtype/application/converters/tools_from_api.py +39 -35
  181. qtype/base/types.py +6 -1
  182. qtype/commands/convert.py +3 -6
  183. qtype/commands/generate.py +7 -3
  184. qtype/commands/mcp.py +68 -0
  185. qtype/commands/validate.py +4 -4
  186. qtype/dsl/custom_types.py +2 -1
  187. qtype/dsl/linker.py +15 -7
  188. qtype/dsl/loader.py +3 -3
  189. qtype/dsl/model.py +24 -3
  190. qtype/interpreter/api.py +4 -1
  191. qtype/interpreter/base/base_step_executor.py +3 -1
  192. qtype/interpreter/conversions.py +7 -3
  193. qtype/interpreter/executors/construct_executor.py +1 -1
  194. qtype/interpreter/executors/document_splitter_executor.py +4 -1
  195. qtype/interpreter/executors/file_source_executor.py +3 -3
  196. qtype/interpreter/executors/file_writer_executor.py +4 -4
  197. qtype/interpreter/executors/index_upsert_executor.py +1 -1
  198. qtype/interpreter/executors/sql_source_executor.py +1 -1
  199. qtype/interpreter/resource_cache.py +3 -1
  200. qtype/interpreter/rich_progress.py +6 -3
  201. qtype/interpreter/stream/chat/converter.py +25 -17
  202. qtype/interpreter/stream/chat/ui_request_to_domain_type.py +2 -2
  203. qtype/interpreter/typing.py +5 -7
  204. qtype/mcp/__init__.py +0 -0
  205. qtype/mcp/server.py +467 -0
  206. qtype/semantic/checker.py +1 -1
  207. qtype/semantic/generate.py +3 -3
  208. qtype/semantic/visualize.py +38 -51
  209. {qtype-0.1.10.dist-info → qtype-0.1.12.dist-info}/METADATA +21 -1
  210. qtype-0.1.12.dist-info/RECORD +325 -0
  211. {qtype-0.1.10.dist-info → qtype-0.1.12.dist-info}/WHEEL +1 -1
  212. schema/qtype.schema.json +4018 -0
  213. qtype-0.1.10.dist-info/RECORD +0 -142
  214. {qtype-0.1.10.dist-info → qtype-0.1.12.dist-info}/entry_points.txt +0 -0
  215. {qtype-0.1.10.dist-info → qtype-0.1.12.dist-info}/licenses/LICENSE +0 -0
  216. {qtype-0.1.10.dist-info → qtype-0.1.12.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,90 @@
1
+ # Create Tools from Python Modules
2
+
3
+ Generate QType tool definitions automatically from Python functions using `qtype convert module`, which analyzes type hints and docstrings to create properly typed tools.
4
+
5
+ ### Command
6
+
7
+ ```bash
8
+ qtype convert module myapp.utils --output tools.qtype.yaml
9
+ ```
10
+
11
+ ### QType YAML
12
+
13
+ **Input Python module** (`myapp/utils.py`):
14
+ ```python
15
+ from datetime import datetime
16
+
17
+ def calculate_age(birth_date: datetime, reference_date: datetime) -> int:
18
+ """Calculate age in years between two dates.
19
+
20
+ Args:
21
+ birth_date: The birth date
22
+ reference_date: The date to calculate age at
23
+
24
+ Returns:
25
+ Age in complete years
26
+ """
27
+ age = reference_date.year - birth_date.year
28
+ if (reference_date.month, reference_date.day) < (birth_date.month, birth_date.day):
29
+ age -= 1
30
+ return age
31
+ ```
32
+
33
+ **Generated tool YAML** (`tools.qtype.yaml`):
34
+ ```yaml
35
+ id: myapp.utils
36
+ description: Tools created from Python module myapp.utils
37
+ tools:
38
+ - id: myapp.utils.calculate_age
39
+ description: Calculate age in years between two dates.
40
+ type: PythonFunctionTool
41
+ function_name: calculate_age
42
+ module_path: myapp.utils
43
+ name: calculate_age
44
+ inputs:
45
+ birth_date:
46
+ type: datetime
47
+ optional: false
48
+ reference_date:
49
+ type: datetime
50
+ optional: false
51
+ outputs:
52
+ result:
53
+ type: int
54
+ optional: false
55
+ ```
56
+
57
+ ### Explanation
58
+
59
+ - **`convert module`**: CLI subcommand that converts Python modules to tool definitions
60
+ - **module path**: Dot-separated Python module (e.g., `myapp.utils`, `package.submodule`) - must be importable
61
+ - **`--output`**: Target YAML file path; omit to print to stdout
62
+ - **Type hints**: Required on all parameters and return values; converted to QType types (int, text, datetime, etc.)
63
+ - **Optional parameters**: Detected from default values (e.g., `name: str = "default"` becomes `optional: true`)
64
+ - **Docstrings**: First line becomes tool description; supports Google, NumPy, and reStructuredText formats
65
+ - **Public functions only**: Functions starting with `_` are skipped
66
+
67
+ ### Using Generated Tools
68
+
69
+ ```yaml
70
+ references:
71
+ - !include tools.qtype.yaml
72
+
73
+ flows:
74
+ - id: check_age
75
+ steps:
76
+ - type: InvokeTool
77
+ id: calc
78
+ tool: myapp.utils.calculate_age
79
+ input_bindings:
80
+ birth_date: dob
81
+ reference_date: today
82
+ output_bindings:
83
+ result: age
84
+ ```
85
+
86
+ ## See Also
87
+
88
+ - [Tutorial: Adding Tools to Your Application](../../Tutorials/04-tools-and-function-calling.md)
89
+ - [InvokeTool Reference](../../components/InvokeTool.md)
90
+ - [PythonFunctionTool Reference](../../components/PythonFunctionTool.md)
docs/Reference/cli.md ADDED
@@ -0,0 +1,338 @@
1
+ # Command Line Interface
2
+
3
+ The QType CLI lets you run applications, validate specifications, serve web interfaces, and generating resources.
4
+
5
+ ## Installation
6
+
7
+ The QType CLI is installed with the qtype package. Run commands with:
8
+
9
+ ```bash
10
+ qtype [command] [options]
11
+ ```
12
+
13
+ ## Global Options
14
+
15
+ ```
16
+ --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
17
+ Set the logging level (default: INFO)
18
+ ```
19
+
20
+ ## Commands
21
+
22
+ ### run
23
+
24
+ Execute a QType application locally.
25
+
26
+ ```bash
27
+ qtype run [options] spec
28
+ ```
29
+
30
+ #### Arguments
31
+
32
+ - **`spec`** - Path to the QType YAML spec file
33
+
34
+ #### Options
35
+
36
+ - **`-f FLOW, --flow FLOW`** - The name of the flow to run. If not specified, runs the first flow found
37
+ - **`-i INPUT, --input INPUT`** - JSON blob of input values for the flow (default: `{}`)
38
+ - **`-I INPUT_FILE, --input-file INPUT_FILE`** - Path to a file (e.g., CSV, JSON, Parquet) with input data for batch processing
39
+ - **`-o OUTPUT, --output OUTPUT`** - Path to save output data. If input is a DataFrame, output will be saved as parquet. If single result, saved as JSON
40
+ - **`--progress`** - Show progress bars during flow execution
41
+
42
+ #### Examples
43
+
44
+ Run a simple application:
45
+ ```bash
46
+ qtype run app.qtype.yaml
47
+ ```
48
+
49
+ Run with inline JSON inputs:
50
+ ```bash
51
+ qtype run app.qtype.yaml -i '{"question": "What is AI?"}'
52
+ ```
53
+
54
+ Run a specific flow:
55
+ ```bash
56
+ qtype run app.qtype.yaml --flow process_data
57
+ ```
58
+
59
+ Batch process data from a file:
60
+ ```bash
61
+ qtype run app.qtype.yaml --input-file inputs.csv --output results.parquet
62
+ ```
63
+
64
+ #### See Also
65
+
66
+ - [How To: Pass Inputs On The CLI](../How%20To/Command%20Line%20Usage/pass_inputs_on_the_cli.md)
67
+ - [How To: Load Multiple Inputs from Files](../How%20To/Command%20Line%20Usage/load_multiple_inputs_from_files.md)
68
+ - [Tutorial: Your First QType Application](../Tutorials/01-first-qtype-application.md)
69
+
70
+ ---
71
+
72
+ ### validate
73
+
74
+ Validate a QType YAML spec against the schema and semantic rules.
75
+
76
+ ```bash
77
+ qtype validate [options] spec
78
+ ```
79
+
80
+ #### Arguments
81
+
82
+ - **`spec`** - Path to the QType YAML spec file
83
+
84
+ #### Options
85
+
86
+ - **`-p, --print`** - Print the spec after validation (default: False)
87
+
88
+ #### Examples
89
+
90
+ Validate a specification:
91
+ ```bash
92
+ qtype validate app.qtype.yaml
93
+ ```
94
+
95
+ Validate and print the parsed spec:
96
+ ```bash
97
+ qtype validate app.qtype.yaml --print
98
+ ```
99
+
100
+ #### See Also
101
+
102
+ - [How To: Validate QType YAML](../How%20To/Observability%20&%20Debugging/validate_qtype_yaml.md)
103
+ - [Reference: Semantic Validation Rules](semantic-validation-rules.md)
104
+
105
+ ---
106
+
107
+ ### serve
108
+
109
+ Serve a web experience for a QType application with an interactive UI.
110
+
111
+ ```bash
112
+ qtype serve [options] spec
113
+ ```
114
+
115
+ #### Arguments
116
+
117
+ - **`spec`** - Path to the QType YAML spec file
118
+
119
+ #### Options
120
+
121
+ - **`-p PORT, --port PORT`** - Port to run the server on (default: 8080)
122
+ - **`-H HOST, --host HOST`** - Host to bind the server to (default: 0.0.0.0)
123
+ - **`--reload`** - Enable auto-reload on code changes (default: False)
124
+
125
+ #### Examples
126
+
127
+ Serve an application:
128
+ ```bash
129
+ qtype serve app.qtype.yaml
130
+ ```
131
+
132
+ Serve on a specific port:
133
+ ```bash
134
+ qtype serve app.qtype.yaml --port 3000
135
+ ```
136
+
137
+ Serve with auto-reload for development:
138
+ ```bash
139
+ qtype serve app.qtype.yaml --reload
140
+ ```
141
+
142
+ #### See Also
143
+
144
+ - [How To: Serve Flows as APIs](../How%20To/Qtype%20Server/serve_flows_as_apis.md)
145
+ - [How To: Serve Flows as UI](../How%20To/Qtype%20Server/serve_flows_as_ui.md)
146
+ - [How To: Use Conversational Interfaces](../How%20To/Qtype%20Server/use_conversational_interfaces.md)
147
+ - [How To: Serve Applications with Auto-Reload](../How%20To/Qtype%20Server/serve_applications_with_auto_reload.md)
148
+ - [Tutorial: Building a Stateful Chatbot](../Tutorials/02-conversational-chatbot.md)
149
+
150
+ ---
151
+
152
+ ### mcp
153
+
154
+ Start the QType Model Context Protocol (MCP) server for AI agent integration.
155
+
156
+ ```bash
157
+ qtype mcp [options]
158
+ ```
159
+
160
+ #### Options
161
+
162
+ - **`-t TRANSPORT, --transport TRANSPORT`** - Transport protocol to use: `stdio`, `sse`, or `streamable-http` (default: stdio)
163
+ - **`--host HOST`** - Host to bind to for HTTP/SSE transports (default: 0.0.0.0)
164
+ - **`-p PORT, --port PORT`** - Port to bind to for HTTP/SSE transports (default: 8000)
165
+
166
+ #### Examples
167
+
168
+ Start MCP server with stdio transport (default, for local AI agents):
169
+ ```bash
170
+ qtype mcp
171
+ ```
172
+
173
+ Start with Server-Sent Events transport:
174
+ ```bash
175
+ qtype mcp --transport sse --port 8000
176
+ ```
177
+
178
+ Start with streamable HTTP transport on a specific host and port:
179
+ ```bash
180
+ qtype mcp --transport streamable-http --host 127.0.0.1 --port 3000
181
+ ```
182
+
183
+ #### Description
184
+
185
+ The MCP server exposes QType functionality to AI agents and assistants through the Model Context Protocol. It provides tools for:
186
+
187
+ - Converting API specifications to QType tools
188
+ - Converting Python modules to QType tools
189
+ - Validating QType YAML specifications
190
+ - Visualizing QType architectures
191
+ - Accessing QType documentation and component schemas
192
+
193
+ The stdio transport is ideal for local AI agent integration, while SSE and streamable-http transports are suitable for network-based integrations.
194
+
195
+ ---
196
+
197
+ ### visualize
198
+
199
+ Generate a visual diagram of your QType application architecture.
200
+
201
+ ```bash
202
+ qtype visualize [options] spec
203
+ ```
204
+
205
+ #### Arguments
206
+
207
+ - **`spec`** - Path to the QType YAML file
208
+
209
+ #### Options
210
+
211
+ - **`-o OUTPUT, --output OUTPUT`** - If provided, write the mermaid diagram to this file
212
+ - **`-nd, --no-display`** - If set, don't display the diagram in a browser (default: False)
213
+
214
+ #### Examples
215
+
216
+ Visualize and open in browser:
217
+ ```bash
218
+ qtype visualize app.qtype.yaml
219
+ ```
220
+
221
+ Save to file without displaying:
222
+ ```bash
223
+ qtype visualize app.qtype.yaml --output diagram.mmd --no-display
224
+ ```
225
+
226
+ Generate and save diagram:
227
+ ```bash
228
+ qtype visualize app.qtype.yaml --output architecture.mmd
229
+ ```
230
+
231
+ #### See Also
232
+
233
+ - [How To: Visualize Application Architecture](../How%20To/Observability%20&%20Debugging/visualize_application_architecture.md)
234
+
235
+ ---
236
+
237
+ ### convert
238
+
239
+ Create QType tool definitions from external sources.
240
+
241
+ ```bash
242
+ qtype convert {module,api} [options]
243
+ ```
244
+
245
+ #### Subcommands
246
+
247
+ ##### convert module
248
+
249
+ Convert a Python module to QType tools format.
250
+
251
+ ```bash
252
+ qtype convert module [options] module_path
253
+ ```
254
+
255
+ **Arguments:**
256
+
257
+ - **`module_path`** - Path to the Python module to convert
258
+
259
+ **Options:**
260
+
261
+ - **`-o OUTPUT, --output OUTPUT`** - Output file path. If not specified, prints to stdout
262
+
263
+ **Examples:**
264
+
265
+ Convert a Python module:
266
+ ```bash
267
+ qtype convert module myapp.utils --output tools.qtype.yaml
268
+ ```
269
+
270
+ Print to stdout:
271
+ ```bash
272
+ qtype convert module myapp.utils
273
+ ```
274
+
275
+ **See Also:**
276
+
277
+ - [How To: Create Tools from Python Modules](../How%20To/Tools%20&%20Integration/create_tools_from_python_modules.md)
278
+ - [Tutorial: Adding Tools to Your Application](../Tutorials/04-tools-and-function-calling.md)
279
+
280
+ ##### convert api
281
+
282
+ Convert an OpenAPI/Swagger specification to QType format.
283
+
284
+ ```bash
285
+ qtype convert api [options] api_spec
286
+ ```
287
+
288
+ **Arguments:**
289
+
290
+ - **`api_spec`** - Path to the API specification file (supports local files or URLs)
291
+
292
+ **Options:**
293
+
294
+ - **`-o OUTPUT, --output OUTPUT`** - Output file path. If not specified, prints to stdout
295
+
296
+ **Examples:**
297
+
298
+ Convert an OpenAPI spec:
299
+ ```bash
300
+ qtype convert api spec.oas.yaml --output api_tools.qtype.yaml
301
+ ```
302
+
303
+ Convert from a URL:
304
+ ```bash
305
+ qtype convert api https://petstore3.swagger.io/api/v3/openapi.json --output petstore.qtype.yaml
306
+ ```
307
+
308
+ **See Also:**
309
+
310
+ - [How To: Create Tools from OpenAPI Specifications](../How%20To/Tools%20&%20Integration/create_tools_from_openapi_specifications.md)
311
+ - [Tutorial: Adding Tools to Your Application](../Tutorials/04-tools-and-function-calling.md)
312
+
313
+ ---
314
+
315
+ ### generate
316
+
317
+ Generate QType project resources (primarily for internal development).
318
+
319
+ ```bash
320
+ qtype generate {commons,schema,dsl-docs,semantic-model} [options]
321
+ ```
322
+
323
+ This command is primarily used for QType development and maintenance.
324
+
325
+ #### Subcommands
326
+
327
+ - **`commons`** - Generates the commons library tools from `tools.py`
328
+ - **`schema`** - Generates the JSON schema for the QType DSL from `model.py`
329
+ - **`dsl-docs`** - Generates markdown documentation for the QType DSL classes from `model.py`
330
+ - **`semantic-model`** - Generates the semantic model from QType DSL (See [Contributing](../Contributing/))
331
+
332
+ ---
333
+
334
+ ## Exit Codes
335
+
336
+ - **0** - Success
337
+ - **1** - Error (validation failure, runtime error, etc.)
338
+
@@ -0,0 +1,95 @@
1
+ # Extending QType CLI
2
+
3
+ QType supports third-party CLI plugins through Python entry points. This allows developers to extend the QType CLI with custom commands without modifying the core codebase.
4
+
5
+ ## Creating a Plugin
6
+
7
+ ### 1. Define Your Command Function
8
+
9
+ Create a module with a parser function that takes a subparsers object and registers your command:
10
+
11
+ ```python
12
+ # my_package/qtype_commands.py
13
+ import argparse
14
+
15
+ def my_command_parser(subparsers: argparse._SubParsersAction) -> None:
16
+ """Register the 'my-command' subcommand."""
17
+ parser = subparsers.add_parser(
18
+ 'my-command',
19
+ help='My custom QType command'
20
+ )
21
+ parser.add_argument(
22
+ '--option',
23
+ help='An example option'
24
+ )
25
+ # Set the function to call when this command is invoked
26
+ parser.set_defaults(func=my_command_handler)
27
+
28
+ def my_command_handler(args: argparse.Namespace) -> None:
29
+ """Handle the 'my-command' subcommand."""
30
+ print(f"Running my-command with option: {args.option}")
31
+ ```
32
+
33
+ ### 2. Register the Entry Point
34
+
35
+ Add the entry point to your package's `pyproject.toml`:
36
+
37
+ ```toml
38
+ [project.entry-points."qtype.commands"]
39
+ my-command = "my_package.qtype_commands:my_command_parser"
40
+ ```
41
+
42
+ Or if using `setup.py`:
43
+
44
+ ```python
45
+ from setuptools import setup
46
+
47
+ setup(
48
+ name="my-qtype-plugin",
49
+ # ... other setup parameters
50
+ entry_points={
51
+ "qtype.commands": [
52
+ "my-command = my_package.qtype_commands:my_command_parser",
53
+ ],
54
+ },
55
+ )
56
+ ```
57
+
58
+ ### 3. Install and Test
59
+
60
+ After installing your package, the command will be automatically available:
61
+
62
+ ```bash
63
+ pip install my-qtype-plugin
64
+ qtype my-command --option "test"
65
+ ```
66
+
67
+ ## Best Practices
68
+
69
+ 1. **Naming**: Use descriptive command names and avoid conflicts with built-in commands
70
+ 2. **Error Handling**: Handle errors gracefully and provide helpful error messages
71
+ 3. **Documentation**: Include help text for your commands and arguments
72
+ 4. **Dependencies**: Declare any additional dependencies your plugin requires
73
+ 5. **Testing**: Test your plugin with different versions of QType
74
+
75
+ ## Debugging Plugins
76
+
77
+ To see debug information about plugin loading, run QType with debug logging:
78
+
79
+ ```bash
80
+ qtype --log-level DEBUG my-command
81
+ ```
82
+
83
+ This will show which plugins are being loaded and any errors that occur during the loading process.
84
+
85
+ ## Example Plugin Structure
86
+
87
+ ```
88
+ my-qtype-plugin/
89
+ ├── pyproject.toml
90
+ ├── my_package/
91
+ │ ├── __init__.py
92
+ │ └── qtype_commands.py
93
+ └── tests/
94
+ └── test_plugin.py
95
+ ```
@@ -0,0 +1,179 @@
1
+ # Semantic Validation Rules
2
+
3
+ Semantic validation happens after loading your yaml. You should expect to see these even if the yaml is validated by the spec.
4
+
5
+ You can validate any qtype file with:
6
+ ```
7
+ qtype validate you_file.qtype.yaml
8
+ ```
9
+
10
+ This document lists all semantic validation rules enforced by QType. These rules are checked after YAML parsing and reference resolution.
11
+
12
+ ---
13
+
14
+ ## Agent
15
+
16
+ - Must have exactly 1 input
17
+ - Must have exactly 1 output
18
+ - Input must be type `text` or `ChatMessage`
19
+ - Output type must match input type
20
+
21
+ ---
22
+
23
+ ## Application
24
+
25
+ - If using `SecretReference`, must configure `secret_manager`
26
+ - For `AWSSecretManager`, auth must be `AWSAuthProvider`
27
+
28
+ ---
29
+
30
+ ## AWSAuthProvider
31
+
32
+ - Must specify at least one authentication method:
33
+ - Access keys (`access_key_id` + `secret_access_key`)
34
+ - Profile name (`profile_name`)
35
+ - Role ARN (`role_arn`)
36
+ - If assuming a role, must provide base credentials (access keys or profile)
37
+
38
+ ---
39
+
40
+ ## BedrockReranker
41
+
42
+ - Must have exactly 2 inputs
43
+ - One input must be type `text` (query)
44
+ - One input must be type `list[SearchResult]` (results to rerank)
45
+ - Must have exactly 1 output of type `list[SearchResult]`
46
+
47
+ ---
48
+
49
+ ## Collect
50
+
51
+ - Must have exactly 1 input -- any type `T`
52
+ - Must have exactly 1 output of type `list[T]`
53
+ - Output list element type must match input type
54
+
55
+ ---
56
+
57
+ ## Construct
58
+
59
+ - Must have at least 1 input
60
+ - Must have exactly 1 output
61
+ - Output type must be a Pydantic BaseModel (Custom type or Domain type)
62
+
63
+ ---
64
+
65
+ ## Decoder
66
+
67
+ - Must have exactly 1 input of type `text`
68
+ - Must have at least 1 output
69
+
70
+ ---
71
+
72
+ ## DocToTextConverter
73
+
74
+ - Must have exactly 1 input of type `RAGDocument`
75
+ - Must have exactly 1 output of type `RAGDocument`
76
+
77
+ ---
78
+
79
+ ## DocumentEmbedder
80
+
81
+ - Must have exactly 1 input of type `RAGChunk`
82
+ - Must have exactly 1 output of type `RAGChunk`
83
+
84
+ ---
85
+
86
+ ## DocumentSearch
87
+
88
+ - Must have exactly 1 input of type `text`
89
+ - Must have exactly 1 output of type `list[SearchResult]`
90
+
91
+ ---
92
+
93
+ ## DocumentSource
94
+
95
+ - Must have exactly 1 output of type `RAGDocument`
96
+
97
+ ---
98
+
99
+ ## DocumentSplitter
100
+
101
+ - Must have exactly 1 input of type `RAGDocument`
102
+ - Must have exactly 1 output of type `RAGChunk`
103
+
104
+ ---
105
+
106
+ ## Echo
107
+
108
+ - Input and output variable IDs must match (order can differ)
109
+
110
+ ---
111
+
112
+ ## Explode
113
+
114
+ - Must have exactly 1 input of type `list[T]`
115
+ - Must have exactly 1 output of type `T`
116
+ - Output type must match input list element type
117
+
118
+ ---
119
+
120
+ ## FieldExtractor
121
+
122
+ - Must have exactly 1 input
123
+ - Must have exactly 1 output
124
+ - `json_path` must be non-empty
125
+
126
+ ---
127
+
128
+ ## Flow
129
+
130
+ **General:**
131
+ - Must have at least 1 step
132
+ - All step inputs must be fulfilled by flow inputs or previous step outputs
133
+
134
+ **Conversational Interface:**
135
+ - Must have exactly 1 `ChatMessage` input
136
+ - All non-ChatMessage inputs must be listed in `session_inputs`
137
+ - Must have exactly 1 `ChatMessage` output
138
+
139
+ **Complete Interface:**
140
+ - Must have exactly 1 input of type `text`
141
+ - Must have exactly 1 output of type `text`
142
+
143
+ ---
144
+
145
+ ## IndexUpsert
146
+
147
+ **For Vector Index:**
148
+ - Must have exactly 1 input
149
+ - Input must be type `RAGChunk` or `RAGDocument`
150
+
151
+ **For Document Index:**
152
+ - Must have at least 1 input
153
+
154
+ ---
155
+
156
+ ## LLMInference
157
+
158
+ - Must have exactly 1 output
159
+ - Output must be type `text` or `ChatMessage`
160
+
161
+ ---
162
+
163
+ ## PromptTemplate
164
+
165
+ - Must have exactly 1 output
166
+ - Output must be type `text`
167
+
168
+ ---
169
+
170
+ ## SQLSource
171
+
172
+ - Must have at least 1 output
173
+
174
+ ---
175
+
176
+ ## VectorSearch
177
+
178
+ - Must have exactly 1 input of type `text`
179
+ - Must have exactly 1 output of type `list[RAGSearchResult]`