{"id":27370161,"url":"https://github.com/datastaxdevs/workshop-rag-fashion-buddy","last_synced_at":"2025-04-13T08:48:11.346Z","repository":{"id":237640988,"uuid":"794946459","full_name":"datastaxdevs/workshop-rag-fashion-buddy","owner":"datastaxdevs","description":"Material and step by step instructions for the Fashion Buddy workshop","archived":false,"fork":false,"pushed_at":"2024-05-16T14:34:47.000Z","size":12010,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-17T14:59:42.900Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datastaxdevs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-02T09:24:47.000Z","updated_at":"2024-05-16T14:34:50.000Z","dependencies_parsed_at":"2024-05-02T22:31:27.865Z","dependency_job_id":null,"html_url":"https://github.com/datastaxdevs/workshop-rag-fashion-buddy","commit_stats":null,"previous_names":["datastaxdevs/workshop-rag-fashion-buddy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datastaxdevs%2Fworkshop-rag-fashion-buddy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datastaxdevs%2Fworkshop-rag-fashion-buddy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datastaxdevs%2Fworkshop-rag-fashion-buddy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datastaxdevs%2Fworkshop-rag-fashion-buddy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datastaxdevs","download_url":"https://codeload.github.com/datastaxdevs/workshop-rag-fashion-buddy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248688189,"owners_count":21145762,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-13T08:48:09.922Z","updated_at":"2025-04-13T08:48:11.330Z","avatar_url":"https://github.com/datastaxdevs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Workshop RAG 👢Fashion Buddy 🧥 !\n\n[![License Apache2](https://img.shields.io/hexpm/l/plug.svg)](http://www.apache.org/licenses/LICENSE-2.0)\n[![Discord](https://img.shields.io/discord/685554030159593522)](https://discord.com/widget?id=685554030159593522\u0026theme=dark)\n\n\u003e ⚠️ Difficulty: **`Beginners`, we expect you to read some python code.**\n\nLearn how to build an app end-to-end application with multi-modal retrieval augmented generation (RAG) and vector search using Astra DB, Vertex AI, and Gemini.\n\n## 📋 Table of content\n\n**HOUSEKEEPING**\n- [Objectives](#objectives)\n- [Frequently asked questions](#frequently-asked-questions)\n- [Materials for the Session](#materials-for-the-session)\n\n[**LAB1 - Environment Setup**](#lab1---environment-setup)\n- [1.1 - Create Astra Account](#11---create-astra-account)\n- [1.2 - Create Astra Database](#12---create-astra-database)\n- [1.3 - Create VertexAI account](#13-get-your-credentials)\n- [1.4 - Get your credentials](#14---create-vertexai-account)\n- [1.5 - VertexAI Studio](#15---vertexai-studio)\n\n[**LAB2 - Google Collab**](#lab2---google-collab)\n- [2.1 - Run Google Collab](#21---run-google-collab)\n- [2.2 - Vector Search in AstraDB](#22---vector-search-in-astradb)\n\n[**LAB3 - Streamlit application**](#lab3---streamlit-application)\n- [3.1 - Setup your environment](#31---setup-your-environment)\n- [3.2 - Run the application](#32---run-the-application)\n- [3.3 - Deploy the application](#33---deploy-the-application)\n\n## HouseKeeping\n\n### Objectives\n\n* Discover how to use the following technologies:\n    * **Google Gemini:** The latest large language model from Google\n    * **Langchain** the leading framework for building application in generative AI\n    * **RagStackAI** libraries provided by DataStax to ease the use of langchain\n    * **GoogleCollab:** a notebook environment that runs in the cloud    \n    * **StreamLit**  an easy way to build application with user interfaces in python\n    * **Github workspaces:**  a full IDE in the cloud\n    \n    * **Astra DB** (a Database-as-a-service built on Apache Cassandra)\n  \n* Han fun with an interactive session\n\n### Frequently asked questions\n\n\u003cp/\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e 1️⃣ Can I run this workshop on my computer?\u003c/b\u003e\u003c/summary\u003e\n\u003chr\u003e\n\u003cp\u003eThere is nothing preventing you from running the workshop on your own machine, If you do so, you will need the following\n\u003col\u003e\n\u003cli\u003e\u003cb\u003egit\u003c/b\u003e installed on your local system\n\u003cli\u003e\u003cb\u003ePython 3.8+\u003c/b\u003e installed on your local system\n\u003c/ol\u003e\n\u003c/p\u003e\nIn this readme, we try to provide instructions for local development as well - but keep in mind that the main focus is development on Gitpod, hence \u003cstrong\u003eWe can't guarantee live support\u003c/strong\u003e about local development in order to keep on track with the schedule. However, we will do our best to give you the info you need to succeed.\n\u003c/details\u003e\n\u003cp/\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e 2️⃣ What other prerequisites are required?\u003c/b\u003e\u003c/summary\u003e\n\u003chr\u003e\n\u003cul\u003e\n\u003cli\u003eYou will need an enough *real estate* on screen, we will ask you to open a few windows and it does not file mobiles (tablets should be OK)\n\u003cli\u003eYou will need a GitHub account eventually a google account for the Google Authentication (optional)\n\u003cli\u003eYou will need an Astra account: don't worry, we'll work through that in the following\n\u003cli\u003eYou will need a Vertex AI Account: don't worry, we'll work through that in the following\n\u003cli\u003eYou will need a Streamlit Account: don't worry, we'll work through that in the following\n\u003c/ul\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\u003cp/\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e 3️⃣ Do I need to pay for anything for this workshop?\u003c/b\u003e\u003c/summary\u003e\n\u003chr\u003e\n\u003cb\u003eNo.\u003c/b\u003e All tools and services we provide here are FREE. FREE not only during the session but also after.\n\u003c/details\u003e\n\n\u003e [🏠 Back to Table of Contents](#-table-of-content)\n\n### Materials for the Session\n\nIt doesn't matter if you join our workshop live or you prefer to work at your own pace,\nwe have you covered. In this repository, you'll find everything you need for this workshop:\n\n- [Slide deck](/slides/slides.pdf)\n- [Discord chat](https://dtsx.io/discord)\n\n----\n## LAB1 - Environment Setup\n\n### 1.1 - Create Astra Account\n\n- Access [https://astra.datastax.com](https://astra.datastax.com) and register with `Google` or `Github` account. It is free to use. There is free forever tiers of up to 25$ of consumption every month.\n\n![](https://awesome-astra.github.io/docs/img/astra/astra-signin-github-0.png)\n\n### 1.2 - Create Astra Database\n\n\u003e If you are creating a new account, you will be brought to the DB-creation form directly.\n\n- Get to the databases dashboard (by clicking on Databases in the left-hand navigation bar, expanding it if necessary), and click the `[Create Database]` button on the right.\n\n![](https://datastaxdevs.github.io/langchain4j/langchain4j-1.png)\n\n- **ℹ️ Fields Description**\n\n| Field                                      | Description                                                                                                                                                                                                                                   |\n|--------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **Vector Database vs Serverless Database** | Choose `Vector Database` In june 2023, Cassandra introduced the support of vector search to enable Generative AI use cases.                                                                                                                   |\n| **Database name**                          | It does not need to be unique, is not used to initialize a connection, and is only a label (keep it between 2 and 50 characters). It is recommended to have a database for each of your applications. The free tier is limited to 5 databases. |\n| **Cloud Provider**                         | Choose whatever you like. Click a cloud provider logo, pick an Area in the list and finally pick a region. We recommend choosing a region that is closest to you to reduce latency. In free tier, there is very little difference.            |\n| **Cloud Region**                           | Pick region close to you available for selected cloud provider and your plan.                                                                                                                                                                 |\n\nIf all fields are filled properly, clicking the \"Create Database\" button will start the process.\n\n![](https://datastaxdevs.github.io/langchain4j/langchain4j-2.png)\n\nIt should take a couple of minutes for your database to become `Active`.\n\n![](https://datastaxdevs.github.io/langchain4j/langchain4j-3.png)\n\n### 1.3. Get your credentials\n\nTo connect to your database, you need the API Endpoint and a token. The api endpoint is available on the database screen, there is a little icon to copy the URL in your clipboard. (it should look like `https://\u003cdb-id\u003e-\u003cdb-region\u003e.apps.astra.datastax.com`).\n\n![](https://datastaxdevs.github.io/langchain4j/langchain4j-4.png)\n\nTo get a token click the `[Generate Token]` button on the right. It will generate a token that you can copy to your clipboard.\n\n### 1.4 - Create VertexAI account\n\nhttps://console.cloud.google.com/\n\n### 1.5 - VertexAI Studio\n\n- Create a new project by clicking on the `Select a project` dropdown and then clicking on `New Project`\n\n![](assets/vertex-01.png)\n\n- Name your project and click on `Create`\n\n![](assets/vertex-02.png)\n\n- Make sure to select the project, then in the navigation menu, click on `Vertex AI`.\n\n![](assets/vertex-03.png)\n\n![](assets/vertex-04.png)\n\n- Enable all Api for Vertex AI (make sure to have your billing account or free credit setup_)\n\n![](assets/vertex-05.png)\n\n- You should agree with the condition\n\n![](assets/vertex-06.png)\n\n- And then you should be able to access the Vertex AI Studio\n\n![](assets/vertex-07.png)\n\n- Select `Try Gemini` \n\n![](assets/vertex-08.png)\n\n- Here we can pick a multi-modal model to use for our application\n\n![](assets/vertex-09.png)\n\n## LAB2 - Google Collab\n\n### 2.1 - Run Google Collab \n\n* Download your service account key as a json file from Google Cloud console. Record the path to this json file. [See instructions here](https://cloud.google.com/iam/docs/keys-create-delete)\n* Create a `.env` file in the same directory as `fashion_buddy.py`\n* Copy/paste the following into your `.env` file and replace with your environment variables.\n```\nGCP_PROJECT_ID = \"\u003cYOUR_GCP_PROJECT_ID\u003e\"\nASTRA_DB_TOKEN= \"AstraCS:...\"\nASTRA_API_ENDPOINT= \"https://\u003cDATABASE_ID\u003e-\u003cREGION\u003e.apps.astra.datastax.com\"\nGOOGLE_APPLICATION_CREDENTIALS_PATH= \u003c./PATH/TO/YOUR/GOOGLE_SERVICE_ACCOUNT_KEY.json\u003e\n```\n\n\nTo kick this workshop off, we'll first try the concepts in a [Colab Notebook](https://colab.research.google.com/drive/1CwXdjFvJHQaCphtlNWrcviWbUpTvtbQX?authuser=0#scrollTo=Gr9FQy3o64TW)\n\nThis notebook shows the steps to take to use the Astra DB Vector Store as a means to make LLM interactions meaningfull and without hallucinations. The approach taken here is Retrieval Augmented Generation.\n\nYou'll learn:\n\n1. About the content in a CNN dataset (we'll use the news article about Daniel Radcliffe in this example)\n2. How to interact with the OpenAI Chat Model without providing this context\n3. How to load this context into Astra DB Vector Store\n4. How to run a semantic similarity search on Astra DB Vector Store\n5. How to use this context with the OpenAI Chat Model\n\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1CwXdjFvJHQaCphtlNWrcviWbUpTvtbQX)\n\n### 2.2 - Vector Search in AstraDB\n\n## LAB3 - Streamlit application\n\n### 3.1 - Setup your environment\n\n- Follow the steps outlined [here](https://docs.streamlit.io/streamlit-community-cloud/get-started/quickstart).\n\n![](assets/streamlit.png)\n\nlet's get started with coding. Click `Create codespace on main` as follows:\n\n![codespace](./assets/create-codespace.png)\n\nAnd you're ready to rock and roll! 🥳  \nAs Codespaces creates your dev environment based on `Python 3.11`, it will automatically install the Python dependecies from `requirements.txt`. So, no need to `pip install` anything here. It will also set up prt forwarding so you can access subsequent Streamlit apps from anywhere.  \nWhen the codespace start up, it will run a Streamlit Hello World app for you which shows some of the awesome capabilities of this UI framework. When you're done playing, just click `ctrl-c` in the `terminal` to stop running it.\n\n\n### 3.2 - Run the application\n\n- Access the folder\n\n```bash\ncd streamlit_app\n```\n\n- Copy your Service account files in \n\n```console\n/workspaces/workshop-rag-fashion-buddy/streamlit_app/.streamlit/secret.json\n```\n\n- Define the environment Variable\n\n```console\nexport GOOGLE_APPLICATION_CREDENTIALS=\"/workspaces/workshop-rag-fashion-buddy/streamlit_app/.streamlit/secret.json\"\n```\n\n- Open and change the file `secrets.toml`\n\n```console\nGCP_PROJECT_ID= \"\"\n\n# Astra DB secrets\nASTRA_API_ENDPOINT = \"\"\nASTRA_DB_TOKEN = \"\"\n```\n\n- Now run the application\n\n```\nstreamlit run fashion_buddy.py\n```\n\n  ![Streamlit](./assets/running.png)\n\n### 3.3 - Deploy the application\n\nIn this step we'll deploy your awesome app to the internet so everyone can enjoy your cool work and be amazed!\n\n- Set up your Streamlit account\n\nIf you have not do so before, please set up your account on Streamlit. When you already have an account skip to the next step and deploy the app.\n\n1. Head over to [Streamlit.io](https://streamlit.io) and clikc `Sign up`. Then select `Continue with Github`:\n\n    ![Streamlit](./assets/streamlit-0.png)\n\n2. Log in using your Github credentials:\n\n    ![Streamlit](./assets/streamlit-1.png)\n\n3. Now authorize Streamlit:\n\n    ![Streamlit](./assets/streamlit-2.png)\n\n4. And set up your account:\n\n    ![Streamlit](./assets/streamlit-3.png)\n\n### Deploy your app\n\nOn the main screen, when logged in, click `New app`.\n\n1. When this is your first deployment, provide additional permissions:\n\n    ![Streamlit](./assets/streamlit-4.png)\n\n2. Now define your application settings. Use YOUR repository name, and name the Main file path as `app_7.py`. Pick a cool App URL as you'll app will be deployed to that:\n\n    ![Streamlit](./assets/streamlit-5.png)\n\n3. Click on Advanced, select Python 3.11 and copy-paste the contents from your `secrets.toml`.\n\nClick Deploy! Wait for a bit and your app is online for everyone to use!\n\n⛔️ Be aware that this app is public and uses your OpenAI account which will incur cost. You'll want to shield it off by clicking `Settings-\u003eSharing` in the main screen and define the email addresses that are allowed access. In order to enable this, link your Google account.\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatastaxdevs%2Fworkshop-rag-fashion-buddy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatastaxdevs%2Fworkshop-rag-fashion-buddy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatastaxdevs%2Fworkshop-rag-fashion-buddy/lists"}