diff --git a/README.md b/README.md index c058183..e767623 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,11 @@ 5. Create a `.env` (use the `.example.env` for reference) and replace the API keys 6. Run `npm install` and `npm run dev` to install dependencies and run locally +## Tasks + +- [ ] Add error handling to getAnswer & anywhere else +- [ ] Move back to Together SDK w/ helicone + simpler streaming + ## Future tasks - [ ] Try to parse the sources in a more effecient way to make the app faster overall: Try Serper API diff --git a/app/api/getAnswer/route.ts b/app/api/getAnswer/route.ts index 0ff720f..9c1f765 100644 --- a/app/api/getAnswer/route.ts +++ b/app/api/getAnswer/route.ts @@ -23,17 +23,22 @@ export async function POST(request: Request) { let finalResults = await Promise.all( sources.map(async (result: any) => { try { + console.log(`[getAnswer] Fetching source from ${result.url}`); const response = await fetch(result.url); const html = await response.text(); + console.log(`[getAnswer] Got HTML from ${result.url}`); const virtualConsole = new jsdom.VirtualConsole(); const dom = new JSDOM(html, { virtualConsole }); const doc = dom.window.document; + console.log(`[getAnswer] Parsing HTML from ${result.url}`); const parsed = new Readability(doc).parse(); let parsedContent = parsed ? cleanedText(parsed.textContent) : "Nothing found"; + console.log(`[getAnswer] Got parsed content from ${result.url}`); + return { ...result, fullContent: parsedContent, @@ -47,6 +52,7 @@ export async function POST(request: Request) { } }), ); + console.log(`[getAnswer] Finished fetching text from source URLs`); let debug = finalResults.map( (result, index) => `[[citation:${index}]] ${result.fullContent} \n\n`,