Document Upload and RAG

Hello

We have a RAG application that uses Palantir as the back-end and has a custom React front-end. The application allows the user to interact with the documents that are loaded into the system.

We would like to add a feature where the user can upload documents and have them available to query. We can’t find any solution for getting the documents into Palantir to process the RAG flow. We tried a few different things all unsuccessfully:

  1. Custom Function
  2. Attachments
  3. Put mediaset

The custom function failed with a 500 error with no description of why it was failing. Attachments failed because they are user scoped and subsequent processing wasn’t in the user’s context. Put mediaset failed 403 because we didn’t have the right scope, but we couldn’t find a way to add the scope.

We feel like this is a pretty vanilla use-case but so far no luck. We appreciate any advice.

1 Like

Thanks for your question and sorry for the trouble this is giving you.
I am not sure what Custom function means but I wanted to tell you that we are releasing formal support for Mediaset operation in OSDK so you would be able to do that in a first class way.
As for now, I am right to say that you are trying to use the token provided you by the client to make a direct fetch/put on the mediaset?
If this is during development, you could use a staticlly issued token for now (e.g. replace your auth object with a function which return a promise to a token and return the hard coded token.
or create a generic client (which will not be scoped) and use that client id with your existing application.

Hey @jderosalia ,

We have changes landing very soon that should enable this workflow! As soon as they are shipped I will drop some code samples for the first class way to achieve this.

In the meantime I achieved this in the SongShare demo by doing number 3 on your list. The scope you need is api:mediasets-write so your client should look like this:

const client = new FoundryClient({
  url,
  auth: new PublicClientAuth({
    clientId,
    url,
    redirectUrl,
    scopes: ["api:read-data", "api:write-data", "api:mediasets-write"],
  }),
});

The next issue you will face is that the mediaset is not in the Resource Scope of your Third Party Application. You can work around this by making an OAuth Client in Developer Console and using that client ID and client secret in your React app (while using the Application to generate your SDK). I’d recommend reading the OSDK Permissions docs to understand what working outside of resource scopes means.

This should unblock your workflow for the time being, hopefully I’ll be back soon with something more first class for you to try which won’t involve the new scopes and client.

2 Likes

Hi guys

I’m not keen to build a separate app. It would help to have a sense of when the new feature will drop. I would be happy with a beta drop if possible.

What I understood is that a workaround would be to create a scope-less token on this page:
https://{HOSTNAME}/workspace/settings/tokens and to pass that to this method: https://www.palantir.com/docs/foundry/api/media-sets-v2-resources/media-sets/put-media-item instead of the user token. I would also need to add the scopes to the auth construction Does that sound right?

JFYI I couldn’t find the SongShare demo as that was a generic link.

Thanks again

Hey @jderosalia,

This example could potentially help until the product team gets back to you with a timeline.

Happy also to discuss how we end up doing the rag with OCR and semantic chunking!

1 Like