Skip to content

Commit

Permalink
Remove logging of error responses
Browse files Browse the repository at this point in the history
It should be up to the user if they want to log
error responses or not. Prompts logged could contain
sensitive information.
  • Loading branch information
jarib committed Dec 13, 2024
1 parent fd433fd commit 84c07c0
Showing 1 changed file with 14 additions and 26 deletions.
40 changes: 14 additions & 26 deletions libs/langchain-google-gauth/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,20 @@ export class GAuthClient implements GoogleAbstractedClient {
}

async request(opts: GoogleAbstractedClientOps): Promise<unknown> {
try {
const ret = await this.gauth.request(opts);
const [contentType] = ret?.headers?.["content-type"]?.split(/;/) ?? [""];
if (opts.responseType !== "stream") {
return ret;
} else if (contentType === "text/event-stream") {
return {
...ret,
data: new NodeSseJsonStream(ret.data),
};
} else {
return {
...ret,
data: new NodeJsonStream(ret.data),
};
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (xx: any) {
console.error("call to gauth.request", JSON.stringify(xx, null, 2));
console.error(
"call to gauth.request opts=",
JSON.stringify(opts, null, 2)
);
console.error("call to gauth.request message:", xx?.message);
throw xx;
const ret = await this.gauth.request(opts);
const [contentType] = ret?.headers?.["content-type"]?.split(/;/) ?? [""];
if (opts.responseType !== "stream") {
return ret;
} else if (contentType === "text/event-stream") {
return {
...ret,
data: new NodeSseJsonStream(ret.data),
};
} else {
return {
...ret,
data: new NodeJsonStream(ret.data),
};
}
}
}

0 comments on commit 84c07c0

Please sign in to comment.