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

ai/packages/core/react /use-assistant.ts: expose setThreadId as helper #1673

Closed
tomfuller71 opened this issue May 22, 2024 · 1 comment
Closed
Labels

Comments

@tomfuller71
Copy link

Feature Description

Expose setThreadId as a UseAssistantHelper so that a new conversation thread can be started by executing setThreadId(undefined).

Use Case

Use case: an assistant providing feedback on a specific tuple of "question" and "student_answer". The UI provides user the ability to select the specific course, exam and question they want to get the assistant's feedback on. When selection is complete the UI should initiate a new chat with an initial prompt dynamically generated from the user's selections. Each new request for feedback should be a new chat where the bot has no memory of any previous conversations.

Without the ability to set the threadId to undefined the same chat thread will be used for the entire lifetime of the React component containing the useAssistant hook and even if messages are cleared the assistant still has memory of the previous conversation. A full page refresh is not ideal as memory of current UI state will be lost without some workarounds.

Additional context

As an alternative to exposing setThreadId add a more explicit helper. e.g.

  /**
   * Resets the chat thread.
   * Stops any existing chat threads, clears the chat `Messages` and `Input`.
   * Resets `threadId` so that new messages will run on a new thread.
  */
  resetThread: () => {
    stop()
    setMessages([])
    setInput('')
    setThreadId(undefined)
  }
@jeremyphilemon
Copy link
Contributor

@tomfuller71

#2209 adds setThreadId helper to switch between threads!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants