35 lines
894 B
QBasic
35 lines
894 B
QBasic
PARAM product_id AS STRING
|
|
|
|
product = PRODUCT product_id
|
|
IF NOT product THEN
|
|
RETURN {error: "Product not found"}
|
|
END IF
|
|
|
|
IF product.description AND product.brand THEN
|
|
RETURN product
|
|
END IF
|
|
|
|
query = product.name + " " + product.category
|
|
links = SCRAPE_ALL "https://www.google.com/search?q=" + query, "a"
|
|
links = FIRST links, 10
|
|
|
|
enriched = []
|
|
FOR i = 0 TO 2
|
|
IF links[i] THEN
|
|
content = SCRAPE links[i], "body"
|
|
PUSH enriched, content
|
|
END IF
|
|
NEXT
|
|
|
|
result = LLM "Analyze these product descriptions: " + enriched + ". Create best description for: " + product.name + ". Return JSON {description, brand, material, features}"
|
|
|
|
UPDATE "products", product_id, {
|
|
description: result.description,
|
|
brand: result.brand,
|
|
material: result.material,
|
|
external_metadata: result
|
|
}
|
|
|
|
product.description = result.description
|
|
product.brand = result.brand
|
|
RETURN product
|