qtype 0.1.11__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 (215) 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/file_source_executor.py +3 -3
  195. qtype/interpreter/executors/file_writer_executor.py +4 -4
  196. qtype/interpreter/executors/index_upsert_executor.py +1 -1
  197. qtype/interpreter/executors/sql_source_executor.py +1 -1
  198. qtype/interpreter/resource_cache.py +3 -1
  199. qtype/interpreter/rich_progress.py +6 -3
  200. qtype/interpreter/stream/chat/converter.py +25 -17
  201. qtype/interpreter/stream/chat/ui_request_to_domain_type.py +2 -2
  202. qtype/interpreter/typing.py +5 -7
  203. qtype/mcp/__init__.py +0 -0
  204. qtype/mcp/server.py +467 -0
  205. qtype/semantic/checker.py +1 -1
  206. qtype/semantic/generate.py +3 -3
  207. qtype/semantic/visualize.py +38 -51
  208. {qtype-0.1.11.dist-info → qtype-0.1.12.dist-info}/METADATA +21 -1
  209. qtype-0.1.12.dist-info/RECORD +325 -0
  210. {qtype-0.1.11.dist-info → qtype-0.1.12.dist-info}/WHEEL +1 -1
  211. schema/qtype.schema.json +4018 -0
  212. qtype-0.1.11.dist-info/RECORD +0 -142
  213. {qtype-0.1.11.dist-info → qtype-0.1.12.dist-info}/entry_points.txt +0 -0
  214. {qtype-0.1.11.dist-info → qtype-0.1.12.dist-info}/licenses/LICENSE +0 -0
  215. {qtype-0.1.11.dist-info → qtype-0.1.12.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,51 @@
1
+ # Reference Entities by ID
2
+
3
+ Use QType's "define once, reference by ID" pattern to eliminate duplication and improve maintainability by assigning unique IDs to components and referencing them throughout your application.
4
+
5
+ ### QType YAML
6
+
7
+ ```yaml
8
+ # Define components with unique IDs
9
+ auths:
10
+ - type: api_key
11
+ id: openai_auth
12
+ api_key: ${OPENAI_KEY}
13
+
14
+ models:
15
+ - type: Model
16
+ id: gpt4
17
+ provider: openai
18
+ model_id: gpt-4o
19
+ auth: openai_auth # Reference auth by ID
20
+
21
+ memories:
22
+ - id: conversation_memory
23
+ token_limit: 10000
24
+
25
+ flows:
26
+ - type: Flow
27
+ id: chat_flow
28
+ steps:
29
+ - type: LLMInference
30
+ model: gpt4 # Reference model by ID
31
+ memory: conversation_memory # Reference memory by ID
32
+ ```
33
+
34
+ ### Explanation
35
+
36
+ - **`id` field**: Assigns a unique identifier to any component (models, auths, tools, variables, etc.)
37
+ - **Reference by string**: Use the ID string wherever the component is needed
38
+ - **Automatic resolution**: QType's linker automatically resolves ID references to actual objects during validation
39
+ - **Reusability**: The same component can be referenced multiple times throughout the application
40
+
41
+ ## Complete Example
42
+
43
+ ```yaml
44
+ !include ../../examples/conversational_ai/simple_chatbot.qtype.yaml
45
+ ```
46
+
47
+ ## See Also
48
+
49
+ - [Tutorial: Your First QType Application](../../Tutorials/01-first-qtype-application.md)
50
+ - [Model Reference](../../components/Model.md)
51
+ - [APIKeyAuthProvider Reference](../../components/APIKeyAuthProvider.md)
@@ -0,0 +1,47 @@
1
+ # Use Environment Variables
2
+
3
+ Keep sensitive credentials and environment-specific configuration out of your YAML files by using environment variable substitution with `${VAR_NAME}` syntax.
4
+
5
+ ### QType YAML
6
+
7
+ ```yaml
8
+ auths:
9
+ - type: api_key
10
+ id: openai_auth
11
+ api_key: ${OPENAI_KEY} # Required variable
12
+ host: https://api.openai.com
13
+
14
+ models:
15
+ - type: Model
16
+ id: gpt4
17
+ provider: openai
18
+ model_id: ${MODEL_NAME:-gpt-4} # Optional with default
19
+ auth: openai_auth
20
+ ```
21
+
22
+ ### Explanation
23
+
24
+ - **`${VAR_NAME}`**: Substitutes the value of environment variable `VAR_NAME`; raises error if not set
25
+ - **`${VAR_NAME:-default}`**: Substitutes the value of `VAR_NAME` or uses `default` if not set
26
+ - **Environment variable resolution**: Happens during YAML loading, before validation and execution
27
+ - **Works everywhere**: Can be used in any string value throughout the YAML specification
28
+
29
+ ## Setting Environment Variables
30
+
31
+ ```bash
32
+ # Export before running
33
+ export OPENAI_KEY="sk-..."
34
+ qtype run app.qtype.yaml
35
+
36
+ # Or set inline
37
+ OPENAI_KEY="sk-..." uv run qtype run app.qtype.yaml
38
+
39
+ # Or in a .env file (automatically loaded via the loader)
40
+ echo 'OPENAI_KEY="sk-..."' >> .env
41
+ qtype run app.qtype.yaml
42
+ ```
43
+
44
+ ## See Also
45
+
46
+ - [Tutorial: Your First QType Application](../../Tutorials/01-first-qtype-application.md)
47
+ - [APIKeyAuthProvider Reference](../../components/APIKeyAuthProvider.md)
@@ -0,0 +1,59 @@
1
+ # Use QType MCP
2
+
3
+ QType's Model Context Protocol (MCP) server enables AI assistants like GitHub Copilot to lookup schemas and documentation, validate and visualize qtype files, and convert python modules or apis to tools directly from your AI workflow.
4
+
5
+ ## Command Line Usage
6
+
7
+ Start the MCP server manually for debugging or other tools:
8
+
9
+ ```bash
10
+ # Stdio transport (for VS Code, Claude Desktop, etc.)
11
+ qtype mcp --transport stdio
12
+
13
+ # HTTP/SSE transport (for web-based tools)
14
+ qtype mcp --transport sse --host 0.0.0.0 --port 8000
15
+ ```
16
+
17
+ ### Transport Options
18
+
19
+ - **stdio**: Standard input/output (default, for desktop tools)
20
+ - **sse**: Server-Sent Events over HTTP
21
+ - **streamable-http**: HTTP streaming protocol
22
+
23
+ ## Available MCP Tools
24
+
25
+ The QType MCP server provides these capabilities to AI assistants:
26
+
27
+ - **convert_api_to_tools**: Convert OpenAPI specs to QType tool definitions
28
+ - **convert_python_to_tools**: Convert Python modules to QType tools
29
+ - **get_component_schema**: Retrieve JSON Schema for any QType component
30
+ - **get_documentation**: Fetch specific documentation files
31
+ - **list_components**: List all available QType component types
32
+ - **list_documentation**: Browse available documentation
33
+ - **validate_qtype_yaml**: Validate QType YAML syntax and semantics
34
+ - **visualize_qtype_architecture**: Generate Mermaid diagrams from QType apps
35
+
36
+
37
+ ## VS Code Configuration
38
+
39
+ Add the QType MCP server to your workspace's `.vscode/mcp.json`:
40
+
41
+ ```json
42
+ {
43
+ "servers": {
44
+ "qtype": {
45
+ "type": "stdio",
46
+ "command": "qtype",
47
+ "cwd": "${workspaceFolder}",
48
+ "args": ["mcp", "--transport", "stdio"]
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+
55
+ ## See Also
56
+
57
+ - [MCP Server Implementation](../../components/MCP.md)
58
+ - [GitHub Copilot Documentation](https://code.visualstudio.com/docs/copilot/copilot-chat)
59
+ - [Model Context Protocol](https://modelcontextprotocol.io/)
@@ -0,0 +1,49 @@
1
+ # Trace Calls with OpenTelemetry
2
+
3
+ Enable distributed tracing for your QType applications using OpenTelemetry to monitor LLM calls, execution times, and data flow through Phoenix or other observability platforms.
4
+
5
+ ### QType YAML
6
+
7
+ ```yaml
8
+ telemetry:
9
+ id: phoenix_trace
10
+ provider: Phoenix
11
+ endpoint: http://localhost:6006/v1/traces
12
+ ```
13
+
14
+ ### Explanation
15
+
16
+ - **telemetry**: Top-level application configuration for observability
17
+ - **id**: Unique identifier for the telemetry sink
18
+ - **provider**: Telemetry backend (`Phoenix` or `Langfuse`)
19
+ - **endpoint**: URL where OpenTelemetry traces are sent
20
+
21
+ ### Starting Phoenix
22
+
23
+ Before running your application, start the Phoenix server:
24
+
25
+ ```bash
26
+ python3 -m phoenix.server.main serve
27
+ ```
28
+
29
+ Phoenix will start on `http://localhost:6006` where you can view traces and spans in real-time.
30
+
31
+ ## Complete Example
32
+
33
+ ```yaml
34
+ --8<-- "../examples/observability_debugging/trace_with_opentelemetry.qtype.yaml"
35
+ ```
36
+
37
+ Run the example:
38
+
39
+ ```bash
40
+ qtype run examples/observability_debugging/trace_with_opentelemetry.qtype.yaml --text "I love this product!"
41
+ ```
42
+
43
+ Then open `http://localhost:6006` in your browser to see the traced execution.
44
+
45
+ ## See Also
46
+
47
+ - [Application Reference](../../components/Application.md)
48
+ - [Validate QType YAML](validate_qtype_yaml.md)
49
+ - [Visualize Application Architecture](visualize_application_architecture.md)
@@ -0,0 +1,35 @@
1
+ # Validate QType YAML
2
+
3
+ Check your QType YAML files for syntax errors, schema violations, reference issues, and semantic problems before running them.
4
+
5
+ ### Command Line
6
+
7
+ ```bash
8
+ # Basic validation
9
+ qtype validate path/to/app.qtype.yaml
10
+
11
+ # Validate and print the parsed document
12
+ qtype validate path/to/app.qtype.yaml --print
13
+ ```
14
+
15
+ ### Validation Checks
16
+
17
+ - **YAML Syntax**: Verifies valid YAML structure and syntax
18
+ - **Schema Validation**: Ensures all fields match the QType schema (Pydantic validation)
19
+ - **Reference Resolution**: Checks that all ID references (models, steps, variables) exist
20
+ - **Duplicate Detection**: Identifies duplicate component IDs
21
+ - **Semantic Validation**: Validates flow logic, type compatibility, and business rules
22
+
23
+ ### Options
24
+
25
+ - **`--print` / `-p`**: Print the validated document with resolved references and defaults applied
26
+
27
+ ### Exit Codes
28
+
29
+ - **0**: Validation successful
30
+ - **1**: Validation failed (error details printed to stderr)
31
+
32
+ ## See Also
33
+
34
+ - [Application Reference](../../components/Application.md)
35
+ - [Semantic Validation Rules](../../Concepts/semantic_validation_rules.md)
@@ -0,0 +1,61 @@
1
+ # Visualize Application Architecture
2
+
3
+ Generate interactive diagrams showing your application's flows, steps, and data dependencies to understand structure and debug issues.
4
+
5
+ ## Example Visualization
6
+
7
+ Here's what a visualization looks like for a conversational chatbot application:
8
+
9
+ ```mermaid
10
+ --8<-- "How To/Observability & Debugging/visualize_example.mermaid"
11
+ ```
12
+
13
+ This diagram shows:
14
+
15
+ - **Flow structure**: The conversational flow with its interface and steps
16
+ - **Data flow**: How variables (user_message, context, response) flow between steps
17
+ - **Shared resources**: The LLM model and memory used by the application
18
+ - **Step types**: Different icons for templates (📄), LLM inference (✨), and other components
19
+
20
+ ## Command Line
21
+
22
+ ```bash
23
+ # Generate and open diagram in browser
24
+ qtype visualize path/to/app.qtype.yaml
25
+
26
+ # Save Mermaid diagram to file
27
+ qtype visualize path/to/app.qtype.yaml --output diagram.mmd
28
+
29
+ # Save without opening browser
30
+ qtype visualize path/to/app.qtype.yaml --output diagram.mmd --no-display
31
+ ```
32
+
33
+ ## Prerequisites
34
+
35
+ Visualization requires [mermaid-cli](https://github.com/mermaid-js/mermaid-cli) to be installed:
36
+
37
+ ```bash
38
+ npm install -g @mermaid-js/mermaid-cli
39
+ ```
40
+
41
+ ## How It Works
42
+
43
+ - **Generates Mermaid diagram**: Creates a flowchart showing flows, steps, and variable connections
44
+ - **Converts to SVG**: Uses `mmdc` to render the diagram as a scalable vector graphic
45
+ - **Opens in browser**: Displays the interactive diagram automatically (unless `--no-display` is set)
46
+
47
+ ## Options
48
+
49
+ - **`--output` / `-o`**: Save the Mermaid diagram source to a file (`.mmd` format)
50
+ - **`--no-display` / `-nd`**: Skip opening the diagram in browser (useful for CI/CD)
51
+
52
+ ## Exit Codes
53
+
54
+ - **0**: Visualization successful
55
+ - **1**: Visualization failed (invalid YAML or missing mmdc)
56
+
57
+ ## See Also
58
+
59
+ - [Validate QType YAML](validate_qtype_yaml.md)
60
+ - [Application Reference](../../components/Application.md)
61
+ - [Flow Reference](../../components/Flow.md)
@@ -0,0 +1,35 @@
1
+ flowchart TD
2
+ subgraph APP ["📱 simple_chatbot"]
3
+ direction TB
4
+
5
+ subgraph FLOW_0 ["🔄 chat_flow"]
6
+ direction LR
7
+ FLOW_0_START@{shape: circle, label: "▶️ Start"}
8
+ FLOW_0_S0@{shape: rounded, label: "✨ generate_response"}
9
+ FLOW_0_START -->|user_message| FLOW_0_S0
10
+ end
11
+
12
+ subgraph RESOURCES ["🔧 Shared Resources"]
13
+ direction LR
14
+ MODEL_NOVA_LITE@{shape: rounded, label: "✨ nova_lite (aws-bedrock)" }
15
+ MEM_CONVERSATION_MEMORY@{shape: win-pane, label: "🧠 conversation_memory (10KT)"}
16
+ end
17
+
18
+ end
19
+
20
+ FLOW_0_S0 -.->|uses| MODEL_NOVA_LITE
21
+ FLOW_0_S0 -.->|stores| MEM_CONVERSATION_MEMORY
22
+
23
+ %% Styling
24
+ classDef appBox fill:none,stroke:#495057,stroke-width:3px
25
+ classDef flowBox fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
26
+ classDef llmNode fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
27
+ classDef modelNode fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px
28
+ classDef authNode fill:#fff3e0,stroke:#ef6c00,stroke-width:2px
29
+ classDef telemetryNode fill:#fce4ec,stroke:#c2185b,stroke-width:2px
30
+ classDef resourceBox fill:#f5f5f5,stroke:#616161,stroke-width:1px
31
+
32
+ class APP appBox
33
+ class FLOW_0 flowBox
34
+ class RESOURCES resourceBox
35
+ class TELEMETRY telemetryNode
Binary file
@@ -0,0 +1,40 @@
1
+ # Serve Flows as APIs
2
+
3
+ Expose your QType flows as HTTP REST endpoints with automatically generated OpenAPI documentation using the `qtype serve` command.
4
+
5
+ ### Command
6
+
7
+ ```bash
8
+ qtype serve <file.qtype.yaml> [--host HOST] [--port PORT] [--reload]
9
+ ```
10
+
11
+ ### Explanation
12
+
13
+ - **Swagger UI**: Interactive API documentation available at `http://localhost:8000/docs`
14
+ - **ReDoc**: Alternative API documentation at `http://localhost:8000/redoc`
15
+ - **REST Endpoints**: Each flow is available at `POST /invoke/{flow_id}`
16
+ - **Streaming Endpoints**: Flows with UI interfaces get `POST /stream/{flow_id}` for Server-Sent Events
17
+ - **Interactive UI**: Web interface at `http://localhost:8000/ui` (redirects from root)
18
+ - **--reload**: Auto-reload on file changes during development
19
+ - **--host/--port**: Override default host (localhost) and port (8000)
20
+
21
+ ### Example
22
+
23
+ ```bash
24
+ qtype serve examples/tutorials/01_hello_world.qtype.yaml
25
+ ```
26
+
27
+ Then visit `http://localhost:8000/docs` to explore and test your API endpoints.
28
+
29
+ ### Available Endpoints
30
+
31
+ - **`GET /flows`**: List all flows with metadata (inputs, outputs, interface type)
32
+ - **`POST /flows/{flow_id}`**: Execute a specific flow (e.g., `POST /flows/simple_example`)
33
+
34
+ Each flow endpoint accepts JSON input matching the flow's input schema and returns structured results with `outputs` and `errors` arrays.
35
+
36
+ ## See Also
37
+
38
+ - [Application Reference](../../components/Application.md)
39
+ - [Flow Reference](../../components/Flow.md)
40
+ - [FlowInterface Reference](../../components/FlowInterface.md)
@@ -0,0 +1,42 @@
1
+ # Serve Flows as UI
2
+
3
+ Expose your QType flows through an interactive web interface using the `qtype serve` command.
4
+
5
+ ### Command
6
+
7
+ ```bash
8
+ qtype serve <file.qtype.yaml> [--host HOST] [--port PORT] [--reload]
9
+ ```
10
+
11
+ ### Explanation
12
+
13
+ - **Interactive UI**: Web interface at `http://localhost:8000/ui` (redirects from root `/`)
14
+ - **Complete Flows**: Display as forms with input fields and output display
15
+ - **Conversational Flows**: Display as chat interfaces with message history
16
+ - **Auto-generated**: UI is automatically created based on flow inputs/outputs
17
+ - **--reload**: Auto-reload on file changes during development
18
+ - **--host/--port**: Override default host (localhost) and port (8000)
19
+
20
+ ### Example
21
+
22
+ ```bash
23
+ qtype serve examples/tutorials/01_hello_world.qtype.yaml
24
+ ```
25
+
26
+ Then visit `http://localhost:8000/ui` to interact with your flow through the web interface.
27
+
28
+ ![Flow UI Screenshot](flow_as_ui.png)
29
+
30
+ The UI automatically generates:
31
+
32
+ - Input fields based on variable types
33
+ - Submit button to execute the flow
34
+ - Output display for results
35
+ - Error messages if execution fails
36
+
37
+ ## See Also
38
+
39
+ - [Serve Flows as APIs](serve_flows_as_apis.md)
40
+ - [Flow Reference](../../components/Flow.md)
41
+ - [FlowInterface Reference](../../components/FlowInterface.md)
42
+ - [Tutorial: Build a Conversational Chatbot](../../Tutorials/02-conversational-chatbot.md)
@@ -0,0 +1,59 @@
1
+ # Use Conversational Interfaces
2
+
3
+ The `Conversational` interface tells the QType UI to render a chat instead of just an "execute flow" button.
4
+
5
+ Note that, if you set the interface to Conversational, QType will validate that the input and outputs are of type `ChatMessage`. If you set the interface to Conversational and this is not true, and error will be thrown.
6
+
7
+ ### QType YAML
8
+
9
+ ```yaml
10
+ flows:
11
+ - type: Flow
12
+ id: simple_chat_example
13
+ interface:
14
+ type: Conversational
15
+ variables:
16
+ - id: user_message
17
+ type: ChatMessage
18
+ - id: response_message
19
+ type: ChatMessage
20
+ inputs:
21
+ - user_message
22
+ outputs:
23
+ - response_message
24
+ ```
25
+
26
+ ### Web UI
27
+
28
+ When you serve a conversational flow with `qtype serve`, the UI renders a chat interface:
29
+
30
+ ![Chat interface showing conversation with memory](../../Tutorials/example_chat.png)
31
+
32
+
33
+ ### Explanation
34
+
35
+ - **interface.type: Conversational**: Configures the flow to be served as a chat interface in the web UI rather than a simple form
36
+ - **ChatMessage type**: Domain type that structures messages with content blocks, role metadata, and conversation context
37
+ - **Reset on refresh**: Starting a new browser session creates a new conversation with fresh memory
38
+
39
+ ## Complete Example
40
+
41
+ ```yaml
42
+ --8<-- "../examples/tutorials/02_conversational_chat.qtype.yaml"
43
+ ```
44
+
45
+ **Start the chat interface:**
46
+ ```bash
47
+ qtype serve 02_conversational_chat.qtype.yaml
48
+ ```
49
+
50
+ Visit [http://localhost:8000/ui](http://localhost:8000/ui) to interact with the chatbot.
51
+
52
+ ## See Also
53
+
54
+ - [Serve Flows as UI](serve_flows_as_ui.md)
55
+ - [Tutorial: Build a Conversational Chatbot](../../Tutorials/02-conversational-chatbot.md)
56
+ - [Flow Reference](../../components/Flow.md)
57
+ - [FlowInterface Reference](../../components/FlowInterface.md)
58
+ - [ChatMessage Reference](../../components/ChatMessage.md)
59
+ - [Memory Concept](../../Concepts/Core/memory.md)
@@ -0,0 +1,47 @@
1
+ # Use Variables with UI Hints
2
+
3
+ Customize how input variables are displayed in the web UI using the `ui` field on variable definitions.
4
+
5
+ ### QType YAML
6
+
7
+ ```yaml
8
+ flows:
9
+ - type: Flow
10
+ id: generate_story
11
+
12
+ variables:
13
+ # Use textarea widget for multi-line text input
14
+ - id: story_prompt
15
+ type: text
16
+ ui:
17
+ widget: textarea
18
+
19
+ # Use file upload widget with mime type filtering
20
+ - id: document
21
+ type: file
22
+ ui:
23
+ accept: "application/pdf"
24
+
25
+ # Variables without ui hints use default widgets
26
+ - id: max_length
27
+ type: int
28
+ ```
29
+
30
+ ### Explanation
31
+
32
+ - **ui.widget**: For `text` variables, controls input style (`text` for single-line, `textarea` for multi-line)
33
+ - **ui.accept**: For `file` variables, specifies accepted mime types (e.g., `"application/pdf"`, `"image/*"`, `"*/*"`)
34
+ - **Default widgets**: Variables without `ui` hints automatically use appropriate widgets based on their type
35
+
36
+ **Note**: UI hints are currently limited to text and file input customization. Other variable types use standard widgets.
37
+
38
+ ## Complete Example
39
+
40
+ ```yaml
41
+ --8<-- "../examples/language_features/ui_hints.qtype.yaml"
42
+ ```
43
+
44
+ ## See Also
45
+
46
+ - [Serve Flows as UI](../../How%20To/Qtype%20Server/serve_flows_as_ui.md)
47
+ - [Flow Reference](../../components/Flow.md)
@@ -0,0 +1,48 @@
1
+ # Bind Tool Inputs and Outputs
2
+
3
+ Map flow variables to tool parameters and capture tool results using `input_bindings` and `output_bindings` in the InvokeTool step.
4
+
5
+ ### QType YAML
6
+
7
+ ```yaml
8
+ steps:
9
+ # Tool with no inputs, only output binding
10
+ - type: InvokeTool
11
+ id: get_current_time
12
+ tool: qtype.application.commons.tools.get_current_timestamp
13
+ input_bindings: {}
14
+ output_bindings:
15
+ result: current_time
16
+ outputs: [current_time]
17
+
18
+ # Tool with multiple input bindings
19
+ - type: InvokeTool
20
+ id: add_days
21
+ tool: qtype.application.commons.tools.timedelta
22
+ input_bindings:
23
+ timestamp: current_time # Tool param ← flow variable
24
+ days: days_until_due # Tool param ← flow variable
25
+ output_bindings:
26
+ result: deadline_time # Tool output → flow variable
27
+ outputs: [deadline_time]
28
+ ```
29
+
30
+ ### Explanation
31
+
32
+ - **input_bindings**: Maps tool parameter names (left) to flow variable names (right)
33
+ - **output_bindings**: Maps tool output names (left) to flow variable names (right)
34
+ - **outputs**: Lists flow variables this step produces (must match output_bindings values)
35
+ - **Chaining**: Output variables from one tool become input variables for the next tool
36
+
37
+ ## Complete Example
38
+
39
+ ```yaml
40
+ --8<-- "../examples/tutorials/04_tools_and_function_calling.qtype.yaml"
41
+ ```
42
+
43
+ ## See Also
44
+
45
+ - [Tutorial: Adding Tools to Your Application](../../Tutorials/04-tools-and-function-calling.md)
46
+ - [InvokeTool Reference](../../components/InvokeTool.md)
47
+ - [Create Tools from Python Modules](create_tools_from_python_modules.md)
48
+ - [Create Tools from OpenAPI Specifications](create_tools_from_openapi_specifications.md)
@@ -0,0 +1,89 @@
1
+ # Create Tools from OpenAPI Specifications
2
+
3
+ Generate QType tool definitions automatically from OpenAPI/Swagger specifications using `qtype convert api`, which parses API endpoints, parameters, and schemas to create properly typed API tools.
4
+
5
+ ### Command
6
+
7
+ ```bash
8
+ # Convert from a URL (or use a local file path)
9
+ qtype convert api https://petstore3.swagger.io/api/v3/openapi.json --output petstore_tools.qtype.yaml
10
+ ```
11
+
12
+ This creates the `petstore_tools.qtype.yaml` qtype file you can import into your application.
13
+
14
+ ### QType YAML
15
+
16
+ **Generated tool YAML** (`petstore_tools.qtype.yaml`):
17
+ ```yaml
18
+ id: swagger-petstore---openapi-30
19
+ description: Tools created from API specification petstore_api.json
20
+
21
+ auths:
22
+ - id: swagger-petstore---openapi-30_api_key_api_key
23
+ type: api_key
24
+ api_key: your_api_key_here
25
+
26
+ tools:
27
+ - id: getPetById
28
+ name: Find pet by ID.
29
+ description: Returns a single pet.
30
+ type: APITool
31
+ method: GET
32
+ endpoint: /api/v3/pet/{petId}
33
+ auth: swagger-petstore---openapi-30_api_key_api_key
34
+ parameters:
35
+ petId:
36
+ type: int
37
+ optional: false
38
+ outputs:
39
+ id:
40
+ type: int
41
+ optional: true
42
+ name:
43
+ type: text
44
+ optional: false
45
+ status:
46
+ type: text
47
+ optional: true
48
+ ```
49
+
50
+ ### Explanation
51
+
52
+ - **`convert api`**: CLI subcommand that converts OpenAPI specifications to tool definitions
53
+ - **OpenAPI spec**: JSON or YAML file following OpenAPI 3.0+ or Swagger 2.0 format
54
+ - **`--output`**: Target YAML file path; omit to print to stdout
55
+ - **operationId**: Becomes the tool ID (e.g., `getPetById`)
56
+ - **parameters**: Path, query, and header parameters become tool `parameters`
57
+ - **responses**: Response schema properties become tool `outputs`
58
+ - **servers**: Base URL is combined with path to create full endpoint
59
+ - **method**: HTTP method (GET, POST, PUT, DELETE, etc.)
60
+ - **securitySchemes**: Generates auth providers (API key, OAuth2, Bearer token)
61
+
62
+ ### Using Generated Tools
63
+
64
+ ```yaml
65
+ references:
66
+ - !include petstore_tools.qtype.yaml
67
+
68
+ flows:
69
+ - id: fetch_pet
70
+ steps:
71
+ - type: InvokeTool
72
+ id: get_pet
73
+ tool: getPetById
74
+ input_bindings:
75
+ petId: pet_id
76
+ output_bindings:
77
+ name: pet_name
78
+ status: pet_status
79
+ ```
80
+
81
+ See [Tutorial: Adding Tools to Your Application](../../Tutorials/04-tools-and-function-calling.md) for a detailed usage.
82
+
83
+
84
+ ## See Also
85
+
86
+ - [Tutorial: Adding Tools to Your Application](../../Tutorials/04-tools-and-function-calling.md)
87
+ - [How-To: Create Tools from Python Modules](create_tools_from_python_modules.md)
88
+ - [InvokeTool Reference](../../components/InvokeTool.md)
89
+ - [APITool Reference](../../components/APITool.md)