|
| 1 | +# NetApp Workload Factory GenAI sample application |
| 2 | + |
| 3 | +## Introduction |
| 4 | +The NetApp Workload Factory GenAI sample application enables external application developers to test authentication and retrieval from a published NetApp Workload Factory knowledge base by interacting directly with it in a web-based chatbot application. Its features are similar to the chatbot interface within the NetApp Workload Factory UI, and it uses the same Workload Factory API for conversations. As a developer, you can use this sample application to test published knowledge bases and see API examples that can help you develop your own chatbot application. |
| 5 | + |
| 6 | +## Application components |
| 7 | +The NetApp Workload Factory GenAI sample application is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). |
| 8 | + |
| 9 | +The sample application uses [Redux Toolkit](https://redux-toolkit.js.org) with [RTK Query](https://redux-toolkit.js.org/tutorials/rtk-query) for data fetching. |
| 10 | + |
| 11 | +## Requirements |
| 12 | +- [Node.js](https://nodejs.org/) 18.17 or later stable version. |
| 13 | +- The NetApp Workload Factory GenAI sample application relies on one of the following login providers: |
| 14 | + - [Amazon Cognito](https://aws.amazon.com/cognito/) + [Amazon Amplify Framework](https://aws-amplify.github.io/docs/js/start) |
| 15 | + - [Clerk](https://clerk.com/) |
| 16 | +- You need a knowledge base created with NetApp Workload Factory GenAI that is configured for active authentication and published: |
| 17 | + - [Activate external authentication for a knowledge base](https://docs.netapp.com/us-en/workload-genai/activate-authentication.html) |
| 18 | + - [Publish a knowledge base](https://docs.netapp.com/us-en/workload-genai/publish-knowledgebase.html) |
| 19 | +- You need the ID of the published knowledge base. You can find the knowledge base ID on the **Knowledge bases > Manage knowledge base** page in Workload Factory GenAI, or you can work with the person that created the knowledge base. |
| 20 | + |
| 21 | +## Set up login providers |
| 22 | +To get started, you need to configure one of the supported login providers. Configure the same login provider (issuer) that is used by the knowledge base that will integrate with the sample chatbot application. |
| 23 | + |
| 24 | +### Set up AWS Cognito |
| 25 | +1. Follow the [Create user pool](https://www.cognitobuilders.training/20-lab1/20-setup-and-explore/10-create-userpool/) instructions to create a Cognito user pool. |
| 26 | +2. Use the Amazon Cognito documentation to find your user pool ID and user web client ID: |
| 27 | + 1. [Find your user pool ID](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cognito-idp/list-user-pools.html). |
| 28 | + For example: `aws cognito-idp list-user-pools --max-results=60 --output=table` |
| 29 | + 2. [Find your web client ID](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cognito-idp/list-user-pool-clients.html). |
| 30 | + For example: `aws cognito-idp list-user-pool-clients --user-pool-id $(USER_POOL_ID) --output=table` |
| 31 | +3. Download and unpack the Workload Factory GenAI sample application source package. |
| 32 | +4. In the Workload Factory GenAI sample application source, rename the `.env.local.sample` file to `.env.local`. |
| 33 | +5. In the `.env.local` file, uncomment the corresponding section for the login provider you plan to use, and make sure the section for the other provider is commented out. |
| 34 | +6. In the `.env.local` file, change the following variables in the appropriate provider section to match your environment. Replace `YOUR_KNOWLEDGE_BASE_ID` with the knowledge base ID from Workload Factory: |
| 35 | + - NEXT_PUBLIC_LOGIN_PROVIDER=cognito |
| 36 | + - NEXT_PUBLIC_KNOWLEDGE_BASE_ID=YOUR_KNOWLEDGE_BASE_ID |
| 37 | + - NEXT_PUBLIC_AWS_USER_POOLS_ID=YOUR_AWS_USER_POOLS_ID |
| 38 | + - NEXT_PUBLIC_AWS_USER_WEB_CLIENT_ID=YOUR_AWS_USER_WEB_CLIENT_ID |
| 39 | + |
| 40 | +### Set up Clerk |
| 41 | +1. Follow the [Sign up](https://dashboard.clerk.com/sign-in?redirect_url=https%3A%2F%2Fdashboard.clerk.com%2F) instructions to sign up for a Clerk account. |
| 42 | +2. Download and unpack the Workload Factory GenAI sample application source package. |
| 43 | +3. In the Workload Factory GenAI sample application source, rename the `.env.local.sample` file to `.env.local`. |
| 44 | +4. In the `.env.local` file, uncomment the corresponding section for the login provider you plan to use, and make sure the section for the other provider is commented out. |
| 45 | +5. In the `.env.local` file, change the following variables in the appropriate provider section to match your environment. Replace `YOUR_KNOWLEDGE_BASE_ID` with the knowledge base ID from Workload Factory: |
| 46 | + - NEXT_PUBLIC_LOGIN_PROVIDER=clerk |
| 47 | + - NEXT_PUBLIC_KNOWLEDGE_BASE_ID=YOUR_KNOWLEDGE_BASE_ID |
| 48 | + - NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=YOUR_NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY |
| 49 | + - CLERK_SECRET_KEY=YOUR_CLERK_SECRET_KEY |
| 50 | + - NEXT_PUBLIC_CLERK_TEMPLATE=YOUR_CLERK_TEMPLATE |
| 51 | + |
| 52 | +## Download the application |
| 53 | +To download the application, clone the GitHub repository. Then, change to the sample application directory so that you can build or run it: |
| 54 | + |
| 55 | +1. |
| 56 | + ```bash |
| 57 | + git clone https://github.com/NetApp/FSx-ONTAP-samples-scripts |
| 58 | + ``` |
| 59 | + |
| 60 | +2. |
| 61 | + ```bash |
| 62 | + cd FSx-ONTAP-samples-scripts/AI/GenAI-ChatBot-application-sample |
| 63 | + ``` |
| 64 | + |
| 65 | +## Install dependencies |
| 66 | +To install dependencies for the sample application, run the following command: |
| 67 | + |
| 68 | +```bash |
| 69 | +npm install |
| 70 | +``` |
| 71 | + |
| 72 | +## Run the application |
| 73 | +1. To run the application locally, run the following command: |
| 74 | + |
| 75 | + ```bash |
| 76 | + npm run dev |
| 77 | + ``` |
| 78 | + |
| 79 | +2. Open [http://localhost:9091](http://localhost:9091) with your browser to log in to the application. |
| 80 | + |
| 81 | +## Build the application |
| 82 | +To build bundle.js, run the following command: |
| 83 | + |
| 84 | +```bash |
| 85 | +npm run build |
| 86 | +``` |
| 87 | + |
| 88 | +## Learn More |
| 89 | + |
| 90 | +- Learn more about [BlueXP Workload Factory for AWS](https://docs.netapp.com/us-en/workload-genai/index.html). |
| 91 | +- Learn more about the APIs used in this sample application by visiting the [Workload Factory API documentation](https://console.workloads.netapp.com/api-doc). |
| 92 | +- To learn more about Next.js, take a look at the following resources: |
| 93 | + - [Next.js documentation](https://nextjs.org/docs) - learn about Next.js features and API. |
| 94 | + - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. |
| 95 | + |
| 96 | +## Author Information |
| 97 | + |
| 98 | +This repository is maintained by the contributors listed on [GitHub](https://github.com/NetApp/FSx-ONTAP-samples-scripts/graphs/contributors). |
| 99 | + |
| 100 | +## License |
| 101 | + |
| 102 | +Licensed under the Apache License, Version 2.0 (the "License"). |
| 103 | + |
| 104 | +You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0). |
| 105 | + |
| 106 | +Unless required by applicable law or agreed to in writing, software distributed under the License |
| 107 | +is distributed on an _"AS IS"_ basis, without WARRANTIES or conditions of any kind, either express or implied. |
| 108 | + |
| 109 | +See the License for the specific language governing permissions and limitations under the License. |
| 110 | + |
| 111 | +© 2024 NetApp, Inc. All Rights Reserved. |
0 commit comments