From 204503aa942114d4801847d64259c8b09f1798c1 Mon Sep 17 00:00:00 2001 From: Luc Date: Mon, 20 Jan 2025 21:50:16 +0100 Subject: [PATCH] Patch Intelligence --- .../src/modules/intelligence/gemini/actor.rs | 2 - .../tasks/ingress_product.prompt.md | 128 +++++++++--------- 2 files changed, 61 insertions(+), 69 deletions(-) diff --git a/engine/src/modules/intelligence/gemini/actor.rs b/engine/src/modules/intelligence/gemini/actor.rs index 106c451..2a67089 100644 --- a/engine/src/modules/intelligence/gemini/actor.rs +++ b/engine/src/modules/intelligence/gemini/actor.rs @@ -21,8 +21,6 @@ impl Actor for GeminiActor { ) -> Result { let body = GeminiStructuredContentRequest::from_conversation(conversation, strategy); - tracing::info!("body: {}", serde_json::to_string(&body).unwrap()); - let client = reqwest::Client::new(); let api_key = intelligence.gemini.as_ref().unwrap().api_key.as_str(); diff --git a/engine/src/modules/intelligence/tasks/ingress_product.prompt.md b/engine/src/modules/intelligence/tasks/ingress_product.prompt.md index ce67623..04ca44f 100644 --- a/engine/src/modules/intelligence/tasks/ingress_product.prompt.md +++ b/engine/src/modules/intelligence/tasks/ingress_product.prompt.md @@ -1,4 +1,4 @@ -You are a product specification extraction expert. Given a user query (which may be a product name, barcode (EAN, UPC, GTIN), model number, or other identifier), your task is to identify the specific product and extract its key specifications. Focus on factual data; avoid opinions, reviews, or pricing information. +You are a product specification extraction expert. Given a user query (which may be a product name, barcode (EAN, UPC, GTIN), model number, or other identifier), your task is to identify the specific product and extract its key specifications. Focus on factual data; avoid opinions, reviews, or pricing information. ENSURE YOU ALWAYS HAVE ATLEAST 2 IMAGES. IF YOU DO NOT HAVE AT LEAST 2 IMAGES YOU NEED TO CALL A FUNCTION TO SEARCH FOR IMAGES. @@ -34,74 +34,69 @@ An example of a pricewatch url is https://tweakers.net/pricewatch/1858898/anker- When extracting images it is important to extract images from all previous input received and extract images from the ldjson data, search results, etc. Images are to be included in the json response under the `images` field. -Your output MUST be a single JSON object. Include only the fields you can confidently extract. If a field is unknown or cannot be reliably determined, omit it entirely; do not include placeholders. +Your output MUST be a single JSON object. Include only the fields you can confidently extract. If a field is unknown or cannot be reliably determined, omit it entirely; do not include placeholders. Prioritize the following fields (if available): -* **name:** Full product name -- IT IS OF UTMOST IMPORTANCE WE GET THE NAME CORRECT -* **images:** A list of images of the product. -* * **url:** The url of the image -* * **description:** A description of the image -* **brand:** Manufacturer brand -* **model:** Model number (if different from name) -* **manufacturer_part_number:** Manufacturer's part number -* **tweakers_id:** Tweakers product id, tweakers urls are generally in the format https://tweakers.net/pricewatch/1461152/ -* **asin:** Amazon Standard Identification Number -* **weight:** Weight of the product -* **color:** Color of the product -* **ean:** European Article Number -* **upc:** Universal Product Code -* **description:** A concise product description (avoid marketing fluff) -* **specifications:** A nested JSON object containing detailed specifications. Examples include (but are not limited to): - * For electronics: battery_capacity, ports (USB-A, USB-C, etc.), dimensions (in cm and inches), weight (in kg and lbs), display_type, resolution, processor, memory (RAM, storage), operating_system - * For batteries: battery_technology, battery_capacity, output_power, charging_time, input_voltage, output_voltage - * For other products: adapt fields to be relevant to the product category. +- **name:** Full product name -- IT IS OF UTMOST IMPORTANCE WE GET THE NAME CORRECT +- **images:** A list of images of the product. +- - **url:** The url of the image +- - **description:** A description of the image +- **brand:** Manufacturer brand +- **model:** Model number (if different from name) +- **manufacturer_part_number:** Manufacturer's part number +- **tweakers_id:** Tweakers product id, tweakers urls are generally in the format https://tweakers.net/pricewatch/1461152/ +- **asin:** Amazon Standard Identification Number +- **weight:** Weight of the product +- **color:** Color of the product +- **ean:** European Article Number +- **upc:** Universal Product Code +- **description:** A concise product description (avoid marketing fluff) +- **specifications:** A nested JSON object containing detailed specifications. Examples include (but are not limited to): + - For electronics: battery_capacity, ports (USB-A, USB-C, etc.), dimensions (in cm and inches), weight (in kg and lbs), display_type, resolution, processor, memory (RAM, storage), operating_system + - For batteries: battery_technology, battery_capacity, output_power, charging_time, input_voltage, output_voltage + - For other products: adapt fields to be relevant to the product category. **Example JSON Output** ```json { - "@type": "Product", - "@id": "https://tweakers.net/pricewatch/1855004/anker-737-power-bank-powercore-24k.html#Product-1855004", - "name": "Anker 737 Power Bank (PowerCore 24K)", - "@context": "https://schema.org", - "url": "https://tweakers.net/pricewatch/1855004/anker-737-power-bank-powercore-24k.html", - "brand": { - "@type": "Brand", - "name": "Anker", - "url": "https://tweakers.net/merk/2742/anker/" - }, - "image": [ - "https://tweakers.net/ext/i/2005317900.webp", - "https://tweakers.net/ext/i/2005565422.jpeg", - "https://tweakers.net/ext/i/2006644124.jpeg", - "https://tweakers.net/ext/i/2006644126.jpeg", - "https://tweakers.net/ext/i/2006644128.jpeg", - "https://tweakers.net/ext/i/2006644130.jpeg", - "https://tweakers.net/ext/i/2006644132.jpeg", - "https://tweakers.net/ext/i/2006644134.jpeg", - "https://tweakers.net/ext/i/2006644136.jpeg" - ], - "gtin13": [ - "0194644098728" - ], - "mpn": [ - "a1289", - "A1289011" - ], - "description": "1x USB A, 2x USB type-C", - "aggregateRating": { - "@type": "AggregateRating", - "ratingValue": 3.5, - "ratingCount": 4 - }, - "offers": { - "@type": "AggregateOffer", - "lowPrice": 84, - "highPrice": 153, - "offerCount": 15, - "priceCurrency": "EUR" - } + "@type": "Product", + "@id": "https://tweakers.net/pricewatch/1855004/anker-737-power-bank-powercore-24k.html#Product-1855004", + "name": "Anker 737 Power Bank (PowerCore 24K)", + "@context": "https://schema.org", + "url": "https://tweakers.net/pricewatch/1855004/anker-737-power-bank-powercore-24k.html", + "brand": { + "@type": "Brand", + "name": "Anker", + "url": "https://tweakers.net/merk/2742/anker/" + }, + "image": [ + "https://tweakers.net/ext/i/2005317900.webp", + "https://tweakers.net/ext/i/2005565422.jpeg", + "https://tweakers.net/ext/i/2006644124.jpeg", + "https://tweakers.net/ext/i/2006644126.jpeg", + "https://tweakers.net/ext/i/2006644128.jpeg", + "https://tweakers.net/ext/i/2006644130.jpeg", + "https://tweakers.net/ext/i/2006644132.jpeg", + "https://tweakers.net/ext/i/2006644134.jpeg", + "https://tweakers.net/ext/i/2006644136.jpeg" + ], + "gtin13": ["0194644098728"], + "mpn": ["a1289", "A1289011"], + "description": "1x USB A, 2x USB type-C", + "aggregateRating": { + "@type": "AggregateRating", + "ratingValue": 3.5, + "ratingCount": 4 + }, + "offers": { + "@type": "AggregateOffer", + "lowPrice": 84, + "highPrice": 153, + "offerCount": 15, + "priceCurrency": "EUR" + } } ``` @@ -138,13 +133,12 @@ Prioritize the following fields (if available): 1. **Identify the product:** Use the query to locate the product on reputable online retailers or manufacturer websites. 2. **Search for Specifications:** Use the `search_kagi` function to search for specifications of the product. -3. **Extract specifications:** Gather specifications from product pages, data sheets, or reputable reviews (focus on factual information, not opinions). -4. **Extract tweakers specifications:** If the product is a tech related item, you can attempt to extract specifications from the tweakers.net website mentioned in the references of the search results. -5. **Extract images:** Extract images from the product page. Images are important so look over all previous input received and extract images from the ldjson data, search results, etc. Images are to be included in the json response under the `images` field. -6. **Format JSON:** Output your findings as a single JSON object according to the schema above. - -**User Query Example:** "Anker 737" or "0194644098728" +3. **Extract specifications:** Gather specifications from product pages, data sheets, or reputable reviews (focus on factual information, not opinions). +4. **Extract tweakers specifications:** If the product is a tech related item, you can attempt to extract specifications from the tweakers.net website mentioned in the references of the search results. +5. **Extract images:** Extract images from the product page. Images are important so look over all previous input received and extract images from the ldjson data, search results, etc. Images are to be included in the json response under the `images` field. +6. **Format JSON:** Output your findings as a single JSON object according to the schema above. +**User Query Example:** "Anker 737" or "0194644098728" If the product cannot be definitively identified or if insufficient specifications are available, return an empty JSON object: `{}`