Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export class PromptLayer {
groupId,
modelParameterOverrides,
stream = false,
skipLogging = false, // New option to skip logging
}: RunRequest) {
const tracer = getTracer();

Expand All @@ -142,6 +143,7 @@ export class PromptLayer {
groupId,
modelParameterOverrides,
stream,
skipLogging,
};
span.setAttribute("function_input", JSON.stringify(functionInput));

Expand Down Expand Up @@ -208,6 +210,9 @@ export class PromptLayer {
const response = await request_function(promptBlueprint, kwargs);

const _trackRequest = (body: object) => {
if (skipLogging) {
return Promise.resolve({}); // Return an empty object if logging is skipped
}
const request_end_time = new Date().toISOString();
return trackRequest({
function_name,
Expand All @@ -234,9 +239,9 @@ export class PromptLayer {
const requestLog = await _trackRequest({ request_response: response });

const functionOutput = {
request_id: requestLog.request_id,
request_id: skipLogging ? null : requestLog.request_id,
raw_response: response,
prompt_blueprint: requestLog.prompt_blueprint,
prompt_blueprint: skipLogging ? null : requestLog.prompt_blueprint,
};
span.setAttribute("function_output", JSON.stringify(functionOutput));

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export interface RunRequest {
promptReleaseLabel?: string;
inputVariables?: Record<string, unknown>;
modelParameterOverrides?: Record<string, unknown>;
skipLogging?: boolean;
}

export interface LogRequest {
Expand Down