<h1 align="center">
<a href="https://prompts.chat">
This is an Azure OpenAI Chat Web Part for SharePoint Online, offering a user experience that is familiar to users of ChatGPT.
Sign in to like and favorite skills
This is an Azure OpenAI Chat Web Part for SharePoint Online, offering a user experience that is familiar to users of ChatGPT.
Data Privacy
Azure OpenAI is the private GDPR-compliant service developed by Microsoft and deployable to your Azure tenant. Data provided to endpoints of Azure OpenAI is kept inside the boundaries of your tenant.
Native OpenAI is a public service, which provides access to its optional API by paid subscriptions. Any data provided to endpoints of Native OpenAI goes outside the boundaries of your tenant. As of December 2023, Native OpenAI is GDPR-compliant.
This web part interacts with private Azure OpenAI endpoints that are published via Azure API Management service (APIM).
In addition to the default configuration, you have the option to publish the Native OpenAI endpoint in APIM. You can find instructions in the documentation (pages 23 and 32-35).
In the simplest case, you can also use direct access to Azure OpenAI and Native OpenAI endpoints, configured with an api-key explicitly stored in the web part properties.
The web part supports optional integrations with company data. For security reasons, these integrations are disabled by default and must be explicitly enabled in the web part settings.
The integrations available in this release include:
SharePoint Search
Company Users
Local Date and Time
Analysis of an uploaded PDF and summarization of its content
Analysis of uploaded images and description of their content
Version 1.1 released on Dec 11, 2023. It includes the following additional options:
Search on the Internet: Bing and Google (+ Reddit).
Image generation from the prompt text. This option supports Dalle 3.
The option to use voice input to prompt text is available.
Version 1.2 released on Dec 23, 2023. It includes the following additional options:
Data encryption for all storage types.
GPT-4 Vision APIM endpoint (/openai4/vision).
Speech synthesis to read out AI-generated texts by default
/tts APIM endpoint (/openainative/tts) and Native OpenAI text-to-speech model for AI-generated texts.

I would like to express my deep respect and admiration for Microsoft, the creators of the groundbreaking Azure OpenAI service.
I am immensely grateful to Advania Finland for providing me with the opportunity and resources to develop this project.




