You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,7 @@
1
1
# ChatGPT + Enterprise data with Azure OpenAI and Cognitive Search - Java Version
2
+
[](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=599293758&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=WestUs2)
3
+
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/dantelmomsft/azure-search-openai-demo-java/)
4
+
2
5
This repo is the java conversion of the well known [chatGPT + Enterprise data code sample](https://github.com/Azure-Samples/azure-search-openai-demo) originally written in python.
3
6
It demonstrates a few approaches for creating ChatGPT-like experiences over your own data using the Retrieval Augmented Generation pattern. It uses Azure OpenAI Service to access the ChatGPT model (gpt-35-turbo), and Azure Cognitive Search for data indexing and retrieval.
4
7
@@ -55,6 +58,7 @@ ReadDecomposeAsk | :x: | :soon:
55
58
56
59
Execute the following command, if you don't have any pre-existing Azure services and want to start from a fresh deployment.
57
60
61
+
1. Run `azd auth login`
58
62
1. Run `azd up` - This will provision Azure resources and deploy this sample to those resources, including building the search index based on the files found in the `./data` folder.
59
63
* For the target location, the regions that currently support the models used in this sample are **East US**, **France Central**, **South Central US**, **UK South**, and **West Europe**. For an up-to-date list of regions and models, check [here](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/concepts/models)
60
64
1. After the application has been successfully deployed you will see a URL printed to the console. Click that URL to interact with the application in your browser.
@@ -82,6 +86,13 @@ It will look like the following:
82
86
3. Run `./start.ps1` or `./start.sh` or run the "VS Code Task: Start App" to start the project locally.
83
87
4. Wait for the spring boot server to start and refresh your browser to localhost:8080
84
88
89
+
### To Run in GitHub Codespaces or VS Code Remote Containers
90
+
91
+
You can run this repo virtually by using GitHub Codespaces or VS Code Remote Containers. Click on one of the buttons below to open this repo in one of those options.
92
+
93
+
[](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=599293758&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=WestUs2)
94
+
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/dantelmomsft/azure-search-openai-demo-java/)
95
+
85
96
### UI Navigation
86
97
87
98
* In Azure: navigate to the Azure WebApp deployed by azd. The URL is printed out when azd completes (as "Endpoint"), or you can find it in the Azure portal.
@@ -93,6 +104,35 @@ Once in the web app:
93
104
* Explore citations and sources
94
105
* Click on "settings" to try different options, tweak prompts, etc.
95
106
107
+
## App Continuous Integration
108
+
if you don't want to use azd to build and deploy the app, a GitHub automated CI pipeline is provided in `.github/workflows/app-ci.yml`. Some notes about the CI pipeline design:
109
+
- It uses a "branch per environment approach". The deploy environment name is computed at 'runtime' based on a git branch. You can check branch/env-name mapping logic in the "set environment for branch" step (line 29). The current implemented logic maps everything to a dev like environment. Therefore on each git push on the `main branch` the pipeline is triggered trying to deploy to an environment called `Development`. For more info about GitHub environments and how to set specific env variables and secrets read [here](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment).
110
+
- GitHub environment variables and secrets are used to configure development environment specific configuration. They need to be configured manually in github repository settings:
111
+
-`AZUREAPPSERVICE_PUBLISHPROFILE` is used to store the azure app service publish profile configuration securely.
112
+
-`AZUREAPPSERVICE_APP_NAME` is used to store the azure web app resource name generated during infra arm deployment.
113
+
114
+
To properly configure automated build and deploy for both backend and frontend components follow below steps:
115
+
116
+
1. Go to your forked repository in GitHub and create an [environment]((https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment)) called 'Development' (yes this is the exact name; don't change it). If you want to change the environment name (also adding new branches and environments, change the current branch/env mapping) you can do that, but make sure to change the pipeline code accordingly in `.github/workflows/app-ci.yml` (starting line 29)
117
+
2. Create 'Development' environment [secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) for the azure web app hosting both frontend and backend [publish profiles]((https://learn.microsoft.com/en-us/visualstudio/azure/how-to-get-publish-profile-from-azure-app-service?view=vs-2022)). You'll need to copy paste the xml content from the .PublishSettings file into the secret value:
118
+
- Create a secret with name `AZUREAPPSERVICE_PUBLISHPROFILE` and set the Value field to publish profile of the azure web app
119
+
3. Create 'Development' environment [variables](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-an-environment) for azure web app resource name:
120
+
- Create a variable with name `AZUREAPPSERVICE_APP_NAME` and set the Value field to the azure web app resource name
121
+
4. For each commit you push check the status of the triggered pipeline in the GitHub Actions tab, you should see a pipeline has been triggered for the specific commit. If everything is ok you should see green checkmark on both build and deploy jobs in the pipeline detail like below:
The repo includes sample pdf documents in the data folder. They are ingested in blob container and indexed in azure cognitive search during infra provisioning by azure developer cli post provision hooks (see line 23 in [azure.yaml](azure.yaml))
127
+
128
+
If you want to chat with your custom documents you can:
129
+
1. Add your pdf documents in the [data folder](./data/).
130
+
2. Open a terminal and cd to repo root folder. Example `cd path/to/your/custom/dir/azure-search-openai-demo-java`
131
+
3. Run `./scripts/prepdocs.ps1` if you are on windows or `./scripts/prepdocs.sh` on linux
132
+
4. Wait the script to complete. This is not a 'delta' process, it's not updating **only** the new files you've added. Instead on each run all documents in data folder will be ingested.Feel free to add new files you want to ingest and delete/move the old documents from the data folder. Once you've run the script and it completes successfully, cognitive search index have been updated and stored (until you want to manually delete it from your azure cognitive search instance)
133
+
5. if ingestion and indexing is completed successfully you should see a message like this
134
+

135
+
96
136
## Resources
97
137
98
138
*[Revolutionize your Enterprise Data with ChatGPT: Next-gen Apps w/ Azure OpenAI and Cognitive Search](https://aka.ms/entgptsearchblog)
Copy file name to clipboardExpand all lines: app/backend/src/main/java/com/microsoft/openai/samples/rag/approaches/RAGApproachFactorySpringBootImpl.java
Copy file name to clipboardExpand all lines: app/backend/src/main/java/com/microsoft/openai/samples/rag/ask/approaches/semantickernel/ReadRetrieveReadApproach.java
0 commit comments