-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Propagate prompt id to playground spans metadata #6224
base: prompts
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
) | ||
from opentelemetry.sdk.trace.id_generator import RandomIdGenerator as DefaultOTelIDGenerator | ||
from opentelemetry.trace import StatusCode | ||
from strawberry.relay.types import GlobalID | ||
from strawberry.scalars import JSON as JSONScalarType | ||
from typing_extensions import Self, TypeAlias, assert_never | ||
|
||
|
@@ -70,8 +71,10 @@ def __init__( | |
) -> None: | ||
self._input = input | ||
self._attributes: dict[str, Any] = attributes if attributes is not None else {} | ||
|
||
self._attributes.update( | ||
chain( | ||
prompt_id_metadata(input.prompt_id), | ||
llm_span_kind(), | ||
llm_model_name(input.model.name), | ||
llm_tools(input.tools or []), | ||
|
@@ -264,6 +267,10 @@ def input_value_and_mime_type( | |
yield INPUT_VALUE, safe_json_dumps(input_data) | ||
|
||
|
||
def prompt_id_metadata(prompt_id: Optional[GlobalID]) -> Iterator[tuple[str, Any]]: | ||
yield METADATA, {"phoenix-prompt-id": str(prompt_id)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
|
||
def _merge_tool_call_chunks( | ||
chunks_by_id: defaultdict[str, list[ToolCallChunk]], | ||
) -> list[dict[str, Any]]: | ||
|
@@ -442,6 +449,7 @@ def _serialize_event(event: SpanEvent) -> dict[str, Any]: | |
LLM_TOOLS = SpanAttributes.LLM_TOOLS | ||
LLM_TOKEN_COUNT_PROMPT = SpanAttributes.LLM_TOKEN_COUNT_PROMPT | ||
LLM_TOKEN_COUNT_COMPLETION = SpanAttributes.LLM_TOKEN_COUNT_COMPLETION | ||
METADATA = SpanAttributes.METADATA | ||
|
||
MESSAGE_CONTENT = MessageAttributes.MESSAGE_CONTENT | ||
MESSAGE_ROLE = MessageAttributes.MESSAGE_ROLE | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to also add this to the nonStreaming mutation? That one does not carry over prompt id