qtype 0.1.11__py3-none-any.whl → 0.1.13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qtype/` +0 -0
- qtype/application/__init__.py +0 -2
- qtype/application/converters/tools_from_api.py +67 -57
- qtype/application/converters/tools_from_module.py +66 -32
- qtype/base/types.py +6 -1
- qtype/commands/convert.py +3 -6
- qtype/commands/generate.py +97 -10
- qtype/commands/mcp.py +68 -0
- qtype/commands/run.py +116 -44
- qtype/commands/validate.py +4 -4
- qtype/docs/.pages +8 -0
- qtype/docs/Concepts/mental-model-and-philosophy.md +363 -0
- qtype/docs/Contributing/.pages +4 -0
- qtype/docs/Contributing/index.md +283 -0
- qtype/docs/Contributing/roadmap.md +81 -0
- qtype/docs/Decisions/ADR-001-Chat-vs-Completion-Endpoint-Features.md +56 -0
- qtype/docs/Gallery/dataflow_pipelines.md +81 -0
- qtype/docs/Gallery/dataflow_pipelines.mermaid +45 -0
- qtype/docs/Gallery/research_assistant.md +97 -0
- qtype/docs/Gallery/research_assistant.mermaid +42 -0
- qtype/docs/Gallery/simple_chatbot.md +38 -0
- qtype/docs/Gallery/simple_chatbot.mermaid +35 -0
- qtype/docs/How To/Authentication/configure_aws_authentication.md +60 -0
- qtype/docs/How To/Authentication/use_api_key_authentication.md +40 -0
- qtype/docs/How To/Command Line Usage/load_multiple_inputs_from_files.md +77 -0
- qtype/docs/How To/Command Line Usage/pass_inputs_on_the_cli.md +52 -0
- qtype/docs/How To/Command Line Usage/serve_with_auto_reload.md +27 -0
- qtype/docs/How To/Data Processing/adjust_concurrency.md +40 -0
- qtype/docs/How To/Data Processing/cache_step_results.md +71 -0
- qtype/docs/How To/Data Processing/decode_json_xml.md +24 -0
- qtype/docs/How To/Data Processing/explode_collections.md +40 -0
- qtype/docs/How To/Data Processing/gather_results.md +68 -0
- qtype/docs/How To/Data Processing/invoke_other_flows.md +71 -0
- qtype/docs/How To/Data Processing/load_data_from_athena.md +49 -0
- qtype/docs/How To/Data Processing/read_data_from_files.md +61 -0
- qtype/docs/How To/Data Processing/read_sql_databases.md +46 -0
- qtype/docs/How To/Data Processing/write_data_to_file.md +39 -0
- qtype/docs/How To/Invoke Models/call_large_language_models.md +51 -0
- qtype/docs/How To/Invoke Models/create_embeddings.md +49 -0
- qtype/docs/How To/Invoke Models/reuse_prompts_with_templates.md +38 -0
- qtype/docs/How To/Language Features/include_qtype_yaml.md +45 -0
- qtype/docs/How To/Language Features/include_raw_text_from_other_files.md +48 -0
- qtype/docs/How To/Language Features/reference_entities_by_id.md +51 -0
- qtype/docs/How To/Language Features/use_agent_skills.md +29 -0
- qtype/docs/How To/Language Features/use_environment_variables.md +48 -0
- qtype/docs/How To/Language Features/use_optional_variables.md +42 -0
- qtype/docs/How To/Language Features/use_qtype_mcp.md +59 -0
- qtype/docs/How To/Observability & Debugging/trace_calls_with_open_telemetry.md +49 -0
- qtype/docs/How To/Observability & Debugging/validate_qtype_yaml.md +36 -0
- qtype/docs/How To/Observability & Debugging/visualize_application_architecture.md +61 -0
- qtype/docs/How To/Observability & Debugging/visualize_example.mermaid +35 -0
- qtype/docs/How To/Qtype Server/flow_as_ui.png +0 -0
- qtype/docs/How To/Qtype Server/serve_flows_as_apis.md +40 -0
- qtype/docs/How To/Qtype Server/serve_flows_as_ui.md +41 -0
- qtype/docs/How To/Qtype Server/use_conversational_interfaces.md +56 -0
- qtype/docs/How To/Qtype Server/use_variables_with_ui_hints.md +48 -0
- qtype/docs/How To/Tools & Integration/bind_tool_inputs_and_outputs.md +47 -0
- qtype/docs/How To/Tools & Integration/create_tools_from_openapi_specifications.md +85 -0
- qtype/docs/How To/Tools & Integration/create_tools_from_python_modules.md +87 -0
- qtype/docs/Reference/cli.md +336 -0
- qtype/docs/Reference/plugins.md +99 -0
- qtype/docs/Reference/semantic-validation-rules.md +184 -0
- qtype/docs/Tutorials/.pages +1 -0
- qtype/docs/Tutorials/01-first-qtype-application.md +249 -0
- qtype/docs/Tutorials/02-conversational-chatbot.md +327 -0
- qtype/docs/Tutorials/03-structured-data.md +480 -0
- qtype/docs/Tutorials/04-tools-and-function-calling.md +476 -0
- qtype/docs/Tutorials/example_chat.png +0 -0
- qtype/docs/Tutorials/index.md +92 -0
- qtype/docs/components/APIKeyAuthProvider.md +7 -0
- qtype/docs/components/APITool.md +10 -0
- qtype/docs/components/AWSAuthProvider.md +13 -0
- qtype/docs/components/AWSSecretManager.md +5 -0
- qtype/docs/components/Agent.md +6 -0
- qtype/docs/components/Aggregate.md +7 -0
- qtype/docs/components/AggregateStats.md +7 -0
- qtype/docs/components/Application.md +22 -0
- qtype/docs/components/AuthorizationProvider.md +6 -0
- qtype/docs/components/AuthorizationProviderList.md +5 -0
- qtype/docs/components/BearerTokenAuthProvider.md +6 -0
- qtype/docs/components/BedrockReranker.md +8 -0
- qtype/docs/components/ChatContent.md +7 -0
- qtype/docs/components/ChatMessage.md +6 -0
- qtype/docs/components/Collect.md +6 -0
- qtype/docs/components/ConstantPath.md +5 -0
- qtype/docs/components/Construct.md +6 -0
- qtype/docs/components/CustomType.md +7 -0
- qtype/docs/components/Decoder.md +8 -0
- qtype/docs/components/DecoderFormat.md +8 -0
- qtype/docs/components/DocToTextConverter.md +7 -0
- qtype/docs/components/Document.md +7 -0
- qtype/docs/components/DocumentEmbedder.md +6 -0
- qtype/docs/components/DocumentIndex.md +7 -0
- qtype/docs/components/DocumentSearch.md +7 -0
- qtype/docs/components/DocumentSource.md +12 -0
- qtype/docs/components/DocumentSplitter.md +9 -0
- qtype/docs/components/Echo.md +8 -0
- qtype/docs/components/Embedding.md +7 -0
- qtype/docs/components/EmbeddingModel.md +6 -0
- qtype/docs/components/Explode.md +5 -0
- qtype/docs/components/FieldExtractor.md +21 -0
- qtype/docs/components/FileSource.md +6 -0
- qtype/docs/components/FileWriter.md +7 -0
- qtype/docs/components/Flow.md +14 -0
- qtype/docs/components/FlowInterface.md +7 -0
- qtype/docs/components/Index.md +8 -0
- qtype/docs/components/IndexUpsert.md +6 -0
- qtype/docs/components/InvokeEmbedding.md +7 -0
- qtype/docs/components/InvokeFlow.md +8 -0
- qtype/docs/components/InvokeTool.md +8 -0
- qtype/docs/components/LLMInference.md +9 -0
- qtype/docs/components/ListType.md +5 -0
- qtype/docs/components/Memory.md +8 -0
- qtype/docs/components/MessageRole.md +14 -0
- qtype/docs/components/Model.md +10 -0
- qtype/docs/components/ModelList.md +5 -0
- qtype/docs/components/OAuth2AuthProvider.md +9 -0
- qtype/docs/components/PrimitiveTypeEnum.md +20 -0
- qtype/docs/components/PromptTemplate.md +7 -0
- qtype/docs/components/PythonFunctionTool.md +7 -0
- qtype/docs/components/RAGChunk.md +7 -0
- qtype/docs/components/RAGDocument.md +10 -0
- qtype/docs/components/RAGSearchResult.md +8 -0
- qtype/docs/components/Reranker.md +5 -0
- qtype/docs/components/SQLSource.md +8 -0
- qtype/docs/components/Search.md +7 -0
- qtype/docs/components/SearchResult.md +7 -0
- qtype/docs/components/SecretManager.md +7 -0
- qtype/docs/components/SecretReference.md +7 -0
- qtype/docs/components/Source.md +5 -0
- qtype/docs/components/Step.md +8 -0
- qtype/docs/components/TelemetrySink.md +9 -0
- qtype/docs/components/Tool.md +9 -0
- qtype/docs/components/ToolList.md +5 -0
- qtype/docs/components/TypeList.md +5 -0
- qtype/docs/components/Variable.md +8 -0
- qtype/docs/components/VariableList.md +5 -0
- qtype/docs/components/VectorIndex.md +7 -0
- qtype/docs/components/VectorSearch.md +6 -0
- qtype/docs/components/VertexAuthProvider.md +9 -0
- qtype/docs/components/Writer.md +5 -0
- qtype/docs/example_ui.png +0 -0
- qtype/docs/index.md +81 -0
- qtype/docs/legacy_how_tos/.pages +6 -0
- qtype/docs/legacy_how_tos/Configuration/modular-yaml.md +366 -0
- qtype/docs/legacy_how_tos/Configuration/phoenix_projects.png +0 -0
- qtype/docs/legacy_how_tos/Configuration/phoenix_traces.png +0 -0
- qtype/docs/legacy_how_tos/Configuration/reference-by-id.md +251 -0
- qtype/docs/legacy_how_tos/Configuration/telemetry-setup.md +259 -0
- qtype/docs/legacy_how_tos/Data Types/custom-types.md +52 -0
- qtype/docs/legacy_how_tos/Data Types/domain-types.md +113 -0
- qtype/docs/legacy_how_tos/Debugging/visualize-apps.md +147 -0
- qtype/docs/legacy_how_tos/Tools/api-tools.md +29 -0
- qtype/docs/legacy_how_tos/Tools/python-tools.md +299 -0
- qtype/docs/skills/architect/SKILL.md +188 -0
- qtype/docs/skills/architect/references/cheatsheet.md +198 -0
- qtype/docs/skills/architect/references/patterns.md +29 -0
- qtype/docs/stylesheets/extra.css +27 -0
- qtype/dsl/custom_types.py +2 -1
- qtype/dsl/linker.py +23 -7
- qtype/dsl/loader.py +3 -3
- qtype/dsl/model.py +181 -67
- qtype/examples/authentication/aws_authentication.qtype.yaml +63 -0
- qtype/examples/conversational_ai/hello_world_chat.qtype.yaml +43 -0
- qtype/examples/conversational_ai/simple_chatbot.qtype.yaml +40 -0
- qtype/examples/data_processing/athena_query.qtype.yaml +56 -0
- qtype/examples/data_processing/batch_inputs.csv +5 -0
- qtype/examples/data_processing/batch_processing.qtype.yaml +54 -0
- qtype/examples/data_processing/cache_step_results.qtype.yaml +78 -0
- qtype/examples/data_processing/collect_results.qtype.yaml +55 -0
- qtype/examples/data_processing/create_sample_db.py +129 -0
- qtype/examples/data_processing/dataflow_pipelines.qtype.yaml +108 -0
- qtype/examples/data_processing/decode_json.qtype.yaml +23 -0
- qtype/examples/data_processing/explode_items.qtype.yaml +25 -0
- qtype/examples/data_processing/invoke_other_flows.qtype.yaml +98 -0
- qtype/examples/data_processing/read_file.qtype.yaml +60 -0
- qtype/examples/data_processing/reviews.db +0 -0
- qtype/examples/data_processing/sample_article.txt +1 -0
- qtype/examples/data_processing/sample_documents.jsonl +5 -0
- qtype/examples/invoke_models/create_embeddings.qtype.yaml +28 -0
- qtype/examples/invoke_models/simple_llm_call.qtype.yaml +32 -0
- qtype/examples/language_features/include_raw.qtype.yaml +27 -0
- qtype/examples/language_features/optional_variables.qtype.yaml +32 -0
- qtype/examples/language_features/story_prompt.txt +6 -0
- qtype/examples/language_features/ui_hints.qtype.yaml +52 -0
- qtype/examples/legacy/bedrock/data_analysis_with_telemetry.qtype.yaml +169 -0
- qtype/examples/legacy/bedrock/hello_world.qtype.yaml +39 -0
- qtype/examples/legacy/bedrock/hello_world_chat.qtype.yaml +37 -0
- qtype/examples/legacy/bedrock/hello_world_chat_with_telemetry.qtype.yaml +40 -0
- qtype/examples/legacy/bedrock/hello_world_chat_with_thinking.qtype.yaml +40 -0
- qtype/examples/legacy/bedrock/hello_world_completion.qtype.yaml +41 -0
- qtype/examples/legacy/bedrock/hello_world_completion_with_auth.qtype.yaml +44 -0
- qtype/examples/legacy/bedrock/simple_agent_chat.qtype.yaml +46 -0
- qtype/examples/legacy/chat_with_langfuse.qtype.yaml +50 -0
- qtype/examples/legacy/data/customers.csv +6 -0
- qtype/examples/legacy/data_processor.qtype.yaml +48 -0
- qtype/examples/legacy/echo/debug_example.qtype.yaml +59 -0
- qtype/examples/legacy/echo/prompt.qtype.yaml +22 -0
- qtype/examples/legacy/echo/readme.md +29 -0
- qtype/examples/legacy/echo/test.qtype.yaml +26 -0
- qtype/examples/legacy/echo/video.qtype.yaml +20 -0
- qtype/examples/legacy/field_extractor_example.qtype.yaml +137 -0
- qtype/examples/legacy/multi_flow_example.qtype.yaml +125 -0
- qtype/examples/legacy/openai/hello_world_chat.qtype.yaml +43 -0
- qtype/examples/legacy/openai/hello_world_chat_with_telemetry.qtype.yaml +46 -0
- qtype/examples/legacy/qtype_plugin_example.py +51 -0
- qtype/examples/legacy/rag.qtype.yaml +207 -0
- qtype/examples/legacy/sample_data.txt +43 -0
- qtype/examples/legacy/time_utilities.qtype.yaml +64 -0
- qtype/examples/legacy/vertex/README.md +11 -0
- qtype/examples/legacy/vertex/hello_world_chat.qtype.yaml +36 -0
- qtype/examples/legacy/vertex/hello_world_completion.qtype.yaml +40 -0
- qtype/examples/legacy/vertex/hello_world_completion_with_auth.qtype.yaml +45 -0
- qtype/examples/observability_debugging/trace_with_opentelemetry.qtype.yaml +40 -0
- qtype/examples/research_assistant/research_assistant.qtype.yaml +94 -0
- qtype/examples/research_assistant/tavily.oas.yaml +722 -0
- qtype/examples/research_assistant/tavily.qtype.yaml +216 -0
- qtype/examples/tutorials/01_hello_world.qtype.yaml +48 -0
- qtype/examples/tutorials/02_conversational_chat.qtype.yaml +37 -0
- qtype/examples/tutorials/03_structured_data.qtype.yaml +130 -0
- qtype/examples/tutorials/04_tools_and_function_calling.qtype.yaml +89 -0
- qtype/interpreter/api.py +4 -1
- qtype/interpreter/base/base_step_executor.py +3 -1
- qtype/interpreter/base/stream_emitter.py +19 -13
- qtype/interpreter/conversions.py +7 -3
- qtype/interpreter/converters.py +142 -26
- qtype/interpreter/executors/agent_executor.py +2 -3
- qtype/interpreter/executors/aggregate_executor.py +3 -4
- qtype/interpreter/executors/construct_executor.py +15 -15
- qtype/interpreter/executors/doc_to_text_executor.py +1 -3
- qtype/interpreter/executors/field_extractor_executor.py +13 -12
- qtype/interpreter/executors/file_source_executor.py +21 -34
- qtype/interpreter/executors/file_writer_executor.py +4 -4
- qtype/interpreter/executors/index_upsert_executor.py +1 -1
- qtype/interpreter/executors/invoke_embedding_executor.py +1 -4
- qtype/interpreter/executors/invoke_flow_executor.py +2 -2
- qtype/interpreter/executors/invoke_tool_executor.py +19 -18
- qtype/interpreter/executors/llm_inference_executor.py +16 -18
- qtype/interpreter/executors/prompt_template_executor.py +1 -3
- qtype/interpreter/executors/sql_source_executor.py +1 -1
- qtype/interpreter/resource_cache.py +3 -1
- qtype/interpreter/rich_progress.py +6 -3
- qtype/interpreter/stream/chat/converter.py +25 -17
- qtype/interpreter/stream/chat/ui_request_to_domain_type.py +2 -2
- qtype/interpreter/tools/function_tool_helper.py +11 -10
- qtype/interpreter/types.py +89 -4
- qtype/interpreter/typing.py +35 -38
- qtype/mcp/__init__.py +0 -0
- qtype/mcp/server.py +722 -0
- qtype/schema/qtype.schema.json +4016 -0
- qtype/semantic/checker.py +20 -1
- qtype/semantic/generate.py +6 -9
- qtype/semantic/model.py +26 -33
- qtype/semantic/resolver.py +7 -0
- qtype/semantic/visualize.py +45 -53
- {qtype-0.1.11.dist-info → qtype-0.1.13.dist-info}/METADATA +65 -44
- qtype-0.1.13.dist-info/RECORD +352 -0
- {qtype-0.1.11.dist-info → qtype-0.1.13.dist-info}/WHEEL +1 -2
- qtype/application/facade.py +0 -177
- qtype-0.1.11.dist-info/RECORD +0 -142
- qtype-0.1.11.dist-info/top_level.txt +0 -1
- {qtype-0.1.11.dist-info → qtype-0.1.13.dist-info}/entry_points.txt +0 -0
- {qtype-0.1.11.dist-info → qtype-0.1.13.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
```
|
|
96
|
+
|
|
97
|
+
## See Also
|
|
98
|
+
|
|
99
|
+
- [CLI Reference](cli.md)
|
|
@@ -0,0 +1,184 @@
|
|
|
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]`
|
|
180
|
+
|
|
181
|
+
## See Also
|
|
182
|
+
|
|
183
|
+
- [Validate QType YAML](../How%20To/Observability%20%26%20Debugging/validate_qtype_yaml.md)
|
|
184
|
+
- [CLI Reference](cli.md)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
title: Tutorials
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# Your First QType Application
|
|
2
|
+
|
|
3
|
+
**Time:** 15 minutes
|
|
4
|
+
**Prerequisites:** None
|
|
5
|
+
**Example:** [`01_hello_world.qtype.yaml`](https://github.com/bazaarvoice/qtype/blob/main/examples/tutorials/01_hello_world.qtype.yaml)
|
|
6
|
+
|
|
7
|
+
**What you'll learn:** Build a working AI-powered question-answering application and understand the core concepts of QType.
|
|
8
|
+
|
|
9
|
+
**What you'll build:** A simple app that takes a question, sends it to an AI model, and returns an answer.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Part 1: Your First QType File (5 minutes)
|
|
14
|
+
|
|
15
|
+
### Create the File
|
|
16
|
+
|
|
17
|
+
Create a new file called `01_hello_world.qtype.yaml` and add:
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
id: 01_hello_world
|
|
21
|
+
description: My first QType application
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**What this means:**
|
|
25
|
+
|
|
26
|
+
- Every QType application starts with an `id` - a unique name for your app
|
|
27
|
+
- The `description` helps you remember what the app does (optional but helpful)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
### Add Your AI Model
|
|
32
|
+
|
|
33
|
+
Add these lines to your file:
|
|
34
|
+
|
|
35
|
+
```yaml
|
|
36
|
+
auths:
|
|
37
|
+
- type: api_key
|
|
38
|
+
id: openai_auth
|
|
39
|
+
api_key: ${OPENAI_KEY}
|
|
40
|
+
host: https://api.openai.com
|
|
41
|
+
|
|
42
|
+
models:
|
|
43
|
+
- type: Model
|
|
44
|
+
id: gpt-4
|
|
45
|
+
provider: openai
|
|
46
|
+
model_id: gpt-4-turbo
|
|
47
|
+
auth: openai_auth
|
|
48
|
+
inference_params:
|
|
49
|
+
temperature: 0.7
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**What this means:**
|
|
54
|
+
|
|
55
|
+
- `auths:` - different authorization credentials you will use for model invocation (if any)
|
|
56
|
+
- `api_key: ${OPENAI_KEY}` - the api key is read from the environment variable `OPENAI_KEY`
|
|
57
|
+
- `models:` - Where you configure which AI to use
|
|
58
|
+
- `id: gpt-4` - A nickname you'll use to refer to this model
|
|
59
|
+
- `model_id` - The provider's model id.
|
|
60
|
+
- `provider: openai` - Which AI service to use
|
|
61
|
+
- `temperature: 0.7` - Controls creativity (0 = focused, 1 = creative)
|
|
62
|
+
|
|
63
|
+
**Check your work:**
|
|
64
|
+
|
|
65
|
+
1. Save the file
|
|
66
|
+
2. Run: `qtype validate 01_hello_world.qtype.yaml`
|
|
67
|
+
4. You should see: `✅ Validation successful`
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
**Using AWS Bedrock instead?** Replace the models section with:
|
|
71
|
+
```yaml
|
|
72
|
+
models:
|
|
73
|
+
- type: Model
|
|
74
|
+
id: nova
|
|
75
|
+
provider: aws-bedrock
|
|
76
|
+
model_id: amazon.nova-lite-v1:0
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
And ensure your AWS credentials are configured (`aws configure`).
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Part 2: Add Processing Logic (5 minutes)
|
|
84
|
+
|
|
85
|
+
### Create a Flow
|
|
86
|
+
|
|
87
|
+
A "flow" is where you define what your app actually does. Add this to your file:
|
|
88
|
+
|
|
89
|
+
```yaml
|
|
90
|
+
flows:
|
|
91
|
+
- type: Flow
|
|
92
|
+
id: simple_example
|
|
93
|
+
variables:
|
|
94
|
+
- id: question
|
|
95
|
+
type: text
|
|
96
|
+
- id: formatted_prompt
|
|
97
|
+
type: text
|
|
98
|
+
- id: answer
|
|
99
|
+
type: text
|
|
100
|
+
inputs:
|
|
101
|
+
- question
|
|
102
|
+
outputs:
|
|
103
|
+
- answer
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**What this means:**
|
|
107
|
+
|
|
108
|
+
- `flows:` - The processing logic section
|
|
109
|
+
- `variables:` - Declares the data your app uses:
|
|
110
|
+
- `question` - What the user asks
|
|
111
|
+
- `formatted_prompt` - The formatted prompt for the AI
|
|
112
|
+
- `answer` - What the AI responds
|
|
113
|
+
- `inputs:` and `outputs:` - Which variables go in and out
|
|
114
|
+
|
|
115
|
+
**Check your work:**
|
|
116
|
+
|
|
117
|
+
1. Validate again: `qtype validate 01_hello_world.qtype.yaml`
|
|
118
|
+
2. Still should see: `✅ Validation successful`
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### Add Processing Steps
|
|
123
|
+
|
|
124
|
+
Now tell QType what to do with the question. Add this inside your flow (after `outputs:`):
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
steps:
|
|
128
|
+
- id: format_prompt
|
|
129
|
+
type: PromptTemplate
|
|
130
|
+
template: "You are a helpful assistant. Answer the following question:\n{question}\n"
|
|
131
|
+
inputs:
|
|
132
|
+
- question
|
|
133
|
+
outputs:
|
|
134
|
+
- formatted_prompt
|
|
135
|
+
|
|
136
|
+
- id: llm_step
|
|
137
|
+
type: LLMInference
|
|
138
|
+
model: gpt-4
|
|
139
|
+
inputs:
|
|
140
|
+
- formatted_prompt
|
|
141
|
+
outputs:
|
|
142
|
+
- answer
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**What this means:**
|
|
146
|
+
|
|
147
|
+
- `steps:` - The actual processing instructions
|
|
148
|
+
- **Step 1: PromptTemplate** - Formats your question into a proper prompt
|
|
149
|
+
- `template:` - Text with placeholders like `{question}`
|
|
150
|
+
- Takes the user's `question` and creates `formatted_prompt`
|
|
151
|
+
- **Step 2: LLMInference** - Sends the prompt to the AI
|
|
152
|
+
- `model: gpt-4` - Use the model we defined earlier
|
|
153
|
+
- Takes `formatted_prompt` and returns `answer`
|
|
154
|
+
|
|
155
|
+
**Why two steps?** Separating prompt formatting from AI inference makes your app more maintainable and testable.
|
|
156
|
+
|
|
157
|
+
**Check your work:**
|
|
158
|
+
|
|
159
|
+
1. Validate: `qtype validate 01_hello_world.qtype.yaml`
|
|
160
|
+
2. Should still pass ✅
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Part 3: Run Your Application (5 minutes)
|
|
165
|
+
|
|
166
|
+
### Set Up Authentication
|
|
167
|
+
|
|
168
|
+
Create a file called `.env` in the same folder:
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
OPENAI_KEY=sk-your-key-here
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Replace `sk-your-key-here` with your actual OpenAI API key.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
### Test It!
|
|
179
|
+
|
|
180
|
+
Run your application:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
qtype run -i '{"question":"What is 2+2?"}' 01_hello_world.qtype.yaml
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**What you should see:**
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"answer": "2+2 equals 4."
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Troubleshooting:**
|
|
194
|
+
|
|
195
|
+
- **"Authentication error"** → Check your API key in `.env`
|
|
196
|
+
- **"Model not found"** → Verify you have access to the model
|
|
197
|
+
- **"Variable not found"** → Check your indentation in the YAML file
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
### Try It With Different Questions
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# Simple math
|
|
205
|
+
qtype run -i '{"question":"What is the capital of France?"}' 01_hello_world.qtype.yaml
|
|
206
|
+
|
|
207
|
+
# More complex
|
|
208
|
+
qtype run -i '{"question":"Explain photosynthesis in one sentence"}' 01_hello_world.qtype.yaml
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## What You've Learned
|
|
214
|
+
|
|
215
|
+
Congratulations! You've learned:
|
|
216
|
+
|
|
217
|
+
✅ **Application structure** - Every QType app has an `id`
|
|
218
|
+
✅ **Models** - How to configure AI providers
|
|
219
|
+
✅ **Flows** - Where processing logic lives
|
|
220
|
+
✅ **Variables** - How data moves through your app
|
|
221
|
+
✅ **Steps** - Individual processing units (PromptTemplate, LLMInference)
|
|
222
|
+
✅ **Validation** - How to check your work before running
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Next Steps
|
|
227
|
+
|
|
228
|
+
**Reference the complete example:**
|
|
229
|
+
|
|
230
|
+
- [`01_hello_world.qtype.yaml`](https://github.com/bazaarvoice/qtype/blob/main/examples/tutorials/01_hello_world.qtype.yaml) - Full working example
|
|
231
|
+
|
|
232
|
+
**Learn more:**
|
|
233
|
+
|
|
234
|
+
- [Tutorial: Conversational Chatbot](02-conversational-chatbot.md)
|
|
235
|
+
- [Tutorial: Structured Data](03-structured-data.md)
|
|
236
|
+
- [Call Large Language Models](../How%20To/Invoke%20Models/call_large_language_models.md)
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Common Questions
|
|
241
|
+
|
|
242
|
+
**Q: Why do I need to declare variables?**
|
|
243
|
+
A: It makes data flow explicit and helps QType validate your app before running it.
|
|
244
|
+
|
|
245
|
+
**Q: Can I use multiple models in one app?**
|
|
246
|
+
A: Yes! Define multiple models in the `models:` section and reference them by their `id` in steps.
|
|
247
|
+
|
|
248
|
+
**Q: My validation passed but I get errors when running. Why?**
|
|
249
|
+
A: Validation checks structure, but runtime errors often involve authentication or model access. Check your API keys and model permissions.
|