Skip to content

How restrict files

Noel Fran Thomas edited this page Jul 21, 2024 · 1 revision

8b0b0eb

Updated July 21, 2024

  1. Updated @/components/chat-panel.tsx with a component called fileSelect. This allows the user to select files from Bridge (which is updated on every render). Then added the file IDs to the handleQuerySubmit so it can be passed to the submit function as a part of data.
  2. Inside app/actions.tsx, updated the submit function. Captured the file IDs in selectedFileIds if there are any from the formData argument. Then I also filter out the file IDs from the formData before it is pushed as a message from L63 to L67. Inside the nested function, processEvents, I update the call to the researcher to include selectedFileIds. I chose to pass the file IDs to the researcher so that it can decide whether or not to call Bridge, and also to manipulate the search query.
  3. In @/lib/agents/researcher.tsx, updated the arguments to accept file IDs. Then, if there are selected file IDs, intercept the getTools function from directly passing all tools to the LLM. Here I redefine a BridgeQuery, but with the file IDs embedded into its definition. This way there is no need to pass it in as an argument (which exposes it to LLMs - all messages should be considered visible). It is easy to pass it in as an argument, refer to https://sdk.vercel.ai/docs/reference/ai-sdk-core/stream-text.

Clone this wiki locally