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,259 @@
|
|
|
1
|
+
# Observe with Telemetry
|
|
2
|
+
|
|
3
|
+
QType supports telemetry for all applications out of the box -- simply add the [Telemetry](../../Concepts/Core/telemetry.md) field to your application.
|
|
4
|
+
|
|
5
|
+
QType integrates with popular observability platforms to help you understand, debug, and optimize your LLM applications. This guide covers how to set up telemetry with Phoenix and Langfuse.
|
|
6
|
+
|
|
7
|
+
## Supported Providers
|
|
8
|
+
|
|
9
|
+
- **Phoenix** - Open-source LLM observability from Arize AI (default)
|
|
10
|
+
- **Langfuse** - Open-source LLM engineering platform with tracing and analytics
|
|
11
|
+
|
|
12
|
+
## Phoenix Integration
|
|
13
|
+
|
|
14
|
+
[Arize Phoenix](https://phoenix.arize.com/) is an open-source platform for LLM observability that runs locally or in the cloud.
|
|
15
|
+
|
|
16
|
+
### Setting up Phoenix
|
|
17
|
+
First, ensure you have installed the qtype `interpreter`:
|
|
18
|
+
```bash
|
|
19
|
+
pip install qtype[interpreter]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Next, install [Arize Phoenix](https://phoenix.arize.com/):
|
|
23
|
+
```bash
|
|
24
|
+
pip install arize-phoenix
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
and launch it:
|
|
28
|
+
```bash
|
|
29
|
+
phoenix serve
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This launches Phoenix on your local machine and listens for trace data at `http://localhost:6006/v1/traces`.
|
|
33
|
+
|
|
34
|
+
### Adding Phoenix Telemetry
|
|
35
|
+
|
|
36
|
+
Add telemetry to your QType application:
|
|
37
|
+
```yaml
|
|
38
|
+
|
|
39
|
+
```yaml
|
|
40
|
+
id: hello_world
|
|
41
|
+
telemetry:
|
|
42
|
+
id: hello_world_telemetry
|
|
43
|
+
endpoint: http://localhost:6006/v1/traces
|
|
44
|
+
flows:
|
|
45
|
+
- id: simple_chat_example
|
|
46
|
+
description: A simple stateful chat flow with OpenAI
|
|
47
|
+
mode: Chat
|
|
48
|
+
steps:
|
|
49
|
+
- id: llm_inference_step
|
|
50
|
+
memory:
|
|
51
|
+
id: chat_memory
|
|
52
|
+
model:
|
|
53
|
+
id: gpt-4
|
|
54
|
+
provider: openai
|
|
55
|
+
auth:
|
|
56
|
+
id: openai_auth
|
|
57
|
+
type: api_key
|
|
58
|
+
api_key: ${OPENAI_KEY}
|
|
59
|
+
system_message: |
|
|
60
|
+
You are a helpful assistant.
|
|
61
|
+
inputs:
|
|
62
|
+
- id: user_message
|
|
63
|
+
type: ChatMessage
|
|
64
|
+
outputs:
|
|
65
|
+
- id: response_message
|
|
66
|
+
type: ChatMessage
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Notice the `telemetry` field with the Phoenix endpoint. The `provider` defaults to `"Phoenix"` so you don't need to specify it.
|
|
70
|
+
|
|
71
|
+
### Viewing Phoenix Traces
|
|
72
|
+
|
|
73
|
+
1. Start your application:
|
|
74
|
+
```bash
|
|
75
|
+
qtype serve your-app.qtype.yaml
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
2. Navigate to `http://localhost:8000/ui` and have a conversation
|
|
79
|
+
|
|
80
|
+
3. View traces at [http://localhost:6006](http://localhost:6006). You'll see a project whose name matches your application id:
|
|
81
|
+
|
|
82
|
+

|
|
83
|
+
|
|
84
|
+
4. Click on the project to see the traces of your conversation:
|
|
85
|
+
|
|
86
|
+

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