Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Caleb: converted llm response to json

Caleb Peffer667f740315a0
diff --git a/apps/api/src/__tests__/e2e_noAuth/index.test.ts b/apps/api/src/__tests__/e2e_noAuth/index.test.ts
index 271e84897..356fe7631 100644
--- a/apps/api/src/__tests__/e2e_noAuth/index.test.ts
+++ b/apps/api/src/__tests__/e2e_noAuth/index.test.ts
@@ -199,7 +199,8 @@ describe("E2E Tests for API Routes with No Authentication", () => {
expect(completedResponse.body.data[0]).toHaveProperty("content");
expect(completedResponse.body.data[0]).toHaveProperty("markdown");
expect(completedResponse.body.data[0]).toHaveProperty("metadata");
- expect(completedResponse.body.data[0].content).toContain("🔥 FireCrawl");
+
+
}, 60000); // 60 seconds
});
diff --git a/apps/api/src/__tests__/e2e_withAuth/index.test.ts b/apps/api/src/__tests__/e2e_withAuth/index.test.ts
index ad4910a4a..9e3fed1c8 100644
--- a/apps/api/src/__tests__/e2e_withAuth/index.test.ts
+++ b/apps/api/src/__tests__/e2e_withAuth/index.test.ts
@@ -289,13 +289,10 @@ describe("E2E Tests for API Routes", () => {
let llmExtraction = response.body.data.llm_extraction;
- // Check if llm_extraction is a string and parse it if necessary
- if (typeof llmExtraction === 'string') {
- llmExtraction = JSON.parse(llmExtraction);
- }
-
-
- console.log('llm extraction', llmExtraction);
+ // // Check if llm_extraction is a string and parse it if necessary
+ // if (typeof llmExtraction === 'string') {
+ // llmExtraction = JSON.parse(llmExtraction);
+ // }
// Print the keys of the response.body for debugging purposes
diff --git a/apps/api/src/lib/LLM-extraction/models.ts b/apps/api/src/lib/LLM-extraction/models.ts
index 7f50f72d7..71daa278f 100644
--- a/apps/api/src/lib/LLM-extraction/models.ts
+++ b/apps/api/src/lib/LLM-extraction/models.ts
@@ -1,6 +1,5 @@
import OpenAI from 'openai'
import { z } from 'zod'
-import { ScraperLoadResult } from './types'
import { Document, ExtractorOptions } from "../../lib/entities";
// import {
@@ -76,7 +75,8 @@ export async function generateOpenAICompletions<T>({
const c = completion.choices[0].message.tool_calls[0].function.arguments
// Extract the LLM extraction content from the completion response
- const llmExtraction = c;
+ const llmExtraction = JSON.parse(c);
+
// Return the document with the LLM extraction content added
return {