Skip to content

Chat api frontend route file created and middleware updated#168

Open
Karthi-47 wants to merge 4 commits into
mainfrom
Chatservice_API
Open

Chat api frontend route file created and middleware updated#168
Karthi-47 wants to merge 4 commits into
mainfrom
Chatservice_API

Conversation

@Karthi-47
Copy link
Copy Markdown
Collaborator

No description provided.

@SaravanakumarR2018
Copy link
Copy Markdown
Owner

You had already implemented chat history using session storage

Why did you remove chat history when you implemented this PR?

It should be a present.

image

Comment thread src/frontend/src/middleware.ts Outdated
event: NextFetchEvent,
) {
// Apply Clerk middleware for API routes instead of skipping them
if (request.nextUrl.pathname.startsWith('/api')) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

make it

  if (request.nextUrl.pathname.startsWith('/api/backend')) {

Copy link
Copy Markdown
Owner

@SaravanakumarR2018 SaravanakumarR2018 left a comment

Choose a reason for hiding this comment

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

Once you chat with the AI as userA in org OrgA, the chat gets stored in session and gets displayed
Now when you modify the org on the top left corner to OrgB, all the chats relevant to OrgB for UserA should be visible

But currently all the chats relevant to userA for orgA is visible eventhough orgB is selected

We should test these things thoroughly before raising a PR

Copy link
Copy Markdown
Owner

@SaravanakumarR2018 SaravanakumarR2018 left a comment

Choose a reason for hiding this comment

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

  1. When I type somethig in chat - it saysfailed to get response
    so basically it is not communicating with the backend to get the chat output

  2. When I create a new chat, the old chat details in old chat thread are getting erased

  3. I can create any number of chat threads by clicking on new chat icon, but actually only if you have conversed you should create a new chat thread

  4. It is not working for cellphones properly. When I shrink it should not show the chat history and it should only show the chat

  5. The start the new chat is close to the chat bar. We should move it up


try {
const res = await fetch(
`http://${CHAT_SERVICE_HOST}:${CHAT_SERVICE_PORT}/getallchats?chat_id=${chatId}&page=${page}&page_size=${pageSize}&org_id=${requestOrgId}`,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

org_id=${requestOrgId} is not needed
Remove it

},
body: JSON.stringify({
question: message,
chat_id: chatId,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Should we not send chatId for the first chat?

WHere are we taking care of the condition?

}
}

const res = await fetch(`/api/backend/getallchats?chat_id=${currentChat}&page=${pageToLoad}&page_size=10&org_id=${currentOrg}`);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We dont need org_id =org_id=${currentOrg}

import { useCallback, useEffect, useRef, useState } from 'react';

async function fetchChatIds(page: number = 1, pageSize: number = 15, orgId: string) {
const res = await fetch(`/api/backend/getallchatids?page=${page}&page_size=${pageSize}&org_id=${orgId}`);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We dont need org id

}

async function fetchChatMessages(chatId: string, orgId: string) {
const res = await fetch(`/api/backend/getallchats?chat_id=${chatId}&org_id=${orgId}`);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We dont need org id

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants