|
14 | 14 | from parea.cache.cache import Cache |
15 | 15 | from parea.constants import PAREA_OS_ENV_EXPERIMENT_UUID |
16 | 16 | from parea.experiment.datasets import create_test_cases, create_test_collection |
17 | | -from parea.helpers import gen_trace_id, serialize_metadata_values, structure_trace_log_from_api, structure_trace_logs_from_api |
| 17 | +from parea.helpers import create_paginated_trace_logs_response_from_api, gen_trace_id, serialize_metadata_values, structure_trace_log_from_api, structure_trace_logs_from_api |
18 | 18 | from parea.parea_logger import parea_logger |
19 | 19 | from parea.schemas import EvaluationResult |
20 | 20 | from parea.schemas.models import ( |
|
30 | 30 | FeedbackRequest, |
31 | 31 | FinishExperimentRequestSchema, |
32 | 32 | ListExperimentUUIDsFilters, |
| 33 | + PaginatedTraceLogsResponse, |
33 | 34 | ProjectSchema, |
| 35 | + QueryParams, |
34 | 36 | TestCaseCollection, |
35 | 37 | TraceLogFilters, |
36 | 38 | TraceLogTree, |
|
59 | 61 | GET_TRACE_LOG_ENDPOINT = "/trace_log/{trace_id}" |
60 | 62 | LIST_EXPERIMENTS_ENDPOINT = "/experiments" |
61 | 63 | GET_EXPERIMENT_LOGS_ENDPOINT = "/experiment/{experiment_uuid}/trace_logs" |
| 64 | +GET_TRACE_LOGS_ENDPOINT = "/get_trace_logs" |
62 | 65 |
|
63 | 66 |
|
64 | 67 | @define |
@@ -524,6 +527,14 @@ async def aget_experiment(self, experiment_uuid: str) -> Optional[ExperimentWith |
524 | 527 | result = response_json[0] if isinstance(response_json, list) else None |
525 | 528 | return structure(result, ExperimentWithPinnedStatsSchema) |
526 | 529 |
|
| 530 | + def get_trace_logs(self, query_params: QueryParams) -> PaginatedTraceLogsResponse: |
| 531 | + response = self._client.request("POST", GET_TRACE_LOGS_ENDPOINT, data=asdict(query_params)) |
| 532 | + return create_paginated_trace_logs_response_from_api(response.json()) |
| 533 | + |
| 534 | + async def aget_trace_logs(self, query_params: QueryParams) -> PaginatedTraceLogsResponse: |
| 535 | + response = await self._client.request_async("POST", GET_TRACE_LOGS_ENDPOINT, data=asdict(query_params)) |
| 536 | + return create_paginated_trace_logs_response_from_api(response.json()) |
| 537 | + |
527 | 538 |
|
528 | 539 | def patch_openai_client_classes(openai_client, parea_client: Parea): |
529 | 540 | """Creates a subclass of the given openai_client to always wrap it with Parea at instantiation.""" |
|
0 commit comments