Skip to content

Commit

Permalink
Migration notice
Browse files Browse the repository at this point in the history
  • Loading branch information
egonrian committed Apr 29, 2024
1 parent 2966914 commit d701d35
Show file tree
Hide file tree
Showing 408 changed files with 2 additions and 202,360 deletions.
378 changes: 2 additions & 376 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,378 +1,4 @@
# Generative AI for Customer Experience Modernization
# The Customer Experience Modernization source code has been migrated to a new Github repo

This repository provides a deployment guide showcasing the application of Google Cloud's Generative AI for Customer Experience Modernization scenarios. It offers detailed, step-by-step guidance for setting up and utilizing the Generative AI tools
[Click this link to go to the new Github Repo](https://github.com/GoogleCloudPlatform/customer-experience-modernization)

## Repository structure

```
.
├── frontend
└── backend-apis
```

- [`/frontend`](/frontend): Source code for demo app.
- [`/backend-apis`](/backend-apis): Source code for backend APIs.


## Demonstrations

In this repository, the following demonstrations are provided:

Persona 1 - Customer
![Persona 1 Architecture](/frontend/src/assets/architectures/p1_uj_1_2.svg)
* **[Customer Search using Vertex AI Search](https://www.youtube.com/watch?v=47jNYuuhbNA)**
* **[Multimodal Search using Vertex AI Vector Search](https://www.youtube.com/watch?v=8-OZmOZTTr4)**
* **[Website on demand translation using Translation AI](https://www.youtube.com/watch?v=tvyoR4dRCqQ)**
* **[Product Recommendations using Vertex AI Recommendations](https://www.youtube.com/watch?v=e5NRvTygZYg)**
* **[Infobot using Vertex AI Conversation](https://www.youtube.com/watch?v=92ulAdbwUoE)**

![Persona 1 Architecture](/frontend/src/assets/architectures/p1_uj_3.svg)
* **[Email answering and hand off using Vertex AI Conversation](https://www.youtube.com/watch?v=lA2s7t3XdV0)**

Persona 2 - Content Creator
![Persona 2 Architecture](/frontend/src/assets/architectures/p2_uj_1_2.svg)
* **[Products and services creation using Vertex AI LLMs for Text and Image Generation, Vertex AI Vector Search and Vision API for labeling](https://www.youtube.com/watch?v=4LeV_Ea9RGQ)**

Persona 3 - Customer Experience Analyst
![Persona 3 Architecture](/frontend/src/assets/architectures/p3_uj_csm.svg)
* **[User Experience analytics using Looker, Firebase Analytics, Firebase Realtime Analytics and Google Analytics](https://www.youtube.com/watch?v=rh5vCWLVdRA)**

Persona 3 - Marketing Integration
![Persona 3 Marketing Architecture](/frontend/src/assets/architectures/p3_uj_marketing.svg)
* **[Gen AI for Marketing](https://github.com/GoogleCloudPlatform/genai-for-marketing)**

Persona 4 - Customer Service Agent
![Persona 4 Architecture](/frontend/src/assets/architectures/p4_uj_1.svg)
* **[Real time translation between user and agent using Translation AI](https://www.youtube.com/watch?v=vaz_KmVxsXc)**
* **[Message rephrasing using Vertex AI LLM](https://www.youtube.com/watch?v=qyPNGotOJA0)**
* **[Company Knowledge and Conversations Lookup and Q&A using Vertex AI Search](https://www.youtube.com/watch?v=fGBEEUxxkXQ)**
* **[Conversation Summary using Vertex AI LLM](https://www.youtube.com/watch?v=6bkEuwrEWOs)**
* **[Meet conversation with end user](https://www.youtube.com/watch?v=JmLJq5f5L0E)**

Persona 5 - Contact Center Analyst
![Persona 5 Architecture](/frontend/src/assets/architectures/p5_uj_1.svg)
* **[Overall KPIs, Sentiment and Agent Performance using Looker](https://www.youtube.com/watch?v=9R1O-TPEUdU)**
* **[Insights from Reviews and Conversations using Vertex AI Search, Vertex AI LLM and Natural Language AI](https://www.youtube.com/watch?v=fh7rzDiEzJw)**
* **[Similarity search using Vertex AI Vector Search](https://www.youtube.com/watch?v=aQO6kb4ja2w)**
* **[Q&A using Vertex AI Search](https://www.youtube.com/watch?v=i_9FDWWcQsI)**

Persona 6 - Field Service Agent
![Persona 6 Architecture](/frontend/src/assets/architectures/p6_uj_1.svg)
* **[Scheduling using Vertex AI Conversation](https://www.youtube.com/watch?v=m10qRO1CAVE)**
* **[Insights from Reviews and Conversations using Vertex AI Search, Vertex AI LLM and Natural Language AI](https://www.youtube.com/watch?v=bu1e0ZIaohQ)**
* **[Q&A using Vertex AI Search and Multimodal Q&A using Gemini](https://www.youtube.com/watch?v=jFBFknOrVac)**


## Select a Google Cloud project

In the Google Cloud Console, on the project selector page, [select or create a Google Cloud project](https://console.cloud.google.com/projectselector2).
> **As this is a DEMONSTRATION, you need to be a project owner in order to set up the environment.**

## Enable the required services

From [Cloud Shell](https://cloud.google.com/shell/docs/using-cloud-shell), run the following commands to enable the required Cloud APIs.
Change `PROJECT_ID` to the id of your project.

```bash
export PROJECT_ID=<CHANGE TO YOUR PROJECT ID>

gcloud config set project $PROJECT_ID

gcloud services enable \
cloudapis.googleapis.com \
cloudbuild.googleapis.com \
cloudresourcemanager.googleapis.com \
cloudtrace.googleapis.com \
compute.googleapis.com \
container.googleapis.com \
containerregistry.googleapis.com \
iam.googleapis.com \
iamcredentials.googleapis.com \
run.googleapis.com \

gcloud services enable \
admin.googleapis.com \
aiplatform.googleapis.com \
appengine.googleapis.com \
appenginereporting.googleapis.com \
artifactregistry.googleapis.com \
bigquery.googleapis.com \
bigquerydatatransfer.googleapis.com \
bigquerymigration.googleapis.com \
bigquerystorage.googleapis.com \
containerfilesystem.googleapis.com \
datacatalog.googleapis.com \
datastore.googleapis.com \
dialogflow.googleapis.com \
discoveryengine.googleapis.com \
docs.googleapis.com \
drive.googleapis.com \
eventarc.googleapis.com \
fcm.googleapis.com \
fcmregistrations.googleapis.com \
firebase.googleapis.com \
firebaseappdistribution.googleapis.com \
firebasedynamiclinks.googleapis.com \
firebasehosting.googleapis.com \
firebaseinstallations.googleapis.com \
firebaseremoteconfig.googleapis.com \
firebaseremoteconfigrealtime.googleapis.com \
firebaserules.googleapis.com \
firebasestorage.googleapis.com \
firestore.googleapis.com \
iap.googleapis.com \
identitytoolkit.googleapis.com \
language.googleapis.com \
logging.googleapis.com \
looker.googleapis.com \
mobilecrashreporting.googleapis.com \
monitoring.googleapis.com \
notebooks.googleapis.com \
oslogin.googleapis.com \
pubsub.googleapis.com \
runtimeconfig.googleapis.com \
secretmanager.googleapis.com \
securetoken.googleapis.com \
servicemanagement.googleapis.com \
serviceusage.googleapis.com \
sourcerepo.googleapis.com \
sqladmin.googleapis.com \
storage-api.googleapis.com \
storage-component.googleapis.com \
storage.googleapis.com \
translate.googleapis.com \
vision.googleapis.com \
```

## Vertex AI Search and Conversation Setup

You must also activate the Vertex AI Search and Conversation API:

- In the Google Cloud console, go to the Search and Conversation page.

- [Search and Conversation](https://console.cloud.google.com/gen-app-builder//start)

- Select your project from the console drop-down.

- Read and agree to the Terms of Service, then click Continue and activate the API.


This demo uses Vertex AI Search and Conversation for Website Search, Website Recommendations, Infobot, Knowledbase Search and Customer Lookup.

### Persona 1 Search

For Persona 1 Search you can use the script provided to upload the products.
```bash
python backend-apis/deployment-scripts/vertex_search_operations.py --project_id PROJECT --location us-central1
```

This will create the `csm-search-engine` using the generated example dataset [search_products.jsonl](backend-apis/deployment_scripts/dataset/search_products.jsonl)

### Persona 1 Recommendations

For Persona 1 Recommendations, upload products and events to Cloud Storage first.

The events should be fresh. Use the provided script to generate events.

```bash
python backend-apis/deployment-scripts/Persona1/media_event_generation.py
```

This will generate a file named `full_media_events.jsonl`.

Upload full_media_events.jsonl and [recommendations_products.jsonl](backend-apis/deployment_scripts/dataset/recommendation_products.jsonl) to Cloud Storage.

[Create a recommendations app](https://cloud.google.com/generative-ai-app-builder/docs/create-app-data-store-media-recommendations) in Vertex AI Search and Conversations using the Console.
Create 1 App for each model, but use the same datastore for all of them.

- csm-media-rec-datastore - Datastore name.

Apps Name

- csm-media-more-like-this - For the `More Like this` model
- csm-media-most-popular - For `Most Popular` model
- csm-media-others-you-maylike - For `Others you may like` model
- csm-media-rec-for-you - For `Recommended for you` model

### Persona 5 Conversations

For Persona 5 Conversations [Create a Search App](https://cloud.google.com/generative-ai-app-builder/docs/create-engine-es) using the Console
- Name: p5-conversations-search
- Dataset: gs://csm-solution-dataset/persona5/conversations_search_dataset.jsonl

### Persona 5 Reviews

For Persona 5 Reviews [Create a Search App](https://cloud.google.com/generative-ai-app-builder/docs/create-engine-es) using the Console
- Name: p5-reviews-search
- Dataset: gs://csm-solution-dataset/persona5/reviews_search_dataset.jsonl

### Infobot

For the infobot Create a Conversation App using the Console
- Name: p6-manuals-infobot
- Dataset: gs://csm-solution-dataset/persona6/argolis_vertexai_search_products_manuals.jsonl

### Persona 6 Manuals search

For Persona 6 Manuals [Create a Search App](https://cloud.google.com/generative-ai-app-builder/docs/create-engine-es) using the Console
- Name: p6-search-manuals
- Dataset: gs://csm-solution-dataset/persona6/argolis_vertexai_search_products_manuals.jsonl

## Firestore Setup
Firestore datasets are used by Persona 5

Upload each file like this:
```python
import json

with open("./full_conversations.jsonl") as f:
lines = f.readlines()
lines = [json.loads(i) for i in lines]

from google.cloud import firestore
db = firestore.Client()

for line in lines:
data = json.loads(line["jsonData"])
db.collection("p5-conversations").document(line["id"]).set(data)
```

p5-customers
- gs://csm-solution-dataset/persona5/customer_list.json

p5-reviews
- gs://csm-solution-dataset/persona5/product_reviews.jsonl

p5-conversations
- gs://csm-solution-dataset/persona5/full_conversations.jsonl

## Cloud SQL
This demo uses Cloud SQL to store product information.

[Create a Cloud SQL Instance](https://cloud.google.com/sql/docs/mysql/create-instance#create-2nd-gen)

- Version: MySQL 8.0
- Name: csm-instance

[Add a Service Account](https://cloud.google.com/sql/docs/mysql/add-manage-iam-users#creating-a-database-user) to the database that will be used by the application

[Upload from backup](https://cloud.google.com/sql/docs/mysql/import-export/import-export-sql#import_a_sql_dump_file_to)
- Database: csm
- 875 products
- gs://csm-solution-dataset/persona1/Cloud_SQL_Export.sql

## Vertex AI Vector Search
This demo uses Vertex AI Vector Search for similarity search

Use the [example](backend-apis/deployment_scripts/vertex_vector_operations.py) to create 3 Vector Search Endpoints

p5-conversations-index - 19250 conversations
- gs://csm-solution-dataset/persona5/conversations-embeddings/vertexai_conversations_embeddings.json

p5-reviews-index - 8750 reviews
- gs://csm-solution-dataset/persona5/reviews-embeddings/vertexai_reviews_embeddings.json

csm-multimodal-vector-search - 875 products
- gs://csm-solution-dataset/persona1/vector_search_website/vector_website_products.jsonl


## Pubsub Setup
Pubsub is used to offload LLM Requests in the website.

[Create 2 Topics](https://cloud.google.com/pubsub/docs/create-topic#create_a_topic_2)

- website-recommendations
- website-search

## Update the backend configuration with information of your project
Open the [configuration file](/backend-apis/app/config.toml) and include your informations.

## Cloud Run Setup
Cloud Run is used to serve the backend APIs.

Deploy cloud run
```bash
cd backend-apis
gcloud run deploy csm-demo --source . --region us-central1
```

Create eventarc for Pubsub + Search
```bash
gcloud eventarc triggers create trigger-unstructured-search \
--destination-run-service=csm-demo \
--destination-run-path=trigger-unstructured-search \
--destination-run-region=us-central1 \
--location=us-central1 \
--event-filters="type=google.cloud.pubsub.topic.v1.messagePublished" \
--transport-topic=projects/PROJECT/topics/website-search
```

Create eventarc for Pubsub + Recommendations
```bash
gcloud eventarc triggers create trigger-unstructured-recommendations \
--destination-run-service=csm-demo \
--destination-run-path=trigger-unstructured-recommendations \
--destination-run-region=us-central1 \
--location=us-central1 \
--event-filters="type=google.cloud.pubsub.topic.v1.messagePublished" \
--transport-topic=projects/PROJECT/topics/website-recommendations
```

## Firebase Hosting app setup
After you have a Firebase project, you can register your web app with that project.

In the center of the Firebase console's project overview page, click the Web icon (plat_web) to launch the setup workflow.

If you've already added an app to your Firebase project, click Add app to display the platform options.

Enter your app's nickname.
This nickname is an internal, convenience identifier and is only visible to you in the Firebase console.

Click Register app.

Copy the information to include in the configuration.

## Update the frontend configuration with information of your project

Open the [frontend environment file](/frontend/src/environments/environment.ts) and include the Firebase information.

## Build Angular Frontend
Angular is the framework for the Frontend

```bash
npm install -g @angular/cli

cd frontend

ng build
```

## Firebase Hosting Setup
Firebase Hosting is used to serve the frontend.

### Install firebase tools
```bash
npm install -g firebase-tools

firebase login
```

### Init hosting
```bash
cd frontend/dist/genai-csm-project

firebase init hosting
```

select browser as public folder


### Deploy hosting
```bash
firebase deploy --only hosting
```

## Getting help

If you have any questions or if you found any problems with this repository, please report through GitHub issues.
Loading

0 comments on commit d701d35

Please sign in to comment.