From 716b1c7abba5d5bc736d7f2a20ed3c71b7ca1869 Mon Sep 17 00:00:00 2001 From: Xander Song Date: Mon, 14 Oct 2024 17:12:50 -0700 Subject: [PATCH] playground model name (#5001) --- src/phoenix/server/api/subscriptions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/phoenix/server/api/subscriptions.py b/src/phoenix/server/api/subscriptions.py index 5842431a93..c059139858 100644 --- a/src/phoenix/server/api/subscriptions.py +++ b/src/phoenix/server/api/subscriptions.py @@ -107,6 +107,7 @@ async def chat_completion( attributes=dict( chain( _llm_span_kind(), + _llm_model_name(input.model.name), _input_value_and_mime_type(input), _llm_input_messages(input.messages), ) @@ -200,6 +201,10 @@ def _llm_span_kind() -> Iterator[Tuple[str, Any]]: yield OPENINFERENCE_SPAN_KIND, LLM +def _llm_model_name(model_name: str) -> Iterator[Tuple[str, Any]]: + yield LLM_MODEL_NAME, model_name + + def _input_value_and_mime_type(input: ChatCompletionInput) -> Iterator[Tuple[str, Any]]: yield INPUT_MIME_TYPE, JSON yield INPUT_VALUE, json.dumps(asdict(input), cls=GraphQLInputJSONEncoder) @@ -261,6 +266,7 @@ def default(self, obj: Any) -> Any: OUTPUT_VALUE = SpanAttributes.OUTPUT_VALUE LLM_INPUT_MESSAGES = SpanAttributes.LLM_INPUT_MESSAGES LLM_OUTPUT_MESSAGES = SpanAttributes.LLM_OUTPUT_MESSAGES +LLM_MODEL_NAME = SpanAttributes.LLM_MODEL_NAME MESSAGE_CONTENT = MessageAttributes.MESSAGE_CONTENT MESSAGE_ROLE = MessageAttributes.MESSAGE_ROLE