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,52 @@
|
|
|
1
|
+
# Pass Inputs On The CLI
|
|
2
|
+
|
|
3
|
+
Provide input values to your QType flows directly from the command line using JSON-formatted input data, enabling dynamic parameterization of applications without modifying YAML files.
|
|
4
|
+
|
|
5
|
+
### CLI Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Pass a single input variable
|
|
9
|
+
qtype run -i '{"user_name":"Alice"}' app.qtype.yaml
|
|
10
|
+
|
|
11
|
+
# Pass multiple input variables
|
|
12
|
+
qtype run -i '{"model_id":"claude-3", "temperature":0.7}' app.qtype.yaml
|
|
13
|
+
|
|
14
|
+
# Pass complex nested structures
|
|
15
|
+
qtype run -i '{"config":{"max_tokens":1000,"top_p":0.9}}' app.qtype.yaml
|
|
16
|
+
|
|
17
|
+
# Specify which flow to run with inputs
|
|
18
|
+
qtype run -f analyze_data -i '{"threshold":0.85}' app.qtype.yaml
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Explanation
|
|
22
|
+
|
|
23
|
+
- **`-i`, `--input`**: Accepts a JSON blob containing key-value pairs where keys match variable names declared in your flow's `inputs` field
|
|
24
|
+
- **JSON format**: Must be valid JSON with double quotes for strings, properly escaped special characters
|
|
25
|
+
- **Flow inputs**: The variables must match those declared in the flow's `inputs` list or the application's `inputs` list
|
|
26
|
+
- **`-f`, `--flow`**: Specifies which flow to run when your application contains multiple flows (defaults to first flow if omitted)
|
|
27
|
+
|
|
28
|
+
## Complete Example
|
|
29
|
+
|
|
30
|
+
The [LLM Processing Pipelines](../../Gallery/dataflow_pipelines.md) example demonstrates passing the output file path as a CLI input:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Run the pipeline with a custom output path
|
|
34
|
+
qtype run -i '{"output_path":"results.parquet"}' \
|
|
35
|
+
--progress \
|
|
36
|
+
examples/data_processing/dataflow_pipelines.qtype.yaml
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The flow declares `output_path` in its inputs:
|
|
40
|
+
|
|
41
|
+
```yaml
|
|
42
|
+
flows:
|
|
43
|
+
- name: analyze_reviews
|
|
44
|
+
inputs:
|
|
45
|
+
- output_path # Receives value from CLI -i flag
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## See Also
|
|
49
|
+
|
|
50
|
+
- [Load Multiple Inputs from Files](load_multiple_inputs_from_files.md)
|
|
51
|
+
- [CLI Reference](../../Reference/cli.md)
|
|
52
|
+
- [Gallery: Dataflow Pipelines](../../Gallery/dataflow_pipelines.md)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Serve Applications with Auto-Reload
|
|
2
|
+
|
|
3
|
+
Enable automatic reloading of your application when YAML files change during development using the `--reload` flag.
|
|
4
|
+
|
|
5
|
+
### CLI Command
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
qtype serve --reload my_app.qtype.yaml
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Explanation
|
|
12
|
+
|
|
13
|
+
- **--reload**: Watches YAML files for changes and automatically restarts the server
|
|
14
|
+
- **Development workflow**: Edit your YAML file, save, and immediately see changes without manual restart
|
|
15
|
+
- **Port option**: Combine with `-p`/`--port` to specify server port (default: 8000)
|
|
16
|
+
|
|
17
|
+
### Example with Port
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
qtype serve --reload -p 8080 examples/tutorials/01_hello_world.qtype.yaml
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## See Also
|
|
24
|
+
|
|
25
|
+
- [Serve Flows as APIs](../Qtype%20Server/serve_flows_as_apis.md)
|
|
26
|
+
- [Serve Flows as UI](../Qtype%20Server/serve_flows_as_ui.md)
|
|
27
|
+
- [CLI Reference](../../Reference/cli.md)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Adjust Concurrency
|
|
2
|
+
|
|
3
|
+
Control parallel execution of steps to optimize throughput and resource usage using the `concurrency_config` parameter on steps that support concurrent processing.
|
|
4
|
+
|
|
5
|
+
### QType YAML
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
steps:
|
|
9
|
+
- type: LLMInference
|
|
10
|
+
id: classify
|
|
11
|
+
model: nova
|
|
12
|
+
concurrency_config:
|
|
13
|
+
num_workers: 10 # Process up to 10 items in parallel
|
|
14
|
+
inputs: [document]
|
|
15
|
+
outputs: [classification]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Explanation
|
|
19
|
+
|
|
20
|
+
- **concurrency_config**: Configuration object for concurrent processing with `num_workers` parameter
|
|
21
|
+
- **num_workers**: Maximum number of concurrent async workers for this step (default: 1)
|
|
22
|
+
|
|
23
|
+
### Steps Supporting Concurrency
|
|
24
|
+
|
|
25
|
+
The following step types support `concurrency_config`:
|
|
26
|
+
|
|
27
|
+
- **LLMInference**: Parallel LLM inference calls
|
|
28
|
+
- **InvokeEmbedding**: Parallel embedding generation
|
|
29
|
+
- **InvokeTool**: Parallel tool invocations
|
|
30
|
+
- **DocToTextConverter**: Parallel document conversion
|
|
31
|
+
- **DocumentSplitter**: Parallel document chunking
|
|
32
|
+
- **DocumentEmbedder**: Parallel chunk embedding
|
|
33
|
+
- **DocumentSearch**: Parallel search queries
|
|
34
|
+
- **BedrockReranker**: Parallel reranking operations
|
|
35
|
+
|
|
36
|
+
## See Also
|
|
37
|
+
|
|
38
|
+
- [Step Reference](../../components/Step.md)
|
|
39
|
+
- [Cache Step Results](cache_step_results.md)
|
|
40
|
+
- [Gallery: Dataflow Pipelines](../../Gallery/dataflow_pipelines.md)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Cache Step Results
|
|
2
|
+
|
|
3
|
+
Avoid redundant computation by caching step results on disk, enabling faster re-runs when processing the same inputs.
|
|
4
|
+
|
|
5
|
+
### QType YAML
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
steps:
|
|
9
|
+
- type: LLMInference
|
|
10
|
+
id: classify
|
|
11
|
+
model: nova
|
|
12
|
+
inputs: [prompt]
|
|
13
|
+
outputs: [category]
|
|
14
|
+
cache_config:
|
|
15
|
+
namespace: document_classification # Logical grouping for cached data
|
|
16
|
+
version: "1.0" # Change to invalidate cache
|
|
17
|
+
on_error: Drop # Don't cache errors (default)
|
|
18
|
+
ttl: 3600 # Cache for 1 hour (seconds)
|
|
19
|
+
compress: false # Optionally compress cached data
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Explanation
|
|
23
|
+
|
|
24
|
+
- **cache_config**: Enables step-level caching with configuration options
|
|
25
|
+
- **namespace**: Logical separation for cache entries (e.g., different projects or data domains)
|
|
26
|
+
- **version**: Cache version string - increment to invalidate all cached results for this step
|
|
27
|
+
- **on_error**: How to handle errors - `Drop` (don't cache errors, default) or `Cache` (cache error results)
|
|
28
|
+
- **ttl**: Time-to-live in seconds before cached entries expire
|
|
29
|
+
- **compress**: Whether to compress cached data (saves disk space, adds CPU overhead)
|
|
30
|
+
|
|
31
|
+
Cached values are stored in the `.qtype-cache/` directory in your working directory.
|
|
32
|
+
|
|
33
|
+
### Monitoring Cache Performance
|
|
34
|
+
|
|
35
|
+
Use the `--progress` flag to see cache hits and misses:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
qtype run app.qtype.yaml --flow my_flow --progress
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
First run shows cache misses:
|
|
42
|
+
```
|
|
43
|
+
Step classify ✔ 5 succeeded ✖ 0 errors ⟳ 0 hits ✗ 5 misses
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Subsequent runs show cache hits (much faster):
|
|
47
|
+
```
|
|
48
|
+
Step classify ✔ 5 succeeded ✖ 0 errors ⟳ 5 hits ✗ 0 misses
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Complete Example
|
|
52
|
+
|
|
53
|
+
```yaml
|
|
54
|
+
--8<-- "../examples/data_processing/cache_step_results.qtype.yaml"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Run the example:
|
|
58
|
+
```bash
|
|
59
|
+
# First run - cold cache
|
|
60
|
+
qtype run examples/data_processing/cache_step_results.qtype.yaml --progress -i '{"file_path": "examples/data_processing/sample_documents.jsonl"}'
|
|
61
|
+
|
|
62
|
+
# Second run - warm cache (much faster)
|
|
63
|
+
qtype run examples/data_processing/cache_step_results.qtype.yaml --progress -i '{"file_path": "examples/data_processing/sample_documents.jsonl"}'
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## See Also
|
|
68
|
+
|
|
69
|
+
- [Step Reference](../../components/Step.md)
|
|
70
|
+
- [Adjust Concurrency](adjust_concurrency.md)
|
|
71
|
+
- [Tutorial: Your First QType Application](../../Tutorials/01-first-qtype-application.md)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Decode JSON/XML to Structured Data
|
|
2
|
+
|
|
3
|
+
Parse string data in JSON or XML format into structured outputs. This is particularly useful for extracting structured data from llm outputs.
|
|
4
|
+
|
|
5
|
+
### QType YAML
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
--8<-- "../examples/data_processing/decode_json.qtype.yaml"
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Explanation
|
|
12
|
+
|
|
13
|
+
- **Decoder**: Step that parses string data (JSON or XML) into structured outputs
|
|
14
|
+
- **format**: The data format to parse - `json` (default) or `xml`
|
|
15
|
+
- **inputs**: String variable containing the encoded data to decode
|
|
16
|
+
- **outputs**: List of variables to extract from the decoded data (field names must match keys in the JSON/XML)
|
|
17
|
+
- **Error handling**: If parsing fails, the step raises returns an error
|
|
18
|
+
- **Markdown cleanup**: Automatically strips markdown code fences (```json, ```xml) if present in the input
|
|
19
|
+
|
|
20
|
+
## See Also
|
|
21
|
+
|
|
22
|
+
- [Decoder Reference](../../components/Decoder.md)
|
|
23
|
+
- [CustomType Reference](../../components/CustomType.md)
|
|
24
|
+
- [Tutorial: Structured Data](../../Tutorials/03-structured-data.md)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Fan-Out Collections with Explode
|
|
2
|
+
|
|
3
|
+
Transform a single list input into multiple outputs, one per item, enabling parallel processing of collection elements.
|
|
4
|
+
|
|
5
|
+
### QType YAML
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
steps:
|
|
9
|
+
- type: Explode
|
|
10
|
+
id: fan_out
|
|
11
|
+
inputs:
|
|
12
|
+
- items # Variable of type list[T]
|
|
13
|
+
outputs:
|
|
14
|
+
- item # Variable of type T
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Explanation
|
|
18
|
+
|
|
19
|
+
- **Explode**: Takes a single list and yields one output message per item
|
|
20
|
+
- **inputs**: Must be a single variable of type `list[T]`
|
|
21
|
+
- **outputs**: Single variable of the item type `T` (unwrapped from the list)
|
|
22
|
+
- **Fan-out pattern**: Each item is processed independently by downstream steps
|
|
23
|
+
|
|
24
|
+
## Complete Example
|
|
25
|
+
|
|
26
|
+
```yaml
|
|
27
|
+
--8<-- "../examples/data_processing/explode_items.qtype.yaml"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Run it:**
|
|
31
|
+
```bash
|
|
32
|
+
qtype run examples/data_processing/explode_items.qtype.yaml \
|
|
33
|
+
-i '{"items": ["apple", "banana", "cherry"]}'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## See Also
|
|
37
|
+
|
|
38
|
+
- [Gather Results into a List](gather_results.md)
|
|
39
|
+
- [Explode Reference](../../components/Explode.md)
|
|
40
|
+
- [Adjust Concurrency](adjust_concurrency.md)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Gather Results into a List
|
|
2
|
+
|
|
3
|
+
Combine fan-out processing results into a single list while preserving variables that have the same value across all messages (common ancestors).
|
|
4
|
+
|
|
5
|
+
### QType YAML
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
variables:
|
|
9
|
+
- id: processed_product
|
|
10
|
+
type: text
|
|
11
|
+
- id: all_processed
|
|
12
|
+
type: list[text]
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- type: Collect
|
|
16
|
+
id: aggregate
|
|
17
|
+
inputs: [processed_product]
|
|
18
|
+
outputs: [all_processed]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Explanation
|
|
22
|
+
|
|
23
|
+
- **Collect**: Gathers all input values from multiple messages into a single list output
|
|
24
|
+
- **Common ancestors**: Only variables that have the exact same value across ALL input messages are preserved in the output message
|
|
25
|
+
- **Fan-out pattern**: Typically used after `Explode` to reverse the fan-out and accumulate results
|
|
26
|
+
- **Single output**: Always produces exactly one output message containing the accumulate list
|
|
27
|
+
|
|
28
|
+
### Understanding Common Ancestors
|
|
29
|
+
|
|
30
|
+
If you have these three messages flowing into `Collect`:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
Message 1: {category: "Electronics", region: "US", product: "Phone", processed: "Processed: Phone"}
|
|
34
|
+
Message 2: {category: "Electronics", region: "US", product: "Laptop", processed: "Processed: Laptop"}
|
|
35
|
+
Message 3: {category: "Electronics", region: "US", product: "Tablet", processed: "Processed: Tablet"}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The `Collect` step will output:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
{category: "Electronics", region: "US", all_processed: ["Processed: Phone", "Processed: Laptop", "Processed: Tablet"]}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Note that `product` is **not preserved** because it has different values across the messages. Only `category` and `region` (which are identical in all three messages) are included as common ancestors.
|
|
45
|
+
|
|
46
|
+
## Complete Example
|
|
47
|
+
|
|
48
|
+
```yaml
|
|
49
|
+
--8<-- "../examples/data_processing/collect_results.qtype.yaml"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Run the example:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
qtype run examples/data_processing/collect_results.qtype.yaml \
|
|
56
|
+
-i '{"category": "Electronics", "region": "US", "products": ["Phone", "Laptop", "Tablet"]}'
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Output:
|
|
60
|
+
```
|
|
61
|
+
all_processed: ['Processed: Phone', 'Processed: Laptop', 'Processed: Tablet']
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## See Also
|
|
65
|
+
|
|
66
|
+
- [Explode Collections](explode_collections.md)
|
|
67
|
+
- [Collect Reference](../../components/Collect.md)
|
|
68
|
+
- [Aggregate Reference](../../components/Aggregate.md)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Invoke Other Flows
|
|
2
|
+
|
|
3
|
+
Reuse flows as composable building blocks by invoking them from other flows with input and output bindings.
|
|
4
|
+
|
|
5
|
+
### QType YAML
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
flows:
|
|
9
|
+
# Define reusable flow
|
|
10
|
+
- type: Flow
|
|
11
|
+
id: summarize_text
|
|
12
|
+
variables:
|
|
13
|
+
- id: input_text
|
|
14
|
+
type: text
|
|
15
|
+
- id: output_summary
|
|
16
|
+
type: text
|
|
17
|
+
inputs: [input_text]
|
|
18
|
+
outputs: [output_summary]
|
|
19
|
+
steps:
|
|
20
|
+
- type: LLMInference
|
|
21
|
+
id: summarizer
|
|
22
|
+
model: my_model
|
|
23
|
+
inputs: [input_text]
|
|
24
|
+
outputs: [output_summary]
|
|
25
|
+
|
|
26
|
+
# Main flow invokes the reusable flow
|
|
27
|
+
- type: Flow
|
|
28
|
+
id: main
|
|
29
|
+
variables:
|
|
30
|
+
- id: article
|
|
31
|
+
type: text
|
|
32
|
+
- id: summary
|
|
33
|
+
type: text
|
|
34
|
+
inputs: [article]
|
|
35
|
+
outputs: [summary]
|
|
36
|
+
steps:
|
|
37
|
+
- type: InvokeFlow
|
|
38
|
+
id: get_summary
|
|
39
|
+
flow: summarize_text # Reference to flow by ID
|
|
40
|
+
input_bindings:
|
|
41
|
+
input_text: article # Map flow input to step variable
|
|
42
|
+
output_bindings:
|
|
43
|
+
output_summary: summary # Map flow output to step variable
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Explanation
|
|
47
|
+
|
|
48
|
+
- **InvokeFlow**: Step type that executes another flow with variable mapping
|
|
49
|
+
- **flow**: ID of the flow to invoke (must be defined in the application)
|
|
50
|
+
- **input_bindings**: Maps flow input variables to the invoking step's variables (format: `flow_input_name: step_variable_name`)
|
|
51
|
+
- **output_bindings**: Maps flow output variables to the invoking step's variables (format: `flow_output_name: step_variable_name`)
|
|
52
|
+
- **Reusability**: Flows can be invoked multiple times with different bindings
|
|
53
|
+
|
|
54
|
+
## Complete Example
|
|
55
|
+
|
|
56
|
+
```yaml
|
|
57
|
+
--8<-- "../examples/data_processing/invoke_other_flows.qtype.yaml"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Run it:**
|
|
61
|
+
```bash
|
|
62
|
+
qtype run examples/data_processing/invoke_other_flows.qtype.yaml \
|
|
63
|
+
--flow main \
|
|
64
|
+
--input '{"article_text": "Your article text here..."}'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## See Also
|
|
68
|
+
|
|
69
|
+
- [InvokeFlow Reference](../../components/InvokeFlow.md)
|
|
70
|
+
- [Flow Reference](../../components/Flow.md)
|
|
71
|
+
- [Use Agent Skills](../Language%20Features/use_agent_skills.md)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Load Data from Athena
|
|
2
|
+
|
|
3
|
+
Query AWS Athena databases using standard SQL with the `SQLSource` step, which supports Athena through SQLAlchemy connection strings and AWS authentication.
|
|
4
|
+
|
|
5
|
+
### QType YAML
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
flows:
|
|
9
|
+
- id: query-athena
|
|
10
|
+
steps:
|
|
11
|
+
- type: SQLSource
|
|
12
|
+
id: load_sales
|
|
13
|
+
connection: "awsathena+rest://:@athena.us-east-1.amazonaws.com:443/sales_db?s3_staging_dir=s3://my-results-bucket/athena-results/&work_group=primary&catalog_name=some_catalog"
|
|
14
|
+
query: |
|
|
15
|
+
SELECT
|
|
16
|
+
product_id,
|
|
17
|
+
product_name,
|
|
18
|
+
total_sales
|
|
19
|
+
FROM product_sales
|
|
20
|
+
WHERE total_sales >= :min_sales
|
|
21
|
+
ORDER BY total_sales DESC
|
|
22
|
+
inputs:
|
|
23
|
+
- min_sales
|
|
24
|
+
outputs:
|
|
25
|
+
- product_id
|
|
26
|
+
- product_name
|
|
27
|
+
- total_sales
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Explanation
|
|
31
|
+
|
|
32
|
+
- **awsathena+rest**: PyAthena SQLAlchemy dialect for accessing Athena via REST API
|
|
33
|
+
- **Connection string format**: `awsathena+rest://:@athena.{REGION}.amazonaws.com:443/{DATABASE}?s3_staging_dir={S3_PATH}&work_group={WORKGROUP}&catalog_name={CATALOG}"`
|
|
34
|
+
- **s3_staging_dir**: S3 location where Athena writes query results (required by Athena)
|
|
35
|
+
- **work_group**: Athena workgroup name (e.g., `primary`)
|
|
36
|
+
- **auth**: Reference to AWSAuthProvider for AWS credentials
|
|
37
|
+
- **query**: Standard SQL query with parameter substitution using `:parameter_name` syntax
|
|
38
|
+
|
|
39
|
+
## Complete Example
|
|
40
|
+
|
|
41
|
+
```yaml
|
|
42
|
+
--8<-- "../examples/data_processing/athena_query.qtype.yaml"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## See Also
|
|
46
|
+
|
|
47
|
+
- [SQLSource Reference](../../components/SQLSource.md)
|
|
48
|
+
- [Configure AWS Authentication](../Authentication/configure_aws_authentication.md)
|
|
49
|
+
- [Read Data from SQL Databases](read_sql_databases.md)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Read Data from Files
|
|
2
|
+
|
|
3
|
+
Load structured data from files using FileSource, which supports CSV, JSON, JSONL, and Parquet formats with automatic format detection and type conversion.
|
|
4
|
+
|
|
5
|
+
### QType YAML
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
steps:
|
|
9
|
+
- id: read_data
|
|
10
|
+
type: FileSource
|
|
11
|
+
path: batch_inputs.csv
|
|
12
|
+
outputs:
|
|
13
|
+
- query
|
|
14
|
+
- topic
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Explanation
|
|
18
|
+
|
|
19
|
+
- **FileSource**: Step that reads structured data from files using fsspec-compatible URIs
|
|
20
|
+
- **path**: File path (relative to YAML file or absolute), supports local files and cloud storage (s3://, gs://, etc.)
|
|
21
|
+
- **outputs**: Column names from the file to extract as variables (must match actual column names)
|
|
22
|
+
- **Format detection**: Automatically determined by file extension (.csv, .json, .jsonl, .parquet)
|
|
23
|
+
- **Type conversion**: Automatically converts data to match variable types (primitives, domain types, custom types)
|
|
24
|
+
- **Streaming**: Emits one FlowMessage per row, enabling downstream steps to process data in parallel
|
|
25
|
+
|
|
26
|
+
### Automatic Type Conversion
|
|
27
|
+
|
|
28
|
+
FileSource automatically converts data from files to match your variable types:
|
|
29
|
+
|
|
30
|
+
- **Primitive types** (`int`, `float`, `bool`, `text`): Direct conversion from file data
|
|
31
|
+
- **Domain types** (`ChatMessage`, `SearchResult`, etc.): Validated from dict/object columns
|
|
32
|
+
- **Custom types**: Your defined types are validated and instantiated from dict/object columns
|
|
33
|
+
|
|
34
|
+
**Format Recommendations:**
|
|
35
|
+
|
|
36
|
+
- **CSV**: Best for simple primitive types (strings, numbers, booleans)
|
|
37
|
+
- **JSON/JSONL**: Recommended for nested objects, custom types, and domain types
|
|
38
|
+
- **Parquet**: Best for large datasets with mixed types and efficient storage
|
|
39
|
+
|
|
40
|
+
**Example with Custom Types (JSON format):**
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
[
|
|
44
|
+
{"person": {"name": "Alice", "age": 30}, "score": 95},
|
|
45
|
+
{"person": {"name": "Bob", "age": 25}, "score": 87}
|
|
46
|
+
]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
JSON preserves nested objects, making it ideal for complex types. CSV stores everything as strings, requiring nested objects to be serialized as JSON strings within the CSV.
|
|
50
|
+
|
|
51
|
+
## Complete Example
|
|
52
|
+
|
|
53
|
+
```yaml
|
|
54
|
+
--8<-- "../examples/data_processing/read_file.qtype.yaml"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## See Also
|
|
58
|
+
|
|
59
|
+
- [FileSource Reference](../../components/FileSource.md)
|
|
60
|
+
- [Load Multiple Inputs from Files](../Command%20Line%20Usage/load_multiple_inputs_from_files.md)
|
|
61
|
+
- [Write Data to File](write_data_to_file.md)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Read Data from SQL Databases
|
|
2
|
+
|
|
3
|
+
Query relational databases and process results row-by-row using the `SQLSource` step, which supports any database accessible via SQLAlchemy connection strings.
|
|
4
|
+
|
|
5
|
+
### QType YAML
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
steps:
|
|
9
|
+
- type: SQLSource
|
|
10
|
+
id: load_reviews
|
|
11
|
+
connection: "sqlite:///data/reviews.db"
|
|
12
|
+
query: |
|
|
13
|
+
SELECT
|
|
14
|
+
review_id,
|
|
15
|
+
product_name,
|
|
16
|
+
rating,
|
|
17
|
+
review_text
|
|
18
|
+
FROM product_reviews
|
|
19
|
+
WHERE rating >= 4
|
|
20
|
+
ORDER BY review_id
|
|
21
|
+
outputs:
|
|
22
|
+
- review_id
|
|
23
|
+
- product_name
|
|
24
|
+
- rating
|
|
25
|
+
- review_text
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Explanation
|
|
29
|
+
|
|
30
|
+
- **SQLSource**: Step type that executes SQL queries and emits one message per database row
|
|
31
|
+
- **connection**: SQLAlchemy-format connection string (e.g., `sqlite:///path.db`, `postgresql://user:pass@host/db`)
|
|
32
|
+
- **query**: SQL query to execute; column names must match output variable IDs
|
|
33
|
+
- **outputs**: Variables to populate from query result columns (order must match SELECT clause)
|
|
34
|
+
- **auth**: Optional reference to AuthorizationProvider for database credentials
|
|
35
|
+
|
|
36
|
+
## Complete Example
|
|
37
|
+
|
|
38
|
+
```yaml
|
|
39
|
+
--8<-- "../examples/data_processing/dataflow_pipelines.qtype.yaml"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## See Also
|
|
43
|
+
|
|
44
|
+
- [SQLSource Reference](../../components/SQLSource.md)
|
|
45
|
+
- [Load Data from Athena](load_data_from_athena.md)
|
|
46
|
+
- [Read Data from Files](read_data_from_files.md)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Write Data to a File
|
|
2
|
+
|
|
3
|
+
Write flow data to files using the `FileWriter` step, which accumulates all messages and outputs data in Parquet format using fsspec-compatible URIs.
|
|
4
|
+
|
|
5
|
+
### QType YAML
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
steps:
|
|
9
|
+
- type: FileWriter
|
|
10
|
+
id: write_results
|
|
11
|
+
path: output_path # Variable containing file path
|
|
12
|
+
inputs:
|
|
13
|
+
- review_id
|
|
14
|
+
- product_name
|
|
15
|
+
- rating
|
|
16
|
+
- llm_analysis
|
|
17
|
+
- output_path
|
|
18
|
+
outputs:
|
|
19
|
+
- result_file
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Explanation
|
|
23
|
+
|
|
24
|
+
- **FileWriter**: Batches all incoming messages and writes them as a single Parquet file
|
|
25
|
+
- **path**: fsspec-compatible URI (can be a `ConstantPath`, Variable reference, or string) for the output file location
|
|
26
|
+
- **inputs**: Variables from FlowMessages to include as columns in the output file
|
|
27
|
+
- **outputs**: Variable containing the path where data was written (useful for passing to downstream steps)
|
|
28
|
+
- **batch_config**: Optional configuration for batch size. This defaults to max_int (i.e., processes all messages into one file). If you change it, you will get multiple files.
|
|
29
|
+
|
|
30
|
+
## Complete Example
|
|
31
|
+
See the [LLM Processing Pipelines](../../Gallery/dataflow_pipelines.md) gallery example.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## See Also
|
|
36
|
+
|
|
37
|
+
- [FileWriter Reference](../../components/FileWriter.md)
|
|
38
|
+
- [Read Data from Files](read_data_from_files.md)
|
|
39
|
+
- [Gallery: Dataflow Pipelines](../../Gallery/dataflow_pipelines.md)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Call Large Language Models
|
|
2
|
+
|
|
3
|
+
Send text input to an LLM and receive a response using the `LLMInference` step with a system message and configurable model parameters like temperature and max_tokens.
|
|
4
|
+
|
|
5
|
+
### QType YAML
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
models:
|
|
9
|
+
- type: Model
|
|
10
|
+
id: nova_lite
|
|
11
|
+
provider: aws-bedrock
|
|
12
|
+
model_id: amazon.nova-lite-v1:0
|
|
13
|
+
inference_params:
|
|
14
|
+
temperature: 0.7
|
|
15
|
+
max_tokens: 500
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- type: LLMInference
|
|
19
|
+
id: assistant
|
|
20
|
+
model: nova_lite
|
|
21
|
+
system_message: "You are a helpful assistant"
|
|
22
|
+
inputs: [text]
|
|
23
|
+
outputs: [response]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Explanation
|
|
27
|
+
|
|
28
|
+
- **model**: Reference to a Model resource defining the LLM provider and model ID
|
|
29
|
+
- **inference_params**: Configuration for model behavior (temperature, max_tokens, top_p, etc.)
|
|
30
|
+
- **temperature**: Controls randomness (0.0 = deterministic, 1.0 = creative)
|
|
31
|
+
- **max_tokens**: Maximum number of tokens in the response
|
|
32
|
+
- **system_message**: Sets the assistant's persona and instructions for all requests
|
|
33
|
+
- **inputs**: Variables containing the user's text input to the LLM
|
|
34
|
+
- **outputs**: Variables where the LLM's response will be stored (must be type `text` or `ChatMessage`)
|
|
35
|
+
|
|
36
|
+
## Complete Example
|
|
37
|
+
|
|
38
|
+
```yaml
|
|
39
|
+
--8<-- "../examples/invoke_models/simple_llm_call.qtype.yaml"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Run with:
|
|
43
|
+
```bash
|
|
44
|
+
qtype run simple_llm_call.qtype.yaml --input '{"text": "What is the capital of France?"}'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## See Also
|
|
48
|
+
|
|
49
|
+
- [LLMInference Reference](../../components/LLMInference.md)
|
|
50
|
+
- [Model Reference](../../components/Model.md)
|
|
51
|
+
- [Tutorial: Conversational Chatbot](../../Tutorials/02-conversational-chatbot.md)
|