Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setThreadId is changing frequently #2721

Open
ravvi-kumar opened this issue Aug 19, 2024 · 0 comments · May be fixed by #2722
Open

setThreadId is changing frequently #2721

ravvi-kumar opened this issue Aug 19, 2024 · 0 comments · May be fixed by #2722
Labels
ai/ui bug Something isn't working

Comments

@ravvi-kumar
Copy link

Description

setThreadId function in package/react/src/use-assistant.ts : whenever input or messages change, the setThreadId function is changing.

i am using searchParam to get the threadId for my application. whenever the threadId in the searchParam changes, i am setting the threadId of the current chat by using "setThreadId" function from useAssistant() hook.
now by following react-hooks rules, I’ve included setThreadId as a dependency in the useEffect hook. However, this results in the useEffect firing even when the input or messages change, because the setThreadId function is changing frequently.

Code example

useEffect(() => {
  if (currentThreadId) {
    getHistory(currentThreadId).then(data => {
      setHistory(data);
    });
    setThreadId(currentThreadId);
  }
}, [currentThreadId, getHistory, setThreadId]);

here if i not include setThreadId in the dependency, then everything works fine. but actually it is depending on "setThreadId"

Additional context

No response

@lgrammel lgrammel added bug Something isn't working ai/ui labels Aug 19, 2024
@ravvi-kumar ravvi-kumar linked a pull request Aug 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/ui bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants