Skip to content
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

[CM-10169] Replace get_llm_trace_by_key with get_llm_trace_by_id #134

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/comet_llm/api_objects/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,19 @@ def __init__(self, api_key: Optional[str] = None) -> None:
)
self._api = comet_ml.API(api_key=experiment_info_.api_key, cache=False)

def get_llm_trace_by_key(self, trace_key: str) -> llm_trace_api.LLMTraceAPI:
def get_llm_trace_by_id(self, trace_id: str) -> llm_trace_api.LLMTraceAPI:
"""
Get an API Trace object by key.
Get an API Trace object by id.

Args:
trace_key: str, key of the prompt or chain
trace_id: str, id of the prompt or chain

Returns: An LLMTraceAPI object that can be used to get or update trace data
"""
matching_trace = self._api.get_experiment_by_key(trace_key)
matching_trace = self._api.get_experiment_by_key(trace_id)

if matching_trace is None:
raise ValueError(
f"Failed to find any matching traces with the key {trace_key}"
)
raise ValueError(f"Failed to find any matching traces with ID {trace_id}")

return llm_trace_api.LLMTraceAPI.__api__from_api_experiment__(matching_trace)

Expand Down
Loading