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,207 @@
|
|
|
1
|
+
id: rag_example
|
|
2
|
+
description: |
|
|
3
|
+
End-to-end RAG (Retrieval Augmented Generation) example that processes documents
|
|
4
|
+
into a Qdrant vector store and enables conversational chat with the indexed content.
|
|
5
|
+
|
|
6
|
+
This example includes two flows:
|
|
7
|
+
|
|
8
|
+
1. rag_chat: Chat with your documents using RAG
|
|
9
|
+
- Accept user questions as ChatMessage
|
|
10
|
+
- Extract text content from chat message using FieldExtractor
|
|
11
|
+
- Search vector index for relevant context using VectorSearch
|
|
12
|
+
- Generate contextual responses using Amazon Nova Lite
|
|
13
|
+
- Maintain conversation history with memory
|
|
14
|
+
|
|
15
|
+
2. document_ingestion: Ingest documents into the vector store
|
|
16
|
+
- Load LlamaIndex Q&A pairs from HuggingFace (1235 instruction-output pairs)
|
|
17
|
+
- Uses AlignmentLab-AI/llama-index dataset via HuggingFaceFSReader
|
|
18
|
+
- Split documents into manageable chunks
|
|
19
|
+
- Generate embeddings using AWS Bedrock Titan Embed Text v2
|
|
20
|
+
- Store embedded chunks in Qdrant vector database using IndexUpsert
|
|
21
|
+
|
|
22
|
+
Prerequisites:
|
|
23
|
+
- AWS credentials configured (via AWS CLI profile or environment variables)
|
|
24
|
+
- Qdrant running locally on port 6333 (or update the index args for Qdrant Cloud)
|
|
25
|
+
- Python dependencies: llama-index-readers-huggingface-fs (install with: uv add llama-index-readers-huggingface-fs --optional interpreter)
|
|
26
|
+
|
|
27
|
+
To run ingestion:
|
|
28
|
+
uv run python -m qtype.cli run examples/rag.qtype.yaml --flow document_ingestion
|
|
29
|
+
|
|
30
|
+
To start chat:
|
|
31
|
+
uv run python -m qtype.cli run examples/rag.qtype.yaml --flow rag_chat
|
|
32
|
+
|
|
33
|
+
# AWS Authentication for Bedrock
|
|
34
|
+
auths:
|
|
35
|
+
- type: aws
|
|
36
|
+
id: aws_auth
|
|
37
|
+
profile_name: ${AWS_PROFILE} # Uses AWS_PROFILE env var
|
|
38
|
+
|
|
39
|
+
# Models
|
|
40
|
+
models:
|
|
41
|
+
# Embedding model using AWS Bedrock Titan v2
|
|
42
|
+
- type: EmbeddingModel
|
|
43
|
+
id: titan_embed_v2
|
|
44
|
+
provider: aws-bedrock
|
|
45
|
+
model_id: amazon.titan-embed-text-v2:0
|
|
46
|
+
dimensions: 1024
|
|
47
|
+
auth: aws_auth
|
|
48
|
+
|
|
49
|
+
# Generative model for chat
|
|
50
|
+
- type: Model
|
|
51
|
+
id: claude_sonnet
|
|
52
|
+
provider: aws-bedrock
|
|
53
|
+
model_id: amazon.nova-lite-v1:0
|
|
54
|
+
inference_params:
|
|
55
|
+
temperature: 0.7
|
|
56
|
+
max_tokens: 2048
|
|
57
|
+
auth: aws_auth
|
|
58
|
+
|
|
59
|
+
# Qdrant vector index for storing embedded documents
|
|
60
|
+
indexes:
|
|
61
|
+
- type: VectorIndex
|
|
62
|
+
module: llama_index.vector_stores.qdrant.QdrantVectorStore
|
|
63
|
+
id: rag_index
|
|
64
|
+
name: documents
|
|
65
|
+
embedding_model: titan_embed_v2
|
|
66
|
+
args:
|
|
67
|
+
# Qdrant vector store arguments.
|
|
68
|
+
# See https://developers.llamaindex.ai/python/framework-api-reference/storage/vector_store/qdrant/
|
|
69
|
+
collection_name: documents
|
|
70
|
+
url: http://localhost:6333
|
|
71
|
+
api_key: "" # Empty string for local Qdrant (library validation bug requires this)
|
|
72
|
+
|
|
73
|
+
# Flow to ingest documents into the vector store
|
|
74
|
+
flows:
|
|
75
|
+
# Flow for conversational RAG
|
|
76
|
+
- type: Flow
|
|
77
|
+
id: rag_chat
|
|
78
|
+
description: Chat with the document collection using RAG
|
|
79
|
+
|
|
80
|
+
interface:
|
|
81
|
+
type: Conversational
|
|
82
|
+
|
|
83
|
+
variables:
|
|
84
|
+
- id: user_message
|
|
85
|
+
type: ChatMessage
|
|
86
|
+
- id: user_question
|
|
87
|
+
type: text
|
|
88
|
+
- id: search_results
|
|
89
|
+
type: list[RAGSearchResult]
|
|
90
|
+
- id: context_prompt
|
|
91
|
+
type: text
|
|
92
|
+
- id: assistant_response
|
|
93
|
+
type: ChatMessage
|
|
94
|
+
|
|
95
|
+
inputs:
|
|
96
|
+
- user_message
|
|
97
|
+
|
|
98
|
+
outputs:
|
|
99
|
+
- assistant_response
|
|
100
|
+
|
|
101
|
+
steps:
|
|
102
|
+
# Step 1: Extract text content from chat message blocks where type is text
|
|
103
|
+
- id: extract_question
|
|
104
|
+
type: FieldExtractor
|
|
105
|
+
json_path: "$.blocks[?(@.type == 'text')].content"
|
|
106
|
+
inputs:
|
|
107
|
+
- user_message
|
|
108
|
+
outputs:
|
|
109
|
+
- user_question
|
|
110
|
+
|
|
111
|
+
# Step 2: Search the vector index for relevant chunks (VectorSearch handles embedding internally)
|
|
112
|
+
- id: search_index
|
|
113
|
+
type: VectorSearch
|
|
114
|
+
index: rag_index
|
|
115
|
+
default_top_k: 5
|
|
116
|
+
inputs:
|
|
117
|
+
- user_question
|
|
118
|
+
outputs:
|
|
119
|
+
- search_results
|
|
120
|
+
|
|
121
|
+
# Step 3: Build context prompt with retrieved chunks
|
|
122
|
+
- id: build_prompt
|
|
123
|
+
type: PromptTemplate
|
|
124
|
+
template: |
|
|
125
|
+
You are a helpful assistant that answers questions based on the provided context.
|
|
126
|
+
|
|
127
|
+
Context from documents:
|
|
128
|
+
{search_results}
|
|
129
|
+
|
|
130
|
+
User question: {user_question}
|
|
131
|
+
|
|
132
|
+
Please provide a detailed answer based on the context above. If the context doesn't contain relevant information, say so.
|
|
133
|
+
inputs:
|
|
134
|
+
- search_results
|
|
135
|
+
- user_question
|
|
136
|
+
outputs:
|
|
137
|
+
- context_prompt
|
|
138
|
+
|
|
139
|
+
# Step 4: Generate response using LLM with context
|
|
140
|
+
- id: generate_response
|
|
141
|
+
type: LLMInference
|
|
142
|
+
model: claude_sonnet
|
|
143
|
+
system_message: "You are a helpful assistant that answers questions based on provided document context. Be concise and accurate."
|
|
144
|
+
inputs:
|
|
145
|
+
- context_prompt
|
|
146
|
+
outputs:
|
|
147
|
+
- assistant_response
|
|
148
|
+
|
|
149
|
+
- type: Flow
|
|
150
|
+
id: document_ingestion
|
|
151
|
+
description: Load LlamaIndex Q&A pairs from HuggingFace, split, embed, and index documents
|
|
152
|
+
|
|
153
|
+
variables:
|
|
154
|
+
- id: raw_document
|
|
155
|
+
type: RAGDocument
|
|
156
|
+
- id: document_chunk
|
|
157
|
+
type: RAGChunk
|
|
158
|
+
- id: embedded_chunk
|
|
159
|
+
type: RAGChunk
|
|
160
|
+
|
|
161
|
+
outputs:
|
|
162
|
+
- embedded_chunk
|
|
163
|
+
|
|
164
|
+
steps:
|
|
165
|
+
# Step 1: Load documents directly from HuggingFace using HuggingFaceFSReader
|
|
166
|
+
# This dataset contains 1235 LlamaIndex instruction-output Q&A pairs
|
|
167
|
+
- id: load_documents
|
|
168
|
+
type: DocumentSource
|
|
169
|
+
reader_module: llama_index.readers.huggingface_fs.HuggingFaceFSReader
|
|
170
|
+
loader_args:
|
|
171
|
+
path: "datasets/AlignmentLab-AI/llama-index/modified_dataset.jsonl"
|
|
172
|
+
outputs:
|
|
173
|
+
- raw_document
|
|
174
|
+
|
|
175
|
+
# Step 2: Split documents into chunks
|
|
176
|
+
- id: split_documents
|
|
177
|
+
type: DocumentSplitter
|
|
178
|
+
splitter_name: "SentenceSplitter"
|
|
179
|
+
chunk_size: 512
|
|
180
|
+
chunk_overlap: 50
|
|
181
|
+
inputs:
|
|
182
|
+
- raw_document
|
|
183
|
+
outputs:
|
|
184
|
+
- document_chunk
|
|
185
|
+
|
|
186
|
+
# Step 3: Generate embeddings for each chunk
|
|
187
|
+
- id: embed_chunks
|
|
188
|
+
type: DocumentEmbedder
|
|
189
|
+
model: titan_embed_v2
|
|
190
|
+
concurrency_config:
|
|
191
|
+
num_workers: 5
|
|
192
|
+
inputs:
|
|
193
|
+
- document_chunk
|
|
194
|
+
outputs:
|
|
195
|
+
- embedded_chunk
|
|
196
|
+
|
|
197
|
+
# Step 4: Upsert embedded chunks into Qdrant
|
|
198
|
+
- id: index_chunks
|
|
199
|
+
type: IndexUpsert
|
|
200
|
+
index: rag_index
|
|
201
|
+
batch_config:
|
|
202
|
+
batch_size: 25
|
|
203
|
+
inputs:
|
|
204
|
+
- embedded_chunk
|
|
205
|
+
outputs:
|
|
206
|
+
- embedded_chunk
|
|
207
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Sales Data Q1 2024
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
Summary Statistics:
|
|
5
|
+
- Total Records: 1,472 transactions
|
|
6
|
+
- Date Range: January 1 - March 31, 2024
|
|
7
|
+
- Products: A, B, C, D
|
|
8
|
+
- Regions: North, South, East, West
|
|
9
|
+
|
|
10
|
+
Top Performing Products:
|
|
11
|
+
1. Product A: $1,245,890 total sales (avg $847/transaction)
|
|
12
|
+
2. Product C: $1,123,450 total sales (avg $763/transaction)
|
|
13
|
+
3. Product B: $987,230 total sales (avg $671/transaction)
|
|
14
|
+
4. Product D: $856,340 total sales (avg $582/transaction)
|
|
15
|
+
|
|
16
|
+
Regional Breakdown:
|
|
17
|
+
- North Region: $1,089,450 (26.3% of total)
|
|
18
|
+
- South Region: $1,045,230 (25.2% of total)
|
|
19
|
+
- East Region: $1,012,890 (24.4% of total)
|
|
20
|
+
- West Region: $1,001,340 (24.1% of total)
|
|
21
|
+
|
|
22
|
+
Key Trends:
|
|
23
|
+
- Product A shows consistent growth throughout Q1 (+15% month-over-month)
|
|
24
|
+
- West region had strongest growth rate despite lower absolute numbers
|
|
25
|
+
- Discount rates ranged from 0% to 20%, with 10% being most common
|
|
26
|
+
- Average transaction size increased 8% from Jan to March
|
|
27
|
+
- Customer count per transaction averaging 25 customers
|
|
28
|
+
|
|
29
|
+
Notable Patterns:
|
|
30
|
+
- Weekday sales 23% higher than weekend sales
|
|
31
|
+
- Product D underperforming in South region specifically
|
|
32
|
+
- Strong correlation between discount rate and quantity sold
|
|
33
|
+
- North region showing premium pricing power (higher avg transaction)
|
|
34
|
+
|
|
35
|
+
Concerns:
|
|
36
|
+
- Product D sales declining 5% month-over-month
|
|
37
|
+
- South region discount rates higher than other regions
|
|
38
|
+
- Customer acquisition costs need monitoring
|
|
39
|
+
|
|
40
|
+
Opportunities:
|
|
41
|
+
- West region expansion showing strong ROI
|
|
42
|
+
- Product A momentum could be leveraged for upselling
|
|
43
|
+
- Cross-regional best practices could improve South region performance
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
id: time_utilities
|
|
2
|
+
description: |
|
|
3
|
+
A simple application demonstrating tool usage with the commons library.
|
|
4
|
+
|
|
5
|
+
This example shows how to:
|
|
6
|
+
- Import tools from the commons library
|
|
7
|
+
- Invoke Python functions as tools
|
|
8
|
+
- Pass data between tool invocations
|
|
9
|
+
- Work with datetime types
|
|
10
|
+
|
|
11
|
+
The flow gets the current timestamp, formats it, calculates a future time,
|
|
12
|
+
and determines the time difference.
|
|
13
|
+
|
|
14
|
+
# Import the commons tools library
|
|
15
|
+
references:
|
|
16
|
+
- !include ../common/tools.qtype.yaml
|
|
17
|
+
|
|
18
|
+
flows:
|
|
19
|
+
- type: Flow
|
|
20
|
+
id: time_info_flow
|
|
21
|
+
description: Get and format the current timestamp
|
|
22
|
+
|
|
23
|
+
variables:
|
|
24
|
+
- id: current_time
|
|
25
|
+
type: datetime
|
|
26
|
+
|
|
27
|
+
- id: time_two_hours_later
|
|
28
|
+
type: datetime
|
|
29
|
+
|
|
30
|
+
- id: time_difference
|
|
31
|
+
type: TimeDifferenceResultType
|
|
32
|
+
|
|
33
|
+
outputs:
|
|
34
|
+
- current_time
|
|
35
|
+
- time_difference
|
|
36
|
+
|
|
37
|
+
steps:
|
|
38
|
+
# Step 1: Get current timestamp
|
|
39
|
+
- id: get_time
|
|
40
|
+
type: InvokeTool
|
|
41
|
+
tool: qtype.application.commons.tools.get_current_timestamp
|
|
42
|
+
input_bindings: {}
|
|
43
|
+
output_bindings:
|
|
44
|
+
result: current_time
|
|
45
|
+
|
|
46
|
+
# Step 2: Calculate time 2 hours from now
|
|
47
|
+
- id: add_hours
|
|
48
|
+
type: InvokeTool
|
|
49
|
+
tool: qtype.application.commons.tools.timedelta
|
|
50
|
+
input_bindings:
|
|
51
|
+
timestamp: current_time
|
|
52
|
+
hours: "2"
|
|
53
|
+
output_bindings:
|
|
54
|
+
result: time_two_hours_later
|
|
55
|
+
|
|
56
|
+
# Step 3: Calculate the time difference
|
|
57
|
+
- id: calc_difference
|
|
58
|
+
type: InvokeTool
|
|
59
|
+
tool: qtype.application.commons.tools.calculate_time_difference
|
|
60
|
+
input_bindings:
|
|
61
|
+
start_time: current_time
|
|
62
|
+
end_time: time_two_hours_later
|
|
63
|
+
output_bindings:
|
|
64
|
+
result: time_difference
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
To use a Vertex example, set the following environment variables manually:
|
|
2
|
+
```
|
|
3
|
+
export GOOGLE_CLOUD_PROJECT=
|
|
4
|
+
export GOOGLE_CLOUD_LOCATION=
|
|
5
|
+
export GOOGLE_APPLICATION_CREDENTIALS=
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Using gcloud CLI:
|
|
9
|
+
How to setup [Gemini CLI Authentication Setup](https://github.com/google-gemini/gemini-cli/blob/main/docs/get-started/authentication.md)
|
|
10
|
+
|
|
11
|
+
`profile_name`: Replace default with relevant GCP project name in `.config/gcloud/configurations/your-project-configuration-file`
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
id: hello_world
|
|
2
|
+
description: A simple stateful chat flow with Google Vertex AI
|
|
3
|
+
models:
|
|
4
|
+
- type: Model
|
|
5
|
+
id: gemini_flash
|
|
6
|
+
provider: gcp-vertex
|
|
7
|
+
model_id: gemini-2.0-flash
|
|
8
|
+
inference_params:
|
|
9
|
+
temperature: 0.7
|
|
10
|
+
memories:
|
|
11
|
+
- id: chat_memory
|
|
12
|
+
token_limit: 10000
|
|
13
|
+
flows:
|
|
14
|
+
- type: Flow
|
|
15
|
+
id: simple_chat_example
|
|
16
|
+
interface:
|
|
17
|
+
type: Conversational
|
|
18
|
+
variables:
|
|
19
|
+
- id: user_message
|
|
20
|
+
type: ChatMessage
|
|
21
|
+
- id: response_message
|
|
22
|
+
type: ChatMessage
|
|
23
|
+
inputs:
|
|
24
|
+
- user_message
|
|
25
|
+
outputs:
|
|
26
|
+
- response_message
|
|
27
|
+
steps:
|
|
28
|
+
- id: llm_inference_step
|
|
29
|
+
type: LLMInference
|
|
30
|
+
model: gemini_flash
|
|
31
|
+
system_message: "You are a helpful assistant."
|
|
32
|
+
memory: chat_memory
|
|
33
|
+
inputs:
|
|
34
|
+
- user_message
|
|
35
|
+
outputs:
|
|
36
|
+
- response_message
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
id: hello_world
|
|
2
|
+
description: A simple hello world application using Google Vertex AI
|
|
3
|
+
models:
|
|
4
|
+
- type: Model
|
|
5
|
+
id: gemini_flash
|
|
6
|
+
provider: gcp-vertex
|
|
7
|
+
model_id: gemini-2.0-flash
|
|
8
|
+
inference_params:
|
|
9
|
+
temperature: 0.7
|
|
10
|
+
flows:
|
|
11
|
+
- type: Flow
|
|
12
|
+
id: simple_example
|
|
13
|
+
interface:
|
|
14
|
+
type: Complete
|
|
15
|
+
variables:
|
|
16
|
+
- id: prompt
|
|
17
|
+
type: text
|
|
18
|
+
- id: formatted_prompt
|
|
19
|
+
type: text
|
|
20
|
+
- id: answer
|
|
21
|
+
type: text
|
|
22
|
+
inputs:
|
|
23
|
+
- prompt
|
|
24
|
+
outputs:
|
|
25
|
+
- answer
|
|
26
|
+
steps:
|
|
27
|
+
- id: question_prompt
|
|
28
|
+
type: PromptTemplate
|
|
29
|
+
template: "You are a helpful assistant. Answer the following question:\n{prompt}\n"
|
|
30
|
+
inputs:
|
|
31
|
+
- prompt
|
|
32
|
+
outputs:
|
|
33
|
+
- formatted_prompt
|
|
34
|
+
- id: llm_inference_step
|
|
35
|
+
type: LLMInference
|
|
36
|
+
model: gemini_flash
|
|
37
|
+
inputs:
|
|
38
|
+
- formatted_prompt
|
|
39
|
+
outputs:
|
|
40
|
+
- answer
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
id: hello_world
|
|
2
|
+
description: A simple hello world application using Google Vertex AI
|
|
3
|
+
models:
|
|
4
|
+
- type: Model
|
|
5
|
+
id: gemini_flash
|
|
6
|
+
provider: gcp-vertex
|
|
7
|
+
model_id: gemini-2.0-flash
|
|
8
|
+
inference_params:
|
|
9
|
+
temperature: 0.7
|
|
10
|
+
auth: vertex_auth
|
|
11
|
+
auths:
|
|
12
|
+
- type: vertex
|
|
13
|
+
id: vertex_auth
|
|
14
|
+
profile_name: default
|
|
15
|
+
flows:
|
|
16
|
+
- type: Flow
|
|
17
|
+
id: simple_example
|
|
18
|
+
interface:
|
|
19
|
+
type: Complete
|
|
20
|
+
variables:
|
|
21
|
+
- id: prompt
|
|
22
|
+
type: text
|
|
23
|
+
- id: answer
|
|
24
|
+
type: text
|
|
25
|
+
- id: formatted_prompt
|
|
26
|
+
type: text
|
|
27
|
+
inputs:
|
|
28
|
+
- prompt
|
|
29
|
+
outputs:
|
|
30
|
+
- answer
|
|
31
|
+
steps:
|
|
32
|
+
- id: question_prompt
|
|
33
|
+
type: PromptTemplate
|
|
34
|
+
template: "You are a helpful assistant. Answer the following question:\n{prompt}\n"
|
|
35
|
+
inputs:
|
|
36
|
+
- prompt
|
|
37
|
+
outputs:
|
|
38
|
+
- formatted_prompt
|
|
39
|
+
- id: llm_inference_step
|
|
40
|
+
type: LLMInference
|
|
41
|
+
model: gemini_flash
|
|
42
|
+
inputs:
|
|
43
|
+
- formatted_prompt
|
|
44
|
+
outputs:
|
|
45
|
+
- answer
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
id: trace_example
|
|
2
|
+
description: Example of tracing QType application calls with OpenTelemetry to Phoenix
|
|
3
|
+
|
|
4
|
+
models:
|
|
5
|
+
- type: Model
|
|
6
|
+
id: nova
|
|
7
|
+
provider: aws-bedrock
|
|
8
|
+
model_id: amazon.nova-lite-v1:0
|
|
9
|
+
inference_params:
|
|
10
|
+
temperature: 0.7
|
|
11
|
+
max_tokens: 512
|
|
12
|
+
|
|
13
|
+
flows:
|
|
14
|
+
- type: Flow
|
|
15
|
+
id: classify_text
|
|
16
|
+
interface:
|
|
17
|
+
type: Complete
|
|
18
|
+
variables:
|
|
19
|
+
- id: text
|
|
20
|
+
type: text
|
|
21
|
+
- id: response
|
|
22
|
+
type: text
|
|
23
|
+
inputs:
|
|
24
|
+
- text
|
|
25
|
+
outputs:
|
|
26
|
+
- response
|
|
27
|
+
steps:
|
|
28
|
+
- id: classify
|
|
29
|
+
type: LLMInference
|
|
30
|
+
model: nova
|
|
31
|
+
system_message: "Classify the following text as positive, negative, or neutral. Respond with only one word."
|
|
32
|
+
inputs:
|
|
33
|
+
- text
|
|
34
|
+
outputs:
|
|
35
|
+
- response
|
|
36
|
+
|
|
37
|
+
telemetry:
|
|
38
|
+
id: phoenix_trace
|
|
39
|
+
provider: Phoenix
|
|
40
|
+
endpoint: http://localhost:6006/v1/traces
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Research Assistant Example
|
|
2
|
+
#
|
|
3
|
+
# Takes one input (topic), searches the web via Tavily, then synthesizes
|
|
4
|
+
# an answer using an LLM call.
|
|
5
|
+
#
|
|
6
|
+
# Prereqs:
|
|
7
|
+
# - Set `TAVILY-API_BEARER` for Tavily auth (see tavily.qtype.yaml)
|
|
8
|
+
# - Configure AWS credentials if using Bedrock (default model below)
|
|
9
|
+
#
|
|
10
|
+
# Run with:
|
|
11
|
+
# qtype run \
|
|
12
|
+
# -i '{"topic":"Latest developments in retrieval augmented generation"}' \
|
|
13
|
+
# examples/research_assistant/research_assistant.qtype.yaml
|
|
14
|
+
|
|
15
|
+
id: research_assistant
|
|
16
|
+
description: Web search + synthesis research assistant using Tavily
|
|
17
|
+
|
|
18
|
+
# Import Tavily tools created from tavily.oas.yaml
|
|
19
|
+
references:
|
|
20
|
+
- !include ./tavily.qtype.yaml
|
|
21
|
+
|
|
22
|
+
models:
|
|
23
|
+
- type: Model
|
|
24
|
+
id: nova_lite
|
|
25
|
+
provider: aws-bedrock
|
|
26
|
+
model_id: amazon.nova-lite-v1:0
|
|
27
|
+
inference_params:
|
|
28
|
+
temperature: 0.3
|
|
29
|
+
max_tokens: 900
|
|
30
|
+
|
|
31
|
+
flows:
|
|
32
|
+
- type: Flow
|
|
33
|
+
id: research
|
|
34
|
+
description: Search the web for a topic and synthesize an answer
|
|
35
|
+
inputs:
|
|
36
|
+
- topic
|
|
37
|
+
outputs:
|
|
38
|
+
- answer
|
|
39
|
+
|
|
40
|
+
variables:
|
|
41
|
+
- id: topic
|
|
42
|
+
type: text
|
|
43
|
+
|
|
44
|
+
# Tavily outputs
|
|
45
|
+
- id: tavily_results
|
|
46
|
+
type:
|
|
47
|
+
element_type: schema_4844016144
|
|
48
|
+
|
|
49
|
+
# LLM prompt + response
|
|
50
|
+
- id: synthesis_prompt
|
|
51
|
+
type: text
|
|
52
|
+
- id: answer
|
|
53
|
+
type: text
|
|
54
|
+
|
|
55
|
+
steps:
|
|
56
|
+
- type: InvokeTool
|
|
57
|
+
id: search_web
|
|
58
|
+
tool: search
|
|
59
|
+
input_bindings:
|
|
60
|
+
query: topic
|
|
61
|
+
output_bindings:
|
|
62
|
+
results: tavily_results
|
|
63
|
+
outputs:
|
|
64
|
+
- tavily_results
|
|
65
|
+
|
|
66
|
+
- type: PromptTemplate
|
|
67
|
+
id: build_prompt
|
|
68
|
+
template: |
|
|
69
|
+
Research topic: {topic}
|
|
70
|
+
|
|
71
|
+
Search results (list of objects with url/content/score):
|
|
72
|
+
{tavily_results}
|
|
73
|
+
|
|
74
|
+
Task:
|
|
75
|
+
- Write a concise, well-structured answer to the research topic.
|
|
76
|
+
- If the results contain URLs, include 3-8 bullet citations at the end
|
|
77
|
+
using the URLs you relied on most.
|
|
78
|
+
- If information is missing or uncertain, say so explicitly.
|
|
79
|
+
inputs:
|
|
80
|
+
- topic
|
|
81
|
+
- tavily_results
|
|
82
|
+
outputs:
|
|
83
|
+
- synthesis_prompt
|
|
84
|
+
|
|
85
|
+
- type: LLMInference
|
|
86
|
+
id: synthesize
|
|
87
|
+
model: nova_lite
|
|
88
|
+
system_message: |
|
|
89
|
+
You are a careful research assistant. Use the provided search results.
|
|
90
|
+
Prefer accurate summaries over speculation.
|
|
91
|
+
inputs:
|
|
92
|
+
- synthesis_prompt
|
|
93
|
+
outputs:
|
|
94
|
+
- answer
|