diff --git a/src/apis/logsExport.ts b/src/apis/logsExport.ts index c4a4078..c2473a7 100644 --- a/src/apis/logsExport.ts +++ b/src/apis/logsExport.ts @@ -2,7 +2,8 @@ import { ApiResource } from '../apiResource'; import { APIResponseType, ApiClientInterface } from '../_types/generalTypes'; import { APIPromise, RequestOptions } from '../baseClient'; import { createHeaders } from './createHeaders'; -import { toQueryParams } from '../utils'; +import { overrideConfig, toQueryParams } from '../utils'; +import { LOGS_API } from '../constants'; export interface LogsExportCreateParams { filters?: Record; @@ -71,12 +72,38 @@ export interface LogsExportDownloadParams { export interface LogsExportDownloadResponse extends APIResponseType { signed_url?: string; } + +export interface LogInsertBody { + request?: Record; + response?: Record; + metadata?: Record; +} export class Logs extends ApiResource { exports: Exports; constructor(client: any) { super(client); this.exports = new Exports(client); } + + create( + _body: LogInsertBody, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise { + const body = _body; + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const response = this.post(LOGS_API, { + body, + ...opts, + }); + return response; + } } export class Exports extends ApiResource { create( diff --git a/src/constants.ts b/src/constants.ts index 54f4bc9..d92d754 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -45,3 +45,4 @@ export const TEXT_COMPLETE_API = '/completions'; export const PROMPT_API = '/prompt/complete'; export const FEEDBACK_API = '/feedback'; export const EMBEDDINGS_API = '/embeddings'; +export const LOGS_API = '/logs';