Skip to content

Commit

Permalink
fix(logging): Log API url if verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Oct 24, 2023
1 parent 04ebd3d commit 2e2b9d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/embeddings-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ ${promptText}
}

if (opts.verbose) {
console.error(util.inspect({ requestId, payload }, false, 8, true));
console.error(util.inspect({ requestId, apiUrl: openAiAPIURL, payload }, false, 8, true));
}

let run = async () => {
Expand Down Expand Up @@ -433,7 +433,7 @@ ${question}
}

if (opts.verbose) {
console.error(util.inspect({ requestId, payload }, false, 8, true));
console.error(util.inspect({ requestId, apiUrl: openAiAPIURL, payload }, false, 8, true));
}

let run = async () => {
Expand Down
6 changes: 4 additions & 2 deletions lib/generate-embeddings.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ async function getChunkEmbeddings(chunk, apiToken, opts) {
let data;
let retries = 0;

const openAiAPIURL = getApiUrl(baseApiUrl, OPENAI_API_URL);

if (verbose) {
console.error(util.inspect({ requestId, payload }, false, 8, true));
}

let run = async () => {
res = await fetchCmd(getApiUrl(baseApiUrl, OPENAI_API_URL), {
res = await fetchCmd(openAiAPIURL, {
method: 'post',
headers,
body: JSON.stringify(payload),
Expand Down Expand Up @@ -103,7 +105,7 @@ async function getChunkEmbeddings(chunk, apiToken, opts) {
const reqEndTime = Date.now();

if (opts.verbose) {
console.error(util.inspect({ requestId, output: data }, false, 8, true));
console.error(util.inspect({ requestId, apiUrl: openAiAPIURL, output: data }, false, 8, true));
}

let embedding = data?.data?.[0]?.embedding;
Expand Down
4 changes: 2 additions & 2 deletions lib/generate-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ ${JSON.stringify(content)}`;
}

if (opts.verbose) {
console.error(util.inspect({ requestId, payload }, false, 8, true));
console.error(util.inspect({ requestId, apiUrl: openAiAPIURL, payload }, false, 8, true));
}

let run = async () => {
Expand Down Expand Up @@ -332,7 +332,7 @@ ${JSON.stringify(content)}`;
.trim();

if (opts.verbose) {
console.error(util.inspect({ output, data }, false, 8, true));
console.error(util.inspect({ requestId, output, data }, false, 8, true));
}

try {
Expand Down

0 comments on commit 2e2b9d9

Please sign in to comment.