docs added
|
@ -57,3 +57,4 @@ samples/react-kiota-custom-api-client/teamified-client/package-lock.json
|
|||
|
||||
samples/react-azure-openai-connector/_gitignored/sample-request.json
|
||||
samples/react-azure-openai-connector/_gitignored/citations-sample.json
|
||||
samples/react-azure-openai-connector/_gitignored/MyConstants.ts
|
||||
|
|
|
@ -1,10 +1,35 @@
|
|||
# react-azure-openai-connector
|
||||
# Using Azure OpenAI Connectors API
|
||||
|
||||
## Summary
|
||||
|
||||
Short summary on functionality and used technologies.
|
||||
This (__experimental__) webpart, shows how to use the new feature (_in preview at the moment of building this sample_) Azure OpenAI Data Connectors.
|
||||
|
||||
[picture of the solution in action, if possible]
|
||||
![./assets/react-azure-openai-connector.gif](./assets/react-azure-openai-connector.gif)
|
||||
|
||||
The webpart is calling the Azure OpenAI API, with a specific Data source configured to an existing Azure Search service that contains the Hotels index provided by Microsoft. The following screenshots shows how you can configure the connector throught the new Azure OpenAI Studio. This is **NOT required** for the sample, but helps to understand what the webpart is doing behind the scenes.
|
||||
|
||||
First, you have configured your Search service (any tier except the free one) importing the Hotels data sample provided by Microsoft
|
||||
|
||||
![./assets/studio01.png](./assets/studio01.png)
|
||||
|
||||
![./assets/studio02.png](./assets/studio02.png)
|
||||
|
||||
Now, from the [Azure OpenAI Studio](https://oai.azure.com/portal), in the _Chat playground_, you can configure your data connector:
|
||||
|
||||
![./assets/studio03.png](./assets/studio03.png)
|
||||
|
||||
Connect it to your Azure Search Hotels index:
|
||||
|
||||
![./assets/studio04.png](./assets/studio04.png)
|
||||
![./assets/studio05.png](./assets/studio05.png)
|
||||
|
||||
Follow the assistant to create the Connector. Once is done, you can use chatGPT to find hotels using natural language:
|
||||
|
||||
![./assets/studio06.png](./assets/studio06.png)
|
||||
|
||||
The webpart offers the same functionality, showing how to call the Azure OpenAI API, with a pre-configured Data source.
|
||||
|
||||
__Note__: this is an experimental sample, based on the preview of the Azure OpenAI service, and the preview of the Data Connectors. Ensure you check the _prerequisites_ section if you are planning to run this sample.
|
||||
|
||||
## Used SharePoint Framework Version
|
||||
|
||||
|
@ -15,24 +40,29 @@ Short summary on functionality and used technologies.
|
|||
- [SharePoint Framework](https://aka.ms/spfx)
|
||||
- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||
|
||||
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
> Any special pre-requisites?
|
||||
- Your Azure Subscription has the Azure OpenAI service available. You will see this message if you try to add Azure OpenAI service in your Subscription (follow the link in the Azure portal to request access).
|
||||
|
||||
> Azure OpenAI Service is currently available to customers via an application form. The selected subscription has not been enabled for use of the service and does not have quota for any pricing tiers. Click here to request access to Azure OpenAI service.
|
||||
|
||||
- You have created an Azure OpenAI service in your subscription (create it in a US region, as some features may not be available in other regions)
|
||||
- Grab the Azure OpenAI Key (go to your _Azure OpenAI service -> Keys and Endpoint_)
|
||||
- You have configured an Azure Search service with at least a Basic plan (Free tier is not working with the Azure OpenAI Connectors feature), and have deployed the "Hotels" index that is provided as sample by Microsoft.
|
||||
- Grab the Azure Search endpoint URL (you can see it in the _Overview_ section)
|
||||
- Grab the Azure Search API key (_Keys_ section)
|
||||
|
||||
## Solution
|
||||
|
||||
| Solution | Author(s) |
|
||||
| ----------- | ------------------------------------------------------- |
|
||||
| folder name | Author details (name, company, twitter alias with link) |
|
||||
| react-azure-openai-connector | [Luis Mañez](https://github.com/luismanez) ([ClearPeople LTD](https://www.clearpeople.com)) |
|
||||
|
||||
## Version history
|
||||
|
||||
| Version | Date | Comments |
|
||||
| ------- | ---------------- | --------------- |
|
||||
| 1.1 | March 10, 2021 | Update comment |
|
||||
| 1.0 | January 29, 2021 | Initial release |
|
||||
| 1.0 | July 26, 2023 | Initial release |
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
@ -42,32 +72,30 @@ Short summary on functionality and used technologies.
|
|||
|
||||
## Minimal Path to Awesome
|
||||
|
||||
- Install the MS Graph Toolkit for SPFx package. [Follow this](https://learn.microsoft.com/en-us/graph/toolkit/get-started/mgt-spfx)
|
||||
- Clone this repository
|
||||
- Ensure that you are at the solution folder
|
||||
- Edit the file __Constants.ts__ with your values (see _prerequisites_ section)
|
||||
- in the command-line run:
|
||||
- **npm install**
|
||||
- **gulp serve**
|
||||
- Add the webpart in the SharePoint workbench or any SharePoint page (appending _?debug=true&noredir=true&debugManifestsFile=https://localhost:4321/temp/manifests.js_ to the page URL)
|
||||
|
||||
> Include any additional steps as needed.
|
||||
|
||||
## Features
|
||||
|
||||
Description of the extension that expands upon high-level summary above.
|
||||
|
||||
This extension illustrates the following concepts:
|
||||
|
||||
- topic 1
|
||||
- topic 2
|
||||
- topic 3
|
||||
|
||||
> Notice that better pictures and documentation will increase the sample usage and the value you are providing for others. Thanks for your submissions advance.
|
||||
|
||||
> Share your web part with others through Microsoft 365 Patterns and Practices program to get visibility and exposure. More details on the community, open-source projects and other activities from http://aka.ms/m365pnp.
|
||||
- Calling Azure OpenAI _completions_ endpoint with a configured Azure Search connector
|
||||
- Using MS Graph toolkit with the Person component
|
||||
- Multiple FluentUI components
|
||||
|
||||
## References
|
||||
|
||||
- [Azure OpenAI REST API completions endpoint](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions)
|
||||
- [MS Graph toolkit for SPFx installation](https://learn.microsoft.com/en-us/graph/toolkit/get-started/mgt-spfx)
|
||||
- [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||
- [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview)
|
||||
- [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
|
||||
- [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview)
|
||||
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development
|
||||
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development
|
After Width: | Height: | Size: 3.4 MiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 188 KiB |
After Width: | Height: | Size: 169 KiB |
After Width: | Height: | Size: 224 KiB |
After Width: | Height: | Size: 212 KiB |
|
@ -1,25 +1,25 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||
"solution": {
|
||||
"name": "react-azure-openai-connector-client-side-solution",
|
||||
"name": "Azure OpenAI Data Connector sample",
|
||||
"id": "8825f8b6-a323-4c34-abf5-29009d24a929",
|
||||
"version": "1.0.0.0",
|
||||
"includeClientSideAssets": true,
|
||||
"skipFeatureDeployment": true,
|
||||
"isDomainIsolated": false,
|
||||
"developer": {
|
||||
"name": "",
|
||||
"websiteUrl": "",
|
||||
"name": "Luis Mañez",
|
||||
"websiteUrl": "https://github.com/luismanez",
|
||||
"privacyUrl": "",
|
||||
"termsOfUseUrl": "",
|
||||
"mpnId": "Undefined-1.17.4"
|
||||
},
|
||||
"metadata": {
|
||||
"shortDescription": {
|
||||
"default": "react-azure-openai-connector description"
|
||||
"default": "Using Azure OpenAI with Data connectors"
|
||||
},
|
||||
"longDescription": {
|
||||
"default": "react-azure-openai-connector description"
|
||||
"default": "The webpart is calling the Azure OpenAI API, with a specific Data source configured to an existing Azure Search service that contains the Hotels index provided by Microsoft."
|
||||
},
|
||||
"screenshotPaths": [],
|
||||
"videoUrl": "",
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
export default class Constants {
|
||||
public static readonly AzureOpenAiApiKey: string = '{YOUR-VALUE}';
|
||||
public static readonly AzureSearchKey: string = '{YOUR-VALUE}';
|
||||
public static readonly AzureSearchEndpoint: string = 'https://{YOUR-VALUE}';
|
||||
public static readonly AzureSearchIndexName: string = '{YOUR-VALUE}';
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
import * as React from "react";
|
||||
//import styles from './OurHotelsFinder.module.scss';
|
||||
import { IOurHotelsFinderProps } from "./IOurHotelsFinderProps";
|
||||
import MessagesList from "./MessagesList";
|
||||
import { DirectionalHint, Icon, Stack, Text, TooltipHost } from "@fluentui/react";
|
||||
import { Stack } from "@fluentui/react";
|
||||
import UserMessage from "./UserMessage";
|
||||
import { IOurHotelsFinderState } from "./IOurHotelsFinderState";
|
||||
import CompletionsService from "../services/CompletionsService";
|
||||
|
@ -59,31 +58,6 @@ export default class OurHotelsFinder extends React.Component<IOurHotelsFinderPro
|
|||
|
||||
return (
|
||||
<Stack tokens={{ childrenGap: 20 }} style={{ minHeight: "100%" }}>
|
||||
<Stack.Item>
|
||||
<Stack
|
||||
horizontal
|
||||
tokens={{ childrenGap: 10 }}
|
||||
verticalAlign="center"
|
||||
styles={{
|
||||
root: {
|
||||
backgroundColor: "#D4AF37",
|
||||
color: "white",
|
||||
padding: "10px",
|
||||
borderRadius: "5px",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Icon iconName="Hotel" styles={{ root: { fontSize: "20px" } }} />
|
||||
<Text variant="large" styles={{ root: { fontWeight: "bold" } }}>
|
||||
Our Hotels
|
||||
</Text>
|
||||
<TooltipHost
|
||||
content="This webpart allows you to find Hotels in our Database"
|
||||
directionalHint={DirectionalHint.bottomCenter}>
|
||||
<Icon iconName="Info" styles={{ root: { fontSize: '16px', marginLeft: '10px' } }}/>
|
||||
</TooltipHost>
|
||||
</Stack>
|
||||
</Stack.Item>
|
||||
<Stack.Item
|
||||
grow={1}
|
||||
styles={{
|
||||
|
|
|
@ -10,9 +10,9 @@ export default class CompletionsRequestBuilder {
|
|||
dataSources: [{
|
||||
type: "AzureCognitiveSearch",
|
||||
parameters: {
|
||||
endpoint: "https://srch-atlas-cp-dev.search.windows.net",
|
||||
endpoint: Constants.AzureSearchEndpoint,
|
||||
key: Constants.AzureSearchKey,
|
||||
indexName: "hotels-openai-test-index-lml",
|
||||
indexName: Constants.AzureSearchIndexName,
|
||||
semanticConfiguration: "",
|
||||
queryType: "simple",
|
||||
fieldsMapping: {
|
||||
|
|