From d4901667b1a81e89c96cca822b929492aeef275a Mon Sep 17 00:00:00 2001 From: Alexander Barannikov Date: Tue, 2 Jul 2024 16:39:36 +0100 Subject: [PATCH 1/2] [CM-10413] Fix API.query type hints to the query parameter --- src/comet_llm/api_objects/api.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/comet_llm/api_objects/api.py b/src/comet_llm/api_objects/api.py index 61526c0..a383d1f 100644 --- a/src/comet_llm/api_objects/api.py +++ b/src/comet_llm/api_objects/api.py @@ -7,7 +7,7 @@ # \____\___/|_| |_| |_|\___|\__(_)_| |_| |_|_| # # Sign up for free at https://www.comet.com -# Copyright (C) 2015-2023 Comet ML INC +# Copyright (C) 2015-2024 Comet ML INC # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this package. # ******************************************************* @@ -28,7 +28,7 @@ def __init__(self, api_key: Optional[str] = None) -> None: API class for accessing and updating prompt information. Args: - api_key: You private Comet API key + api_key: Your private Comet API key Example: ```python linenums="1" @@ -91,29 +91,28 @@ def get_llm_trace_by_name( return llm_trace_api.LLMTraceAPI.__api__from_api_experiment__(matching_trace[0]) def query( - self, workspace: str, project_name: str, query: str + self, workspace: str, project_name: str, query: comet_ml.QueryExpression ) -> List[llm_trace_api.LLMTraceAPI]: """ - Fetch LLM Trace based on a query. Currently it is only possible to use + Fetch LLM Trace based on a query. Currently, it is only possible to use trace metadata or details fields to filter the traces. Args: workspace: Name of the workspace project_name: Name of the project - query: Query to use + query: Query expression to use (see note below) Returns: A list of LLMTrace objects Note: - The `query` object takes the form of (QUERY_VARIABLE OPERATOR VALUE) with: + The `query` object can also take the form of (QUERY_VARIABLE OPERATOR VALUE) with: * QUERY_VARIABLE is either TraceMetadata, Duration, Timestamp. * OPERATOR is any standard mathematical operators `<=`, `>=`, `!=`, `<`, `>`. It is also possible to add multiple query conditions using `&`. - If you are querying nested parameters, you should flatted the parameter name using the - `.` operator. + If you are querying nested parameters, flatten the parameter name using the `.` operator. To query the duration, you can use Duration(). From 6065891682c77632c7af6c92d2e1c838ac3b99a4 Mon Sep 17 00:00:00 2001 From: Alexander Barannikov Date: Tue, 2 Jul 2024 17:12:01 +0100 Subject: [PATCH 2/2] [CM-10413] change import to avoid pyright linter error --- src/comet_llm/api_objects/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/comet_llm/api_objects/api.py b/src/comet_llm/api_objects/api.py index a383d1f..f67f3ad 100644 --- a/src/comet_llm/api_objects/api.py +++ b/src/comet_llm/api_objects/api.py @@ -15,6 +15,7 @@ from typing import List, Optional import comet_ml +from comet_ml.query import QueryExpression from .. import experiment_info, logging_messages, query_dsl from . import llm_trace_api @@ -91,7 +92,7 @@ def get_llm_trace_by_name( return llm_trace_api.LLMTraceAPI.__api__from_api_experiment__(matching_trace[0]) def query( - self, workspace: str, project_name: str, query: comet_ml.QueryExpression + self, workspace: str, project_name: str, query: QueryExpression ) -> List[llm_trace_api.LLMTraceAPI]: """ Fetch LLM Trace based on a query. Currently, it is only possible to use