QType Examples¶
Pattern: Simple Chatbot¶
Basic conversational interface with memory.
id: simple_chatbot
description: A friendly chatbot with conversation memory using AWS Bedrock
models:
- type: Model
id: nova_lite
provider: aws-bedrock
model_id: amazon.nova-lite-v1:0
inference_params:
temperature: 0.7
max_tokens: 512
memories:
- id: conversation_memory
token_limit: 10000
flows:
- type: Flow
id: chat_flow
interface:
type: Conversational
variables:
- id: user_message
type: ChatMessage
- id: assistant_response
type: ChatMessage
inputs:
- user_message
outputs:
- assistant_response
steps:
- id: generate_response
type: LLMInference
model: nova_lite
system_message: |
You are a friendly and helpful chatbot. You have a warm, conversational
tone and enjoy helping users with their questions. You remember context
from previous messages in the conversation.
memory: conversation_memory
inputs:
- user_message
outputs:
- assistant_response
Pattern: Tool-Based Research¶
Web search with synthesis using external tools.
# Research Assistant Example
#
# Takes one input (topic), searches the web via Tavily, then synthesizes
# an answer using an LLM call.
#
# Prereqs:
# - Set `TAVILY-API_BEARER` for Tavily auth (see tavily.qtype.yaml)
# - Configure AWS credentials if using Bedrock (default model below)
#
# Run with:
# qtype run \
# -i '{"topic":"Latest developments in retrieval augmented generation"}' \
# examples/research_assistant/research_assistant.qtype.yaml
id: research_assistant
description: Web search + synthesis research assistant using Tavily
# Import Tavily tools created from tavily.oas.yaml
references:
- !include ./tavily.qtype.yaml
models:
- type: Model
id: nova_lite
provider: aws-bedrock
model_id: amazon.nova-lite-v1:0
inference_params:
temperature: 0.3
max_tokens: 900
flows:
- type: Flow
id: research
description: Search the web for a topic and synthesize an answer
inputs:
- topic
outputs:
- answer
variables:
- id: topic
type: text
# Tavily outputs
- id: tavily_results
type:
element_type: schema_4844016144
# LLM prompt + response
- id: synthesis_prompt
type: text
- id: answer
type: text
steps:
- type: InvokeTool
id: search_web
tool: search
input_bindings:
query: topic
output_bindings:
results: tavily_results
outputs:
- tavily_results
- type: PromptTemplate
id: build_prompt
template: |
Research topic: {topic}
Search results (list of objects with url/content/score):
{tavily_results}
Task:
- Write a concise, well-structured answer to the research topic.
- If the results contain URLs, include 3-8 bullet citations at the end
using the URLs you relied on most.
- If information is missing or uncertain, say so explicitly.
inputs:
- topic
- tavily_results
outputs:
- synthesis_prompt
- type: LLMInference
id: synthesize
model: nova_lite
system_message: |
You are a careful research assistant. Use the provided search results.
Prefer accurate summaries over speculation.
inputs:
- synthesis_prompt
outputs:
- answer
Pattern: Data Pipeline with LLM Processing¶
Parallel processing of database records with LLM analysis.
id: review_analysis_pipeline
description: |
Automated product review analysis pipeline demonstrating dataflow processing.
Reads reviews from SQLite database, analyzes sentiment with LLM, and writes
enriched results to a Parquet file.
models:
- type: Model
id: nova_lite
provider: aws-bedrock
model_id: amazon.nova-lite-v1:0
inference_params:
temperature: 0.7
max_tokens: 256
flows:
- type: Flow
id: analyze_reviews
description: Batch process product reviews with LLM sentiment analysis
variables:
- id: review_id
type: int
- id: product_name
type: text
- id: rating
type: int
- id: review_text
type: text
- id: analysis_prompt
type: text
- id: llm_analysis
type: text
- id: output_path
type: text
- id: result_file
type: text
inputs:
- output_path
outputs:
- result_file
steps:
# Step 1: Read reviews from SQLite database
# SQLSource emits one message per database row
- id: load_reviews
type: SQLSource
connection: "sqlite:///examples/data_processing/reviews.db"
query: |
SELECT
review_id,
product_name,
rating,
review_text
FROM product_reviews
ORDER BY review_id
inputs: []
outputs:
- review_id
- product_name
- rating
- review_text
# Step 2: Format analysis prompt for each review
# PromptTemplate creates structured prompts from review data
- id: create_prompt
type: PromptTemplate
template: |
Analyze this product review in 1-2 sentences. Include:
- Overall sentiment (positive/negative/mixed)
- 2-3 key themes or points
Product: {product_name}
Rating: {rating}/5
Review: {review_text}
inputs:
- product_name
- rating
- review_text
outputs:
- analysis_prompt
# Step 3: Analyze each review with LLM
# LLMInference processes each message through the language model
- id: analyze_sentiment
type: LLMInference
model: nova_lite
inputs:
- analysis_prompt
outputs:
- llm_analysis
# Step 4: Write enriched results to Parquet file
# FileWriter batches all messages and writes once
- id: write_results
type: FileWriter
path: output_path
inputs:
- review_id
- product_name
- rating
- review_text
- llm_analysis
- output_path
outputs:
- result_file