From b2c33e0a1497b46a8af919d4c8923fbe19c89c4c Mon Sep 17 00:00:00 2001 From: lievan Date: Mon, 28 Oct 2024 17:11:09 -0400 Subject: [PATCH 1/4] imprive user session tracking --- content/en/llm_observability/setup/sdk/_index.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/content/en/llm_observability/setup/sdk/_index.md b/content/en/llm_observability/setup/sdk/_index.md index 66d5d1b239819..8cb2548a1a134 100644 --- a/content/en/llm_observability/setup/sdk/_index.md +++ b/content/en/llm_observability/setup/sdk/_index.md @@ -356,17 +356,23 @@ def get_relevant_docs(question): ## Tracking user sessions -Session tracking allows you to associate multiple interactions with a given user. When starting a root span for a new trace or span in a new process, specify the `session_id` argument with the string ID of the underlying user session: +Session tracking allows you to associate multiple interactions with a given user. When starting a root span for a new trace or span in a new process, specify the `session_id` argument with the string ID of the underlying user session. Optionally, you can also specify the `user_handle`, `user_name`, and `user_id` tags: {{< code-block lang="python" >}} from ddtrace.llmobs.decorators import workflow @workflow(session_id="") -def process_message(): - ... # user application logic +def process_user_message(): + LLMObs.annotate( + ... + tags = {"user_handle": "poodle@dog.com", "user_id": "1234", "user_name": "poodle"} + ) return {{< /code-block >}} +### User tags + + ## Annotating a span The SDK provides the method `LLMObs.annotate()` to annotate spans with inputs, outputs, and metadata. From d4db77f654c4c9fd951d347a0865a40f0a1a9fe2 Mon Sep 17 00:00:00 2001 From: lievan Date: Mon, 28 Oct 2024 18:27:42 -0400 Subject: [PATCH 2/4] add a table --- content/en/llm_observability/setup/sdk/_index.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/content/en/llm_observability/setup/sdk/_index.md b/content/en/llm_observability/setup/sdk/_index.md index 8cb2548a1a134..49e4bc96ab3ab 100644 --- a/content/en/llm_observability/setup/sdk/_index.md +++ b/content/en/llm_observability/setup/sdk/_index.md @@ -356,7 +356,7 @@ def get_relevant_docs(question): ## Tracking user sessions -Session tracking allows you to associate multiple interactions with a given user. When starting a root span for a new trace or span in a new process, specify the `session_id` argument with the string ID of the underlying user session. Optionally, you can also specify the `user_handle`, `user_name`, and `user_id` tags: +Session tracking allows you to associate multiple interactions with a given user. When starting a root span for a new trace or span in a new process, specify the `session_id` argument with the string ID of the underlying user session, which will be submitted as a tag on the span. Optionally, you can also specify the `user_handle`, `user_name`, and `user_id` tags. {{< code-block lang="python" >}} from ddtrace.llmobs.decorators import workflow @@ -370,8 +370,14 @@ def process_user_message(): return {{< /code-block >}} -### User tags +### Session Tracking Tags +| Tag | Description | +|---|---| +| `session_id` | ID representing a single user session, e.g. a chat session | +| `user_handle` | The handle for the user of the chat session | +| `user_name` | The name for the user of the chat session | +| `user_id` | The ID for the user of the chat session | ## Annotating a span From cbf922a7380674937fae918c6367d7e90fffd4c4 Mon Sep 17 00:00:00 2001 From: lievan <42917263+lievan@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:26:04 -0400 Subject: [PATCH 3/4] Update content/en/llm_observability/setup/sdk/_index.md Co-authored-by: May Lee --- content/en/llm_observability/setup/sdk/_index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/en/llm_observability/setup/sdk/_index.md b/content/en/llm_observability/setup/sdk/_index.md index 49e4bc96ab3ab..e29da1b698c4f 100644 --- a/content/en/llm_observability/setup/sdk/_index.md +++ b/content/en/llm_observability/setup/sdk/_index.md @@ -374,10 +374,10 @@ def process_user_message(): | Tag | Description | |---|---| -| `session_id` | ID representing a single user session, e.g. a chat session | -| `user_handle` | The handle for the user of the chat session | -| `user_name` | The name for the user of the chat session | -| `user_id` | The ID for the user of the chat session | +| `session_id` | The ID representing a single user session, for example, a chat session. | +| `user_handle` | The handle for the user of the chat session. | +| `user_name` | The name for the user of the chat session. | +| `user_id` | The ID for the user of the chat session. | ## Annotating a span From 3cc95ca2889ab291b9cdcc40c9980e15190274ab Mon Sep 17 00:00:00 2001 From: lievan <42917263+lievan@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:26:09 -0400 Subject: [PATCH 4/4] Update content/en/llm_observability/setup/sdk/_index.md Co-authored-by: May Lee --- content/en/llm_observability/setup/sdk/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/llm_observability/setup/sdk/_index.md b/content/en/llm_observability/setup/sdk/_index.md index e29da1b698c4f..43f9af5120bb7 100644 --- a/content/en/llm_observability/setup/sdk/_index.md +++ b/content/en/llm_observability/setup/sdk/_index.md @@ -356,7 +356,7 @@ def get_relevant_docs(question): ## Tracking user sessions -Session tracking allows you to associate multiple interactions with a given user. When starting a root span for a new trace or span in a new process, specify the `session_id` argument with the string ID of the underlying user session, which will be submitted as a tag on the span. Optionally, you can also specify the `user_handle`, `user_name`, and `user_id` tags. +Session tracking allows you to associate multiple interactions with a given user. When starting a root span for a new trace or span in a new process, specify the `session_id` argument with the string ID of the underlying user session, which is submitted as a tag on the span. Optionally, you can also specify the `user_handle`, `user_name`, and `user_id` tags. {{< code-block lang="python" >}} from ddtrace.llmobs.decorators import workflow