()
| 122 | }; |
| 123 | |
| 124 | export const RequestsPage = () => { |
| 125 | usePageTitle("Requests"); |
| 126 | const { projectId } = useCurrentProject(); |
| 127 | const [inspectedRequestId, setInspectedRequestId] = |
| 128 | useQueryState("inspectedRequestId"); |
| 129 | const [offset, setOffset] = useQueryState("offset", 0); |
| 130 | const [limit, setLimit] = useQueryState("limit", DEFAULT_PAGE_SIZE); |
| 131 | |
| 132 | const { data: requests, isSuccess } = useGetRequestReports( |
| 133 | { |
| 134 | offset: Number(offset), |
| 135 | limit: Number(limit), |
| 136 | }, |
| 137 | { |
| 138 | enabled: |
| 139 | inspectedRequestId && |
| 140 | projectId && |
| 141 | offset !== undefined && |
| 142 | limit !== undefined, |
| 143 | } |
| 144 | ); |
| 145 | |
| 146 | const columns = useMemo(() => getTableColumns(), []); |
| 147 | |
| 148 | const pagination = useMemo( |
| 149 | () => requests?.paginatedRequests?.pagination, |
| 150 | [requests] |
| 151 | ); |
| 152 | const paginatedResults = useMemo( |
| 153 | () => requests?.paginatedRequests?.data ?? [], |
| 154 | [requests] |
| 155 | ); |
| 156 | |
| 157 | const data: RequestReportItem[] = useMemo( |
| 158 | () => |
| 159 | paginatedResults.map((report: SerializedPaginatedReport) => { |
| 160 | return { |
| 161 | reportId: report.id, |
| 162 | timestamp: report.timestamp, |
| 163 | status: report.responseStatusCode, |
| 164 | duration: report.duration ?? 0, |
| 165 | totalTokens: report.totalTokens ?? 0, |
| 166 | cost: report.totalCost ?? 0, |
| 167 | isTestPrompt: report.environment === "PLAYGROUND" || false, |
| 168 | promptId: null, |
| 169 | cacheEnabled: report.cacheEnabled, |
| 170 | cacheHit: report.cacheHit, |
| 171 | model: report.model, |
| 172 | modelAuthor: report.modelAuthor, |
| 173 | provider: report.provider, |
| 174 | }; |
| 175 | }), |
| 176 | [paginatedResults] |
| 177 | ); |
| 178 | |
| 179 | return ( |
| 180 | <> |
| 181 | <Drawer |
nothing calls this directly
no test coverage detected