Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable incremental product embedding #207

Merged
merged 17 commits into from
May 28, 2024

Conversation

dingmeng-xue
Copy link
Collaborator

@dingmeng-xue dingmeng-xue commented May 26, 2024

  • Allow adding, editing, and deleting products
  • Update Assist service:
    • Add a vectorstore, which doesn't calculate the embeddings when provided in the documents
    • Enable adding/updating documents
    • List the index out of date documents
    • Add a job to update the documents for some products
  • Update the source file of bikes.json and accessories.json to have id, which equals to the id of the product sql file, and the vector_store.json.

The command to deploy the job is like:

az spring job deploy --name assist-job \
    --source-path apps/acme-assist \
    --build-env BP_JVM_VERSION=17 \
    --build-env BP_MAVEN_ACTIVE_PROFILES=job \
    --env \
        SPRING_AI_AZURE_OPENAI_ENDPOINT=${SPRING_AI_AZURE_OPENAI_ENDPOINT} \
        SPRING_AI_AZURE_OPENAI_API_KEY=${SPRING_AI_AZURE_OPENAI_API_KEY}

Steps to go through this change:

  1. Update the Spring Cloud Gateway routing rules for catalog service, assist service.

  2. Add a new product, you can enrich the short description and description

    curl --location 'https://xiada-fitness-store-gateway-fa329.svc.azuremicroservices.io/products' \
    --header 'Content-Type: application/json' \
    --data '{
        "imageUrl1": "url1",
        "imageUrl2": "url2",
        "imageUrl3": "url3",
        "name": "xiada",
        "shortDescription": "short desc",
        "description": "desc",
        "price": 299.99,
        "tags": [
            "a",
            "b",
            "c"
        ]
    }'
  3. Update the product, this is optional

    curl --location 'https://xiada-fitness-store-gateway-fa329.svc.azuremicroservices.io/products/07e5785e-c844-41ca-b4cb-d1dfa0a1d383' \
    --header 'Content-Type: application/json' \
    --data '{
        "imageUrl1": "https://www.shutterstock.com/shutterstock/photos/2272933579/display_1500/stock-vector-captain-america-logo-art-design-template-white-background-isolated-2272933579.jpg",
        "imageUrl2": "https://www.shutterstock.com/shutterstock/photos/2272933579/display_1500/stock-vector-captain-america-logo-art-design-template-white-background-isolated-2272933579.jpg",
        "imageUrl3": "https://www.shutterstock.com/shutterstock/photos/2272933579/display_1500/stock-vector-captain-america-logo-art-design-template-white-background-isolated-2272933579.jpg",
        "shortDescription": "this is the short description for the product xiada, and it'\''s the best for hiking",
        "description": "xiada likes hiking, and it can be used in different places"
    }'
  4. Deploy the assist-service, call the list product ids to index. You can see the newly added product is in the returned values.

    curl --location 'https://xiada-fitness-store-gateway-fa329.svc.azuremicroservices.io/ai/admin/products-to-index'
  5. Create and deploy the job, make sure setting the BP_MAVEN_ACTIVE_PROFILES env

    az spring job deploy --name assist-job \
        --source-path apps/acme-assist \
        --build-env BP_JVM_VERSION=17 \
        --build-env BP_MAVEN_ACTIVE_PROFILES=job \
        --env \
            SPRING_AI_AZURE_OPENAI_ENDPOINT=${SPRING_AI_AZURE_OPENAI_ENDPOINT} \
            SPRING_AI_AZURE_OPENAI_API_KEY=${SPRING_AI_AZURE_OPENAI_API_KEY}

Additional change is to unify parameter name SPRING_AI_AZURE_OPENAI_API_KEY and SPRING_AI_AZURE_OPENAI_APIKEY. Use SPRING_AI_AZURE_OPENAI_API_KEY as it is used by Spring AI doc.

nevenc and others added 13 commits May 17, 2024 17:35
- Update Assist service:
  + Add a vectorstore, which doesn't calculate the embeddings when provided in the documents
  + Enable adding/updating documents
  + List the index out of date documents
  + Add a job to update the documents for some products
- Update the source file of bikes.json and accessories.json to have id, which equals to the id of the product sql file, and the vector_store.json.
@dingmeng-xue dingmeng-xue merged commit 7733e13 into Azure-Samples:Azure May 28, 2024
2 checks passed
xtreme-brian-shim pushed a commit to svrc/acme-fitness-store that referenced this pull request Aug 22, 2024
* Adding Azure for Spring Developers full day workshop.

* Adding content for Azure for Spring Developers full day workshop.

* Fixed typo.

* Added lab02.

* Updated Lab02

* Added Lab03

* - Allow adding, editing, and deleting products
- Update Assist service:
  + Add a vectorstore, which doesn't calculate the embeddings when provided in the documents
  + Enable adding/updating documents
  + List the index out of date documents
  + Add a job to update the documents for some products
- Update the source file of bikes.json and accessories.json to have id, which equals to the id of the product sql file, and the vector_store.json.

* Update ProductVo -> ProductValueObject

* Remove files

* Remove day sessions

* Revert doc

* Reverted code around ProductResponse

* Add new product scripts

* update

* Rename OPENAI_APIKEY to OPENAI_API_KEY

* remove bind operation

---------

Co-authored-by: Neven Cvetkovic <neven.cvetkovic@gmail.com>
Co-authored-by: Xiaolu Dai <xiada@microsoft.com>
Co-authored-by: Xiaolu Dai <31124698+saragluna@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants