Skip to content

[RHIDP-11602] [RHIDP-11600] AI Notebooks Developer Preview Backend#2499

Open
JslYoon wants to merge 5 commits intoredhat-developer:mainfrom
JslYoon:JslYoon-ai-notebooks-dp
Open

[RHIDP-11602] [RHIDP-11600] AI Notebooks Developer Preview Backend#2499
JslYoon wants to merge 5 commits intoredhat-developer:mainfrom
JslYoon:JslYoon-ai-notebooks-dp

Conversation

@JslYoon
Copy link
Contributor

@JslYoon JslYoon commented Mar 9, 2026

Hey, I just made a Pull Request!

Stories:
https://redhat.atlassian.net/browse/RHIDP-11606
https://redhat.atlassian.net/browse/RHIDP-11600
Implementing AI Notebooks backend functionalities for Session, Document, and LLM query

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

/**
* Strip HTML tags and extract readable text from HTML content
*/
function stripHtmlTags(html: string): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is very overwhelming. any existing html parser can help on this?
perhaps https://www.npmjs.com/package/htmlparser2 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const startTime = Date.now();
const pollIntervalMs = 1000;

while (Date.now() - startTime < this.fileProcessingTimeoutMs) {
Copy link
Contributor

@yangcao77 yangcao77 Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking this could block the backend for up to 30 secs.

can we make this sync file uploading process to be async?

let's say, once user upload any document, immediately return a job id

    response {
      status: 'processing',
      job_id: job_id,
      file_id: file.id,
    };

and introduce a new API to able to get the job status GET /documents/job_id/status

    response {
      status: file.status,  // 'in_progress', 'completed', 'failed'
      progress: file.bytes_processed / file.total_bytes * 100,
      error/message
    };

and rely on frontend side to monitor & display the status

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or, can async handle the file, and use stream to send event for status update and frontend listen to the event. but the idea is not to use a while loop to block backend.
for example

setInterval(async () => {
      const file = await this.client.vectorStores.files.retrieve(...);

      res.write(`{
        status: file.status,
        progress: file.bytes_processed / file.total_bytes * 100,
        message/error
      })`);

      if (file.status === 'completed' || file.status === 'failed') {
        clearInterval(interval);
        res.end();
      }
    }, 1000); // every one second as you defined
  }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karthikjeeyar which would frontend prefer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instant upload & a new route to check status makes more sense, also less logical complexity @yangcao77. I would say blocking the backend is not necessary, since this file upload is async, it would not interfere with any other endpoints. Perhaps a "loading" button on the frontend while the document is uploading on frontend can help?

Copy link
Contributor Author

@JslYoon JslYoon Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps

response {
      status: 'processing',
      job_id: job_id,
      file_id: file.id,
    };

can be

`    response {
      status: 'processing',
      file_id: file.id,
    };`

since file_id is unique. Uploading a file with the same file_id will overwrite the file.

Copy link
Contributor

@yangcao77 yangcao77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a couple comments.
also I noticed there is no tests being created. please create unit tests for most of the functions. and integration tests for the endpoints.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
9.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

// const credentials = await httpAuth.credentials(req);
// const user = await userInfo.getUserInfo(credentials);
// return user.userEntityRef;
return 'user:default/guest';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanup?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, still making some final changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants