quivr icon indicating copy to clipboard operation
quivr copied to clipboard

Enable summarization added to frontend (draft)

Open shuruheel opened this issue 1 year ago • 1 comments

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:

  1. First, add the useEffect and useRef hooks (if not already present) from the react import at the top of the file:
import { Dispatch, SetStateAction, useCallback, useState, useRef, useEffect } from "react";
  1. Add a new state for storing the summarization toggle state:
const [enableSummarization, setEnableSummarization] = useState(false);
  1. 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>
  1. Modify the upload_file and crawl_endpoint function calls within page.tsx to include the enableSummarization 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 } }
);
  1. Finally, update the /upload and /crawl endpoints in the api.py file to accept the enable_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.

shuruheel avatar May 24 '23 18:05 shuruheel

Someone is attempting to deploy a commit to a Personal Account owned by @StanGirard on Vercel.

@StanGirard first needs to authorize it.

vercel[bot] avatar May 24 '23 18:05 vercel[bot]