Skip to content

Latest commit

 

History

History
234 lines (208 loc) · 8.21 KB

README.md

File metadata and controls

234 lines (208 loc) · 8.21 KB

GitHub Models Samples - JavaScript

This folder contains samples for interacting with GitHub Models using JavaScript.

Multiple model-specific SDKs are compatible with the endpoint served under the GitHub Models catalog, such as openai and mistralai packages for their respective models. This makes it easy to port your existing code using one of those SDKs.

You can also use the azure-ai-inference package for a cross-model unified SDK.

SDKs

Running a sample

To run a JavaScript sample, a command like the following in your terminal:

node samples/js/azure_ai_inference/multi_turn.js
<title>Ezonline Shopping HY – Fashion & Accessories</title> <style> body { font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f8f8f8; } .container { max-width: 1200px; margin: auto; padding: 20px; } h1 { text-align: center; } .filters { display: flex; justify-content: space-between; align-items: center; background: white; padding: 10px; border-radius: 5px; margin-bottom: 20px; } .filter-group { display: flex; gap: 10px; } select, input { padding: 8px; border: 1px solid #ccc; border-radius: 5px; } .product-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; } .product-card { background: white; padding: 15px; border-radius: 5px; text-align: center; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1); } .product-card img { width: 100%; height: auto; border-radius: 5px; } .product-card h3 { margin: 10px 0; font-size: 18px; } .product-card p { font-size: 14px; color: #555; } .product-card .price { font-weight: bold; color: #e44d26; } .product-card .add-to-cart { background-color: #e44d26; color: white; padding: 8px 15px; border: none; border-radius: 5px; cursor: pointer; margin-top: 10px; } </style>
<div class="container">
    <h1>Fashion & Accessories</h1>

    <!-- Filters Section -->
    <div class="filters">
        <div class="filter-group">
            <label for="category">Category:</label>
            <select id="category">
                <option value="all">All</option>
                <option value="dresses">Dresses</option>
                <option value="underwear">Underwear</option>
                <option value="bags">Bags</option>
                <option value="jewelry">Jewelry</option>
                <option value="shoes">Shoes</option>
            </select>
        </div>

        <div class="filter-group">
            <label for="price">Price Range:</label>
            <select id="price">
                <option value="all">All</option>
                <option value="0-50">$0 - $50</option>
                <option value="50-100">$50 - $100</option>
                <option value="100-200">$100 - $200</option>
            </select>
        </div>

        <div class="filter-group">
            <label for="sort">Sort By:</label>
            <select id="sort">
                <option value="popular">Most Popular</option>
                <option value="price-low">Price: Low to High</option>
                <option value="price-high">Price: High to Low</option>
            </select>
        </div>
    </div>

    <!-- Product Grid -->
    <div class="product-grid" id="productGrid">
        <!-- Placeholder Products -->
        <div class="product-card" data-category="dresses" data-price="60">
            <img src="https://via.placeholder.com/250" alt="Dress">
            <h3>Elegant Evening Dress</h3>
            <p>Perfect for special occasions</p>
            <p class="price">$60</p>
            <button class="add-to-cart">Add to Cart</button>
        </div>

        <div class="product-card" data-category="underwear" data-price="25">
            <img src="https://via.placeholder.com/250" alt="Underwear">
            <h3>Silk Lingerie Set</h3>
            <p>Soft & comfortable</p>
            <p class="price">$25</p>
            <button class="add-to-cart">Add to Cart</button>
        </div>

        <div class="product-card" data-category="bags" data-price="120">
            <img src="https://via.placeholder.com/250" alt="Bag">
            <h3>Luxury Handbag</h3>
            <p>Elegant & stylish</p>
            <p class="price">$120</p>
            <button class="add-to-cart">Add to Cart</button>
        </div>

        <div class="product-card" data-category="jewelry" data-price="80">
            <img src="https://via.placeholder.com/250" alt="Jewelry">
            <h3>Diamond Necklace</h3>
            <p>Timeless elegance</p>
            <p class="price">$80</p>
            <button class="add-to-cart">Add to Cart</button>
        </div>

        <div class="product-card" data-category="shoes" data-price="60">
            <img src="https://via.placeholder.com/250" alt="Shoes">
            <h3>Fashion Sneakers</h3>
            <p>Trendy & comfortable</p>
            <p class="price">$60</p>
            <button class="add-to-cart">Add to Cart</button>
        </div>
    </div>
</div>

<script>
    document.getElementById("category").addEventListener("change", filterProducts);
    document.getElementById("price").addEventListener("change", filterProducts);
    document.getElementById("sort").addEventListener("change", sortProducts);

    function filterProducts() {
        let category = document.getElementById("category").value;
        let priceRange = document.getElementById("price").value;
        let products = document.querySelectorAll(".product-card");

        products.forEach(product => {
            let productCategory = product.getAttribute("data-category");
            let productPrice = parseInt(product.getAttribute("data-price"));

            let priceMatch = false;
            if (priceRange === "all") {
                priceMatch = true;
            } else {
                let [min, max] = priceRange.split("-").map(Number);
                priceMatch = productPrice >= min && productPrice <= max;
            }

            if ((category === "all" || productCategory === category) && priceMatch) {
                product.style.display = "block";
            } else {
                product.style.display = "none";
            }
        });
    }

    function sortProducts() {
        let sortValue = document.getElementById("sort").value;
        let productGrid = document.getElementById("productGrid");
        let products = Array.from(productGrid.children);

        products.sort((a, b) => {
            let priceA = parseInt(a.getAttribute("data-price"));
            let priceB = parseInt(b.getAttribute("data-price"));

            if (sortValue === "price-low") return priceA - priceB;
            if (sortValue === "price-high") return priceB - priceA;
            return 0;
        });

        productGrid.innerHTML = "";
        products.forEach(product => productGrid.appendChild(product));
    }
</script>