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,259 @@
1
+ # Observe with Telemetry
2
+
3
+ QType supports telemetry for all applications out of the box -- simply add the [Telemetry](../../Concepts/Core/telemetry.md) field to your application.
4
+
5
+ QType integrates with popular observability platforms to help you understand, debug, and optimize your LLM applications. This guide covers how to set up telemetry with Phoenix and Langfuse.
6
+
7
+ ## Supported Providers
8
+
9
+ - **Phoenix** - Open-source LLM observability from Arize AI (default)
10
+ - **Langfuse** - Open-source LLM engineering platform with tracing and analytics
11
+
12
+ ## Phoenix Integration
13
+
14
+ [Arize Phoenix](https://phoenix.arize.com/) is an open-source platform for LLM observability that runs locally or in the cloud.
15
+
16
+ ### Setting up Phoenix
17
+ First, ensure you have installed the qtype `interpreter`:
18
+ ```bash
19
+ pip install qtype[interpreter]
20
+ ```
21
+
22
+ Next, install [Arize Phoenix](https://phoenix.arize.com/):
23
+ ```bash
24
+ pip install arize-phoenix
25
+ ```
26
+
27
+ and launch it:
28
+ ```bash
29
+ phoenix serve
30
+ ```
31
+
32
+ This launches Phoenix on your local machine and listens for trace data at `http://localhost:6006/v1/traces`.
33
+
34
+ ### Adding Phoenix Telemetry
35
+
36
+ Add telemetry to your QType application:
37
+ ```yaml
38
+
39
+ ```yaml
40
+ id: hello_world
41
+ telemetry:
42
+ id: hello_world_telemetry
43
+ endpoint: http://localhost:6006/v1/traces
44
+ flows:
45
+ - id: simple_chat_example
46
+ description: A simple stateful chat flow with OpenAI
47
+ mode: Chat
48
+ steps:
49
+ - id: llm_inference_step
50
+ memory:
51
+ id: chat_memory
52
+ model:
53
+ id: gpt-4
54
+ provider: openai
55
+ auth:
56
+ id: openai_auth
57
+ type: api_key
58
+ api_key: ${OPENAI_KEY}
59
+ system_message: |
60
+ You are a helpful assistant.
61
+ inputs:
62
+ - id: user_message
63
+ type: ChatMessage
64
+ outputs:
65
+ - id: response_message
66
+ type: ChatMessage
67
+ ```
68
+
69
+ Notice the `telemetry` field with the Phoenix endpoint. The `provider` defaults to `"Phoenix"` so you don't need to specify it.
70
+
71
+ ### Viewing Phoenix Traces
72
+
73
+ 1. Start your application:
74
+ ```bash
75
+ qtype serve your-app.qtype.yaml
76
+ ```
77
+
78
+ 2. Navigate to `http://localhost:8000/ui` and have a conversation
79
+
80
+ 3. View traces at [http://localhost:6006](http://localhost:6006). You'll see a project whose name matches your application id:
81
+
82
+ ![Phoenix Projects](./phoenix_projects.png)
83
+
84
+ 4. Click on the project to see the traces of your conversation:
85
+
86
+ ![Phoenix Traces](./phoenix_traces.png)
87
+
88
+ Now you'll have a complete record of all LLM calls and interactions!
89
+
90
+ ## Langfuse Integration
91
+
92
+ [Langfuse](https://langfuse.com) is an open-source LLM engineering platform that provides tracing, analytics, prompt management, and evaluation capabilities.
93
+
94
+ ### Getting Langfuse Credentials
95
+
96
+ 1. Sign up for [Langfuse Cloud](https://cloud.langfuse.com) or deploy self-hosted
97
+ 2. Create a new project
98
+ 3. Navigate to Settings → API Keys
99
+ 4. Generate a new API key pair (public_key and secret_key)
100
+ 5. Store credentials in environment variables:
101
+ ```bash
102
+ export LANGFUSE_PUBLIC_KEY="pk-lf-..."
103
+ export LANGFUSE_SECRET_KEY="sk-lf-..."
104
+ ```
105
+
106
+ ### Adding Langfuse Telemetry
107
+
108
+ Configure Langfuse as your telemetry provider:
109
+
110
+ ```yaml
111
+ telemetry:
112
+ id: langfuse_telemetry
113
+ provider: Langfuse
114
+ endpoint: https://cloud.langfuse.com
115
+ args:
116
+ public_key: ${LANGFUSE_PUBLIC_KEY}
117
+ secret_key: ${LANGFUSE_SECRET_KEY}
118
+ ```
119
+
120
+ **Required fields:**
121
+ - **provider**: Must be set to `"Langfuse"`
122
+ - **endpoint**: Langfuse host URL
123
+ - Cloud: `https://cloud.langfuse.com`
124
+ - Self-hosted: Your instance URL
125
+ - **args.public_key**: Your Langfuse public key
126
+ - **args.secret_key**: Your Langfuse secret key
127
+
128
+ ### Complete Langfuse Example
129
+
130
+ ```yaml
131
+ id: hello_world_langfuse
132
+ description: A simple chat flow with Langfuse telemetry
133
+ models:
134
+ - type: Model
135
+ id: gpt4
136
+ provider: openai
137
+ model_id: gpt-4
138
+ inference_params:
139
+ temperature: 0.7
140
+ max_tokens: 512
141
+ auth: openai_auth
142
+ auths:
143
+ - type: api_key
144
+ id: openai_auth
145
+ api_key: ${OPENAI_KEY}
146
+ memories:
147
+ - id: chat_memory
148
+ token_limit: 10000
149
+ flows:
150
+ - type: Flow
151
+ id: chat_example
152
+ interface:
153
+ type: Conversational
154
+ variables:
155
+ - id: user_message
156
+ type: ChatMessage
157
+ - id: response
158
+ type: ChatMessage
159
+ inputs:
160
+ - user_message
161
+ outputs:
162
+ - response
163
+ steps:
164
+ - type: LLMInference
165
+ id: llm_inference_step
166
+ model: gpt4
167
+ memory: chat_memory
168
+ system_message: "You are a helpful assistant."
169
+ inputs:
170
+ - user_message
171
+ outputs:
172
+ - response
173
+ telemetry:
174
+ id: langfuse_telemetry
175
+ provider: Langfuse
176
+ endpoint: https://cloud.langfuse.com
177
+ args:
178
+ public_key: ${LANGFUSE_PUBLIC_KEY}
179
+ secret_key: ${LANGFUSE_SECRET_KEY}
180
+ ```
181
+
182
+ ### Viewing Langfuse Traces
183
+
184
+ 1. Run your application:
185
+ ```bash
186
+ qtype serve examples/chat_with_langfuse.qtype.yaml
187
+ ```
188
+
189
+ 2. Interact with your application at http://localhost:8000/ui
190
+
191
+ 3. View traces in Langfuse:
192
+ - Go to https://cloud.langfuse.com
193
+ - Navigate to your project
194
+ - View traces in the Tracing tab
195
+
196
+ ### How Langfuse Integration Works
197
+
198
+ QType integrates with Langfuse via OpenTelemetry's OTLP protocol:
199
+
200
+ 1. Creates an OpenTelemetry TracerProvider with your project name as the service name
201
+ 2. Configures an OTLP HTTP exporter that sends spans to Langfuse's `/api/public/otel` endpoint
202
+ 3. Uses Basic Authentication with your public_key:secret_key credentials
203
+ 4. Automatically instruments LlamaIndex to capture all LLM interactions
204
+
205
+ All LLM calls, steps, and flows are automatically traced and sent to Langfuse.
206
+
207
+ ## Using AWS Secrets Manager
208
+
209
+ Both Phoenix and Langfuse support storing credentials in AWS Secrets Manager:
210
+
211
+ ```yaml
212
+ secret_manager:
213
+ type: aws
214
+ region: us-east-1
215
+
216
+ telemetry:
217
+ id: langfuse_telemetry
218
+ provider: Langfuse
219
+ endpoint: https://cloud.langfuse.com
220
+ args:
221
+ public_key:
222
+ secret: langfuse-credentials
223
+ key: public_key
224
+ secret_key:
225
+ secret: langfuse-credentials
226
+ key: secret_key
227
+ ```
228
+
229
+ ## Troubleshooting
230
+
231
+ ### No traces appearing
232
+
233
+ **Phoenix:**
234
+ - Verify Phoenix is running on the correct port (default: 6006)
235
+ - Check the endpoint URL in your telemetry configuration
236
+ - Ensure no firewall is blocking the connection
237
+
238
+ **Langfuse:**
239
+ - Verify your credentials are correct (public_key starts with `pk-lf-`, secret_key starts with `sk-lf-`)
240
+ - Check the endpoint URL (should NOT include `/api/public/otel` - this is added automatically)
241
+ - Ensure your Langfuse project exists
242
+ - Check application logs for authentication errors
243
+ - Verify no extra whitespace in credentials
244
+
245
+ ### Self-hosted Langfuse
246
+
247
+ If using self-hosted Langfuse, set the endpoint to your instance URL:
248
+ ```yaml
249
+ telemetry:
250
+ provider: Langfuse
251
+ endpoint: https://langfuse.yourcompany.com
252
+ ```
253
+
254
+ ## Learn More
255
+
256
+ - [Phoenix Documentation](https://phoenix.arize.com/)
257
+ - [Langfuse Documentation](https://langfuse.com/docs)
258
+ - [Langfuse OpenTelemetry Integration](https://langfuse.com/docs/integrations/opentelemetry)
259
+ - [QType Telemetry Concepts](../../Concepts/Core/telemetry.md)
@@ -0,0 +1,52 @@
1
+ # Create Custom Types
2
+
3
+ QType allows you to create custom types for variable inputs and outputs.
4
+
5
+ Custom types must be defined the in `types` list in your Application. They _can not_ be defined in-line in variables.
6
+
7
+ Internally, custom types are mapped to pydantic objects.
8
+
9
+ --8<-- "components/CustomType.md"
10
+
11
+ ## A Simple Example
12
+
13
+ The following example illustrates the key features of custom types:
14
+
15
+ * The custom types `Arthor` and `Book` are defined. Those terms can be used as a `type` in any variable.
16
+ * All fields of the custom types should be other custom types, primitive types, or [domain types](./domain-types.md)
17
+ * A `?` can be used after the type to indicate it is optional. In this case, it will be `None` if not provided.
18
+ * A `list[type]` can be used to indicate a list.
19
+ * Forward references are allowed -- `Book` references `Arthor` which is defined later
20
+
21
+
22
+
23
+ ```yaml
24
+ id: valid_custom_type
25
+ types:
26
+ - id: Book
27
+ properties:
28
+ title: text
29
+ author: Author # <-- this is a forward reference
30
+ year: int?
31
+ tags: "list[text]"
32
+ published: boolean
33
+ - id: Author
34
+ properties:
35
+ id: int
36
+ name: text
37
+ flows:
38
+ - id: my_person_flow
39
+ mode: Complete
40
+ steps:
41
+ - id: prompt_template
42
+ template: >
43
+ You are a helpful assistant. Please provide information about the following book:
44
+ {book}
45
+ inputs:
46
+ - id: book
47
+ type: Book
48
+ outputs:
49
+ - id: prompt_format
50
+ type: text
51
+ ```
52
+
@@ -0,0 +1,113 @@
1
+ # Use Domain Types
2
+
3
+ QType provides several built-in domain types that represent common AI and chat application data structures.
4
+
5
+ ## Overview of Domain Types
6
+
7
+ QType includes these key domain types:
8
+
9
+ - **`ChatMessage`** - Structured chat messages with roles and content blocks
10
+ - **`ChatContent`** - Individual content blocks (text, images, etc.) within messages
11
+ - **`Embedding`** - Vector embeddings with metadata
12
+ - **`MessageRole`** - Enumeration of message sender roles
13
+
14
+ These types help you build robust AI applications with proper data structure and validation.
15
+
16
+ ## ChatMessage: The Foundation of Conversational AI
17
+
18
+ --8<-- "components/ChatMessage.md"
19
+
20
+ ### Understanding ChatMessage Structure
21
+
22
+ `ChatMessage` is a composite type that represents a single message in a conversation:
23
+
24
+ ```yaml
25
+ # Basic chat message structure
26
+ variables:
27
+ - id: user_input
28
+ type: ChatMessage
29
+ # Will contain: role + list of content blocks
30
+
31
+ - id: ai_response
32
+ type: ChatMessage
33
+ # AI's response with assistant role
34
+ ```
35
+
36
+ ### Message Roles
37
+
38
+ --8<-- "components/MessageRole.md"
39
+
40
+ The `MessageRole` enum defines who sent the message:
41
+
42
+ - **`user`** - End user input
43
+ - **`assistant`** - AI model response
44
+ - **`system`** - System instructions/context
45
+ - **`tool`** - Tool execution results
46
+ - **`function`** - Function call results (legacy)
47
+ - **`developer`** - Developer notes/debugging
48
+ - **`model`** - Direct model output
49
+ - **`chatbot`** - Chatbot-specific role
50
+
51
+ ### Content Blocks
52
+
53
+ --8<-- "components/ChatContent.md"
54
+
55
+ Each `ChatMessage` contains one or more `ChatContent` blocks:
56
+
57
+ ## Practical Examples
58
+
59
+ ### Basic Chat Flow
60
+
61
+ The following creates a simple chat experience that is multi-modal: since `ChatMessage` contains mupltiple blocks, the blocks can be of different multimedia types.
62
+
63
+ ```yaml
64
+ id: simple_chat
65
+ flows:
66
+ - id: chat_conversation
67
+ mode: Chat
68
+ steps:
69
+ - id: llm_step
70
+ model:
71
+ id: gpt-4o
72
+ provider: openai
73
+ auth:
74
+ id: openai_auth
75
+ type: api_key
76
+ api_key: ${OPENAI_KEY}
77
+ system_message: |
78
+ You are a helpful AI assistant.
79
+ inputs:
80
+ - id: user_message
81
+ type: ChatMessage # User's input message
82
+ outputs:
83
+ - id: assistant_response
84
+ type: ChatMessage # AI's response message
85
+ ```
86
+
87
+ ## Working with Embeddings
88
+
89
+ --8<-- "components/Embedding.md"
90
+
91
+ ### Basic Embedding Usage
92
+
93
+ ```yaml
94
+ id: embedding_example
95
+ models:
96
+ - id: text_embedder
97
+ provider: openai
98
+ model_id: text-embedding-3-large
99
+ dimensions: 3072
100
+ auth: openai_auth
101
+
102
+ flows:
103
+ - id: create_embeddings
104
+ steps:
105
+ - id: embed_step
106
+ model: text_embedder
107
+ inputs:
108
+ - id: source_text
109
+ type: text
110
+ outputs:
111
+ - id: text_embedding
112
+ type: Embedding # Vector + metadata
113
+ ```
@@ -0,0 +1,147 @@
1
+ # Visualize Application Architecture
2
+
3
+ QType includes a visualization feature that automatically generates Mermaid flowchart diagrams from your QType specifications. These visual diagrams help you understand the structure and flow of your AI applications at a glance.
4
+
5
+ ## The `qtype visualize` Command
6
+
7
+ The `visualize` command analyzes your QType YAML specification and generates a comprehensive Mermaid diagram showing:
8
+
9
+ - **Flows** and their execution steps
10
+ - **Shared resources** like models, indexes, authentication, and memory
11
+ - **Connections** between components
12
+ - **Telemetry** and observability configuration
13
+
14
+ ## Basic Usage
15
+
16
+ To generate a visualization of your QType application:
17
+
18
+ ```bash
19
+ qtype visualize your_application.qtype.yaml
20
+ ```
21
+
22
+ This will:
23
+ 1. Load and validate your QType specification
24
+ 2. Generate a Mermaid diagram
25
+ 3. Open the diagram in your default browser for viewing
26
+
27
+ ## Output Formats
28
+
29
+ The `visualize` command supports multiple output formats:
30
+
31
+ ### Display in Browser (Default)
32
+ ```bash
33
+ qtype visualize examples/chat_with_telemetry.qtype.yaml
34
+ ```
35
+ Opens the diagram directly in your browser for immediate viewing.
36
+
37
+ ### Save as Mermaid Source
38
+ ```bash
39
+ qtype visualize examples/chat_with_telemetry.qtype.yaml -o diagram.mmd
40
+ ```
41
+ Saves the raw Mermaid markup to a `.mmd` or `.mermaid` file.
42
+
43
+ ### Export as SVG
44
+ ```bash
45
+ qtype visualize examples/chat_with_telemetry.qtype.yaml -o diagram.svg
46
+ ```
47
+ Generates a scalable vector graphics file perfect for documentation.
48
+
49
+ ### Export as PNG
50
+ ```bash
51
+ qtype visualize examples/chat_with_telemetry.qtype.yaml -o diagram.png
52
+ ```
53
+ Creates a raster image file for presentations or embedding.
54
+
55
+ ### Save Without Opening Browser
56
+ ```bash
57
+ qtype visualize examples/chat_with_telemetry.qtype.yaml -o diagram.svg --no-display
58
+ ```
59
+ Use the `--no-display` flag to save files without opening the browser.
60
+
61
+ ## Example: Chat with Telemetry
62
+
63
+ Let's look at a practical example using the `chat_with_telemetry.qtype.yaml` file:
64
+
65
+ ```yaml
66
+ id: hello_world
67
+ flows:
68
+ - id: chat_example
69
+ description: A simple chat flow with OpenAI
70
+ mode: Chat
71
+ steps:
72
+ - id: llm_inference_step
73
+ model:
74
+ id: gpt-4
75
+ provider: openai
76
+ auth:
77
+ id: openai_auth
78
+ type: api_key
79
+ api_key: ${OPENAI_KEY}
80
+ system_message: |
81
+ You are a helpful assistant.
82
+ inputs:
83
+ - id: user_message
84
+ type: ChatMessage
85
+ outputs:
86
+ - id: response
87
+ type: ChatMessage
88
+ telemetry:
89
+ id: hello_world_telemetry
90
+ endpoint: http://localhost:6006/v1/traces
91
+ ```
92
+
93
+ Running the visualization command:
94
+
95
+ ```bash
96
+ qtype visualize examples/chat_with_telemetry.qtype.yaml -o chat_with_telemetry.mermaid
97
+ ```
98
+
99
+ Generates this Mermaid diagram:
100
+
101
+
102
+ ## Understanding the Diagram
103
+
104
+ The generated diagram uses intuitive icons and colors to represent different components:
105
+
106
+ ### Application Structure
107
+ - **📱 Application**: The outermost container showing your application ID
108
+ - **💬 Chat Flows** / **🔄 Flows**: Individual flows with their descriptions
109
+ - **✨ Steps**: Individual steps within flows (with different shapes for different step types)
110
+
111
+ ### Shared Resources
112
+ - **🔐 Authentication**: API keys, OAuth, and other auth providers
113
+ - **✨ Models**: LLM models with their providers (OpenAI, Bedrock, etc.)
114
+ - **🗂️ Indexes**: Vector and document indexes for retrieval
115
+ - **🧠 Memory**: Conversation memory stores
116
+ - **🔧 Tools**: API tools, Python functions, and other capabilities
117
+
118
+ ### Observability
119
+ - **📊 Telemetry**: OpenTelemetry tracing endpoints
120
+ - **📡 Telemetry Sink**: Where traces and metrics are sent
121
+
122
+ ### Connections
123
+ - **Solid arrows** (`-->`) show data flow between steps
124
+ - **Dotted arrows** (`-.->`) show resource dependencies and relationships
125
+
126
+ ## Command Reference
127
+
128
+ ```
129
+ qtype visualize [OPTIONS] SPEC_FILE
130
+
131
+ Arguments:
132
+ SPEC_FILE Path to the QType YAML file to visualize
133
+
134
+ Options:
135
+ -o, --output PATH Save diagram to file (.mmd, .mermaid, .svg, .png)
136
+ -nd, --no-display Don't open diagram in browser (default: False)
137
+ -h, --help Show help message
138
+ ```
139
+
140
+
141
+ ## Tips for Better Visualizations
142
+
143
+ 1. **Use descriptive IDs**: Clear, descriptive IDs for flows and steps make diagrams more readable
144
+ 2. **Add descriptions**: Flow descriptions appear in the diagram and provide valuable context
145
+ 3. **Group related functionality**: Organize steps logically within flows
146
+ 4. **Keep flows focused**: Smaller, focused flows are easier to understand than large, complex ones
147
+
@@ -0,0 +1,29 @@
1
+ # Create Tools from OpenAPI Spec
2
+
3
+ QType allows you to automatically convert openapi specs to tools. This lets you make arbitrary calls in your flows, or connect them to agents.
4
+
5
+ This tutorial will walk you through creating convertting an openapi spec into QType specification that can be used in your applications.
6
+
7
+ ## Prerequisites
8
+
9
+ Before following this tutorial, make sure you understand:
10
+
11
+ - [Variables and types](../../Concepts/Core/variable.md) in QType
12
+ - [Primitive types](../../components/PrimitiveTypeEnum.md)
13
+ - [Domain types](../Data%20Types/domain-types.md)
14
+ - [Custom types](../Data%20Types/custom-types.md)
15
+
16
+ ## Overview
17
+
18
+ The `qtype convert api` command creates [tools](../../Concepts/Core/tool.md), [AuthorizationProvider](../../Concepts/Core/authorization-provider.md), and [Custom types](../Data%20Types/custom-types.md) for each endpoint in the api.
19
+
20
+
21
+ ## Converting the API to QType Tools
22
+
23
+ Via the QType CLI:
24
+
25
+ ```bash
26
+ qtype convert api spec.oas.yaml -o api_tools.qtype.yaml
27
+ ```
28
+
29
+