quivr
quivr copied to clipboard
Enable summarization added to frontend (draft)
I see that your current application supports the summarization feature. However, the summarization is not enabled/disabled from the front-end. To allow users to enable/disable summarization on the front-end, you can add a checkbox input to the page.tsx file and pass the related state to the upload file and crawl endpoint.
Here's how you can edit the page.tsx
to incorporate this behavior:
- First, add the
useEffect
anduseRef
hooks (if not already present) from thereact
import at the top of the file:
import { Dispatch, SetStateAction, useCallback, useState, useRef, useEffect } from "react";
- Add a new state for storing the summarization toggle state:
const [enableSummarization, setEnableSummarization] = useState(false);
- Add a checkbox input under the file and website input components in the
page.tsx
file like this:
<label htmlFor="enableSummarization" className="inline-flex items-center cursor-pointer">
<input
id="enableSummarization"
type="checkbox"
checked={enableSummarization}
onChange={(e) => setEnableSummarization(e.target.checked)}
className="cursor-pointer"
/>
<span className="ml-2 text-sm">Enable summarization</span>
</label>
- Modify the
upload_file
andcrawl_endpoint
function calls withinpage.tsx
to include theenableSummarization
state variable when calling the/upload
and/crawl
endpoints.
const response = await axios.post(
`${process.env.NEXT_PUBLIC_BACKEND_URL}/upload`,
formData,
{ params: { enable_summarization: enableSummarization } }
);
And for crawling endpoint
const response = await axios.post(
`${process.env.NEXT_PUBLIC_BACKEND_URL}/crawl`,
config,
{ params: { enable_summarization: enableSummarization } }
);
- Finally, update the
/upload
and/crawl
endpoints in theapi.py
file to accept theenable_summarization
query parameter:
@app.post("/upload")
async def upload_file(commons: CommonsDep, file: UploadFile, enable_summarization: bool = False):
...
@app.post("/crawl/")
async def crawl_endpoint(commons: CommonsDep, crawl_website: CrawlWebsite, enable_summarization: bool = False):
...
Now, when the user toggles the summarization checkbox, the application will enable/disable the summarization feature based on their input.
Someone is attempting to deploy a commit to a Personal Account owned by @StanGirard on Vercel.
@StanGirard first needs to authorize it.