Skip to content

Commit

Permalink
chore: log openai response
Browse files Browse the repository at this point in the history
  • Loading branch information
EresDev committed Jul 30, 2024
1 parent 0eb37d3 commit 453eac9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/parser/content-evaluator-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,16 @@ export class ContentEvaluatorModule implements Module {
});

const rawResponse = String(response.choices[0].message.content);
console.log("OpenAI raw response:", rawResponse);

const jsonResponse = JSON.parse(rawResponse);

const responseType = Type.Record(Type.String(), Type.Number({ minimum: 0, maximum: 1 }));

if (Value.Check(responseType, jsonResponse)) {
return Value.Convert(responseType, jsonResponse) as { [k: string]: number };
const relevances = Value.Convert(responseType, jsonResponse) as { [k: string]: number };
console.log("Relevances by OpenAI:", relevances);
return relevances;
} else {
throw new Error(`Invalid response type received from openai while evaluating: ${jsonResponse}`);
}
Expand Down

0 comments on commit 453eac9

Please sign in to comment.