This is the simplest and least secure setup. You will not be able to use the Private Chat sharing and People Search features unless you approve the corresponding SPFx permissions.
Prerequisites:
Clone the project.
Open the project in Visual Studio Code and navigate to View > Terminal
Execute the following commands
Create a Site Page in SharePoint Online and open it in "debug mode" using a format like:
https://yourtenant.sharepoint.com/sites/yoursite/SitePages/yourpage.aspx?debug=true&noredir=true&debugManifestsFile=https://localhost:4321/temp/manifests.jsEdit the page and add the Azure OpenAI Chat web part.
Open the web part settings and configure the minimal set of required properties as follows:
Client ID: create a user_impersonation app with name=openaiwp: keep the default "zero" value or leave it empty.
Base URL for GPT endpoint (APIM API or full): you can use the following alternatives:
Direct URL for the Azure OpenAI endpoint, configured for the deployment of GPT 3.5.
Direct URL for the Native OpenAI endpoint.
Base URL for GPT4 endpoint (APIM API or full): you can use the following alternatives:
Empty value if GPT-4 will not be used.
Direct URL for the Azure OpenAI endpoint, configured for the deployment of GPT 4.
Direct URL for the Native OpenAI endpoint, configured as mentioned above.
Base URL for Chat WebApi (APIM API or full): keep the default empty value.
Optional api-key for Azure OpenAI (for troubleshooting, not for Production): add your api-key
The key for Azure OpenAI or Native OpenAI, depending on your choices above.
It will be encrypted and stored in the web part settings (and displayed as *** in the Property Pane).
Language Models: If you have different models, adjust default values in the text box accordingly.
Storage type for chat history: keep the default SharePoint list or select Local storage for a quick review.
SharePoint list URL (leave it empty for default URL): leave it empty and click the Create button if you opt to use SharePoint list storage.
This will create a custom list, dbChats, in the current site collection.
By default, the chat sharing option is disabled.
If you enable it using the corresponding checkbox below the field, click on the Update button to adjust the list's permissions.
The used list template can be found in the package.
Note, if you use Local storage you will be able to review sharing features. However, real sharing between users will not work with Local storage because chat history is stored locally. The maximum capacity of Local storage is limited to 10 Mb.
Save web part settings. Reload the page.
Test the setup by adding any text into the prompt text area, then pressing Enter or clicking the Submit button.
This is the simplest and least secure standalone setup. You will not be able to use the Private Chat sharing and People Search features unless you approve the corresponding SPFx permissions.
Prerequisites:
Download the latest release package or compile it from the source code in spfx-latest.
Create a site collection in SharePoint Online and an App Catalog for it.
Upload the package into the App Catalog.
Add a new Site Page and the web part Azure OpenAI Chat to it.
Open the web part settings and configure the minimal set of required properties as follows:
Client ID: create a user_impersonation app with name=openaiwp: keep the default "zero" value or leave it empty.
Base URL for GPT endpoint (APIM API or full): you can use the following alternatives:
Direct URL for the Azure OpenAI endpoint, configured for the deployment of GPT 3.5.
Direct URL for the Native OpenAI endpoint.
Base URL for GPT4 endpoint (APIM API or full): you can use the following alternatives:
Empty value if GPT-4 will not be used.
Direct URL for the Azure OpenAI endpoint, configured for the deployment of GPT 4.
Direct URL for the Native OpenAI endpoint, configured as mentioned above.
Base URL for Chat WebApi (APIM API or full): keep the default empty value.
Optional api-key for Azure OpenAI (for troubleshooting, not for Production): add your api-key
The key for Azure OpenAI or Native OpenAI, depending on your choices above.
It will be encrypted and stored in the web part settings (and displayed as *** in the Property Pane).
Language Models: If you have different models, adjust default values in the text box accordingly.
Storage type for chat history: keep the default SharePoint list or select Local storage for a quick review.
SharePoint list URL (leave it empty for default URL): leave it empty and click the Create button if you opt to use SharePoint list storage.
This will create a custom list, dbChats, in the current site collection.
By default, the chat sharing option is disabled.
If you enable it using the corresponding checkbox below the field, click on the Update button to adjust the list's permissions.
The used list template can be found in the package.
Note, if you use Local storage you will be able to review sharing features. However, real sharing between users will not work with Local storage because chat history is stored locally. The maximum capacity of Local storage is limited to 10 Mb.
Save web part settings. Reload the page.
Test the setup by adding any text into the prompt text area, then pressing Enter or clicking the Submit button.
Prerequisites:
You should be:
You should create an instance of Azure OpenAI and configure deployments for GPT 3.5, and optionally, GPT 4 text language models.
Optionally, you can deploy the API Management service and publish (Azure) OpenAI endpoints there.
Download the latest release package or compile it from the source code in spfx-latest.
Create a site collection in SharePoint Online and an App Catalog for it.
Upload the package into the App Catalog.
Create a new App registration called openaiwp in Microsoft Entra ID (Azure AD) using default settings.
This step can be skipped if you do not plan to use the API Management service to secure access to (Azure) OpenAI endpoints.
The app will be used to verify users in APIM. openaiwp is the default name used in web part permissions.
Save the App ID (Client ID). You will use it in the web part settings.
5. Review and approve access permissions for the uploaded SPFx package in the API access section of your SharePoint Online tenant.
This step can be skipped if you do not plan to use the API Management service to secure access to (Azure) OpenAI endpoints.
openaiwp > Azure OpenAI Chat Web Part > user_impersonation: required to verify users in APIM.
Microsoft Graph > People.Read and Microsoft Graph > User.Read.All: permissions needed to retrieve colleagues and other users from Azure AD.
Add a new Site Page and the web part Azure OpenAI Chat to it.
Open the web part settings and configure the minimal set of required properties as follows:
Client ID: create a user_impersonation app with name=openaiwp: use the saved App ID, refer to point 4 above.
Base URL for GPT endpoint (APIM API or full): You have the following alternative options:
Preconfigured APIM URL for GPT 3.5: https://yourapiminstance.azure-api.net/openai
Direct URL for Azure OpenAI endpoint configured for GPT 3.5 deployment.
For example, https://instance.openai.azure.com/openai/deployments/gpt-35-turbo-16k/chat/completions?api-version=2023-07-01-preview
You need to have an api-key for that instance.
Direct URL for the native OpenAI endpoint.
For example, https://api.openai.com/v1/chat/completions
You need to have an active, paid OpenAI subscription and a valid api-key for it.
Base URL for GPT4 endpoint (APIM API or full): You have the following alternative options:
No value, implying GPT-4 will not be used.
Preconfigured APIM URL for GPT 3.5: https://yourapiminstance.azure-api.net/openai4
Direct URL for Azure OpenAI endpoint configured for GPT 4 deployment. Same as above.
Direct URL for the native OpenAI endpoint. Same as above.
Base URL for Chat WebApi (APIM API or full): leave it empty.
It's not in use for the default SharePoint list storage.
If left empty, it defaults to https://yourapiminstance.azure-api.net/chatwebapi when Database storage is used.
Optional api-key for Azure OpenAI (for troubleshooting, not for Production): add your api-key if you don't use APIM.
The key is for Azure OpenAI or Native OpenAI, depending on your choices above.
It will be encrypted and stored in the web part settings (and displayed as *** in the Property Pane).
Language models: adjust values in the text box if you have different ones.
Storage type for chat history: keep the default SharePoint list.
SharePoint list URL (leave it empty for the default URL): leave it empty and click on the Create button.
It will create a custom list called dbChats in the current site collection.
By default, the chat sharing option is disabled.
The used list template can be found in the package.
If you enable it using the corresponding checkbox below the field, click on the Update button to adjust the list's permissions.
Save web part settings. Reload the page.
Test the setup by adding any text into the prompt text area, then pressing Enter or clicking the Submit button.
Prerequisites:
Please refer to the project documentation in azure-openai-chat-web-part.pdf and azure-openai-chat-security.pdf
The reference: Don't be alarmed by vulnerabilities after running NPM Install
When working with SPFx solutions, it is important to note that npm packages are not deployed to SharePoint. Therefore, any audit warnings related to these packages can be disregarded in the context of SPFx solutions.
In addition to the standard set of modules employed by SPFx 1.18 with React base, the project includes references to the following additional libraries: