Skip to content

Commit

Permalink
added logging to when schema is generated
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanfaistenauer committed Mar 6, 2025
1 parent 14ad177 commit 27defda
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/core/utils/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export async function generateSchema(instruction: string, responseData: string)

while (retryCount <= MAX_RETRIES) {
try {
return await attemptSchemaGeneration(messages, retryCount);
const schema = await attemptSchemaGeneration(messages, retryCount);
console.log(`Schema generated`);
return schema;
} catch (error) {
retryCount++;
if (retryCount > MAX_RETRIES) {
Expand All @@ -41,7 +43,7 @@ async function attemptSchemaGeneration(
messages: ChatCompletionMessageParam[],
retry: number
): Promise<string> {
console.log(`Generating schema: ${retry ? `(retry ${retry})` : ""}`);
console.log(`Generating schema${retry ? `: (retry ${retry})` : ""}`);
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
baseURL: process.env.OPENAI_API_BASE_URL
Expand Down Expand Up @@ -72,6 +74,7 @@ async function attemptSchemaGeneration(
throw new Error("No schema generated");
}
const validator = new Validator();
const validation = validator.validate({}, generatedSchema);
validator.validate({}, generatedSchema);

return generatedSchema;
}

0 comments on commit 27defda

Please sign in to comment.