@daocloud-proto/hydra 0.18.0-dev-11 → 0.18.0-dev-13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,6 @@
6
6
 
7
7
  import * as HydraCommonCommon from "../../../common/common.pb"
8
8
  import * as fm from "../../../fetch.pb"
9
- import * as GoogleApiHttpbody from "../../../google/api/httpbody.pb"
10
9
  import * as GoogleProtobufTimestamp from "../../../google/protobuf/timestamp.pb"
11
10
 
12
11
  type Absent<T, K extends keyof T> = { [k in Exclude<keyof T, K>]?: undefined };
@@ -281,7 +280,7 @@ export class AIGuardrailsService {
281
280
  static QueryAIAuditLogStatistics(req: QueryAIAuditLogStatisticsRequest, initReq?: fm.InitReq): Promise<QueryAIAuditLogStatisticsResponse> {
282
281
  return fm.fetchReq<QueryAIAuditLogStatisticsRequest, QueryAIAuditLogStatisticsResponse>(`/apis/admin.hydra.io/v1alpha1/ai-guardrails-logs/statistics?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
283
282
  }
284
- static ExportAIAuditLog(req: ExportAIAuditLogRequest, initReq?: fm.InitReq): Promise<GoogleApiHttpbody.HttpBody> {
285
- return fm.fetchReq<ExportAIAuditLogRequest, GoogleApiHttpbody.HttpBody>(`/apis/admin.hydra.io/v1alpha1/ai-guardrails-logs/export?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
283
+ static ExportAIAuditLog(req: ExportAIAuditLogRequest, initReq?: fm.InitReq): Promise<Response> {
284
+ return fm.fetchRawReq(`/apis/admin.hydra.io/v1alpha1/ai-guardrails-logs/export?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
286
285
  }
287
286
  }
package/fetch.pb.ts CHANGED
@@ -338,4 +338,21 @@ export function renderURLSearchParams<T extends RequestPayload>(
338
338
  );
339
339
 
340
340
  return new URLSearchParams(urlSearchParams).toString();
341
- }
341
+ }
342
+
343
+ export async function fetchRawReq(path: string, init?: InitReq): Promise<Response> {
344
+ const {pathPrefix, ...req} = init || {}
345
+ const url = pathPrefix ? `${pathPrefix}${path}` : path
346
+ const response = await fetch(url, req)
347
+ if (!response.ok) {
348
+ const text = await response.text()
349
+ let body: unknown = text
350
+ try {
351
+ body = JSON.parse(text)
352
+ } catch {
353
+ // Preserve a non-JSON error body when an intermediary does not use the gateway error schema.
354
+ }
355
+ throw body
356
+ }
357
+ return response
358
+ }
@@ -32,6 +32,12 @@ export enum TimePeriod {
32
32
  TIME_PERIOD_MONTH = "TIME_PERIOD_MONTH",
33
33
  }
34
34
 
35
+ export enum ModelUsageExportFormat {
36
+ MODEL_USAGE_EXPORT_FORMAT_UNSPECIFIED = "MODEL_USAGE_EXPORT_FORMAT_UNSPECIFIED",
37
+ MODEL_USAGE_EXPORT_FORMAT_CSV = "MODEL_USAGE_EXPORT_FORMAT_CSV",
38
+ MODEL_USAGE_EXPORT_FORMAT_EXCEL = "MODEL_USAGE_EXPORT_FORMAT_EXCEL",
39
+ }
40
+
35
41
  export enum APIKeyUsageQueryStatus {
36
42
  API_KEY_USAGE_QUERY_STATUS_UNSPECIFIED = "API_KEY_USAGE_QUERY_STATUS_UNSPECIFIED",
37
43
  API_KEY_USAGE_QUERY_STATUS_COMPLETED = "API_KEY_USAGE_QUERY_STATUS_COMPLETED",
@@ -236,6 +242,61 @@ export type APIKeyUsageStatisticsResponse = {
236
242
  warnings?: APIKeyUsageWarning[]
237
243
  }
238
244
 
245
+ export type ExportModelUsageRequest = {
246
+ startTime?: GoogleProtobufTimestamp.Timestamp
247
+ endTime?: GoogleProtobufTimestamp.Timestamp
248
+ apiKeyIds?: string[]
249
+ models?: string[]
250
+ responseCodes?: string[]
251
+ format?: ModelUsageExportFormat
252
+ }
253
+
254
+ export type WSExportModelUsageRequest = {
255
+ startTime?: GoogleProtobufTimestamp.Timestamp
256
+ endTime?: GoogleProtobufTimestamp.Timestamp
257
+ apiKeyIds?: string[]
258
+ models?: string[]
259
+ responseCodes?: string[]
260
+ format?: ModelUsageExportFormat
261
+ workspace?: number
262
+ }
263
+
264
+ export type ListModelUsageRequest = {
265
+ startTime?: GoogleProtobufTimestamp.Timestamp
266
+ endTime?: GoogleProtobufTimestamp.Timestamp
267
+ apiKeyIds?: string[]
268
+ models?: string[]
269
+ page?: HydraCommonCommon.Pagination
270
+ responseCodes?: string[]
271
+ }
272
+
273
+ export type WSListModelUsageRequest = {
274
+ startTime?: GoogleProtobufTimestamp.Timestamp
275
+ endTime?: GoogleProtobufTimestamp.Timestamp
276
+ apiKeyIds?: string[]
277
+ models?: string[]
278
+ page?: HydraCommonCommon.Pagination
279
+ responseCodes?: string[]
280
+ workspace?: number
281
+ }
282
+
283
+ export type ModelUsageItem = {
284
+ requestTime?: GoogleProtobufTimestamp.Timestamp
285
+ requestId?: string
286
+ model?: string
287
+ apiKeyName?: string
288
+ statusCode?: string
289
+ totalTokens?: string
290
+ inputTokens?: string
291
+ outputTokens?: string
292
+ userId?: string
293
+ }
294
+
295
+ export type ListModelUsageResponse = {
296
+ items?: ModelUsageItem[]
297
+ page?: HydraCommonCommon.Pagination
298
+ }
299
+
239
300
  export type APIKeyUsageWarning = {
240
301
  code?: string
241
302
  message?: string
@@ -297,6 +358,12 @@ export class APIKeyManagement {
297
358
  static GetAPIKeyUsageStatistics(req: APIKeyUsageStatisticsRequest, initReq?: fm.InitReq): Promise<APIKeyUsageStatisticsResponse> {
298
359
  return fm.fetchReq<APIKeyUsageStatisticsRequest, APIKeyUsageStatisticsResponse>(`/apis/hydra.io/v1alpha1/apikeys-stats`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
299
360
  }
361
+ static ListModelUsage(req: ListModelUsageRequest, initReq?: fm.InitReq): Promise<ListModelUsageResponse> {
362
+ return fm.fetchReq<ListModelUsageRequest, ListModelUsageResponse>(`/apis/hydra.io/v1alpha1/model-usage?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
363
+ }
364
+ static ExportModelUsage(req: ExportModelUsageRequest, initReq?: fm.InitReq): Promise<Response> {
365
+ return fm.fetchRawReq(`/apis/hydra.io/v1alpha1/model-usage/export?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
366
+ }
300
367
  static CheckAPIKeyCreation(req: CheckAPIKeyCreationRequest, initReq?: fm.InitReq): Promise<CheckAPIKeyCreationResponse> {
301
368
  return fm.fetchReq<CheckAPIKeyCreationRequest, CheckAPIKeyCreationResponse>(`/apis/hydra.io/v1alpha1/apikeys/check-creation`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
302
369
  }
@@ -341,4 +408,10 @@ export class WSAPIKeyManagement {
341
408
  static GetAPIKeyUsageStatistics(req: WSAPIKeyUsageStatisticsRequest, initReq?: fm.InitReq): Promise<APIKeyUsageStatisticsResponse> {
342
409
  return fm.fetchReq<WSAPIKeyUsageStatisticsRequest, APIKeyUsageStatisticsResponse>(`/apis/hydra.io/v1alpha1/workspaces/${req["workspace"]}/apikeys-stats`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
343
410
  }
411
+ static ListModelUsage(req: WSListModelUsageRequest, initReq?: fm.InitReq): Promise<ListModelUsageResponse> {
412
+ return fm.fetchReq<WSListModelUsageRequest, ListModelUsageResponse>(`/apis/hydra.io/v1alpha1/workspaces/${req["workspace"]}/model-usage?${fm.renderURLSearchParams(req, ["workspace"])}`, {...initReq, method: "GET"})
413
+ }
414
+ static ExportModelUsage(req: WSExportModelUsageRequest, initReq?: fm.InitReq): Promise<Response> {
415
+ return fm.fetchRawReq(`/apis/hydra.io/v1alpha1/workspaces/${req["workspace"]}/model-usage/export?${fm.renderURLSearchParams(req, ["workspace"])}`, {...initReq, method: "GET"})
416
+ }
344
417
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daocloud-proto/hydra",
3
- "version": "v0.18.0-dev-11",
3
+ "version": "v0.18.0-dev-13",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "ISC"