microsoft / sample-app-aoai-chatGPT

Sample code for a simple web chat experience through Azure OpenAI, including Azure OpenAI On Your Data.
MIT License
1.57k stars 2.43k forks source link

Change citation references to different link (such as Seismic link) #192

Open liuclarahy opened 1 year ago

liuclarahy commented 1 year ago

We are using the 'Add your own data' sample. We uploaded files to Azure Blob Storage, created Cognitive Search and the associated indexes. The bot would provide reference links pointing to the Blob Storage. All good, make sense.

Our ultimate goal is to be able to index files stored in Seismic. While I don't think Azure Cognitive Search can connect to Seismic at this moment, we would like to be able to update the Blob storage links to point to Seismic link instead.

Is updating citation references possible? If so, which part of the code can we start to make the change?

pamelafox commented 1 year ago

You could take a look at mapping the links in the frontend citation parser code, here: https://github.com/microsoft/sample-app-aoai-chatGPT/blob/0e14412723cf65865ba64e72cd97ee65241236df/frontend/src/components/Answer/AnswerParser.tsx#L10

If you do end up needing more flexibility than that, you can also try using the other sample: https://github.com/Azure-Samples/azure-search-openai-demo/

liuclarahy commented 1 year ago

Thank you @pamelafox for your reply. We made the changes to Answer.tsx. Please excuse my ignorance.. do we need to compile the changes to get the latest .js file?

What we are seeing is that the changes we made didn't do anything on the re-deployed webapp.

This is what we did:

  1. Cloned the repo locally
  2. Make the change in Answer.tsx
  3. Redeploy with the following: to redeploy an existing webapp:

az webapp config appsettings set -g xxx -n yyy --settings WEBSITE_WEBDEPLOY_USE_SCM=false az webapp up --runtime PYTHON:3.10 --sku B1 --name yyy --resource-group xxx --plan ppp

I think we are missing the compile/ build step. Can you please shed us some light? Much appreciated.

pamelafox commented 1 year ago

Yes, you need to re-build the JavaScript yourself, the deployment step doesn't do that for this code. You can run start.cmd or start.sh and you should see index.html and JS files updated in the static folder.

liuclarahy commented 1 year ago

@pamelafox . Got the start.cmd running and found the updated index.html and JS files. next is to just to run the redeploy with the following? but still not seeing the changes on the app

az webapp config appsettings set -g xxx -n yyy --settings WEBSITE_WEBDEPLOY_USE_SCM=false az webapp up --runtime PYTHON:3.10 --sku B1 --name yyy --resource-group xxx --plan ppp

pamelafox commented 1 year ago

Hm, az webapp up should be deploying the local code. After it's done, you could open the App Service app in the Azure Portal, find SSH in the left-hand nav, start the SSH session, and then poke around the file system to make sure it's showing the latest files. It might be that it will update in a few minutes, I notice App Service sometimes restarts a few minutes after a deploy.

liuclarahy commented 1 year ago

Gosh... you are right! We had to wait for about 15minutes before seeing the changes on the app. THANK YOU so much for your prompt support.

sarah-widder commented 1 year ago

@liuclarahy for additional customization, you can take a look at how scripts/data_preparation.py creates an index. It's only set up for local files so URL is not set for the document chunks in the index but the chunking approach is the same as happens when you connect to blob storage in the Azure OpenAI studio. You could customize the flow to connect to blob storage and set the URL however you like in the index, then the app code would just display the URL attribute of the citation without needing to override. Just another option in case it helps.

kylgrn commented 11 months ago

@liuclarahy, any extra insights you can share on how you were able to add this functionality/change? I'm looking to do the same with linking to ServiceNow.