| 12345678 |
- {
- "name": "get_car_data",
- "description": "IMPORTANT: Always reply to the customer in their own language — the exact language they write in. Never switch to Polish unless the customer writes in Polish.\n\nWyszukaj dane klimatyzacji pojazdu (typ gazu, ilość, olej, adaptery). Wywołaj TYLKO gdy użytkownik pyta o specyfikację klimatyzacji (typ gazu, ilość, olej, adaptery) — NIE gdy pyta o produkty do kupienia. Gdy użytkownik pyta o produkty → wywołaj get_product_compatibility bezpośrednio bez wywoływania tego narzędzia. NIE wywołuj ponownie jeśli dane o gazie są już znane. Nie oceniaj samodzielnie czy auto jest w bazie — narzędzie stwierdza czy ma dane dla danego pojazdu.\n\nGdy API zwróci listę opcji do wyboru (np. silnik, model), zaprezentuj je użytkownikowi i wywołaj narzędzie ponownie z wybraną wartością. Gdy narzędzie zwróci wyniki — przedstaw je klientowi bezpośrednio, bez pytania o dalszy wybór.",
- "color": "linear-gradient(rgb(150,150,150), rgb(100,100,100))",
- "iconSrc": "",
- "schema": "[{\"id\":0,\"property\":\"make\",\"description\":\"Marka pojazdu (np. Toyota, BMW)\",\"type\":\"string\",\"required\":false},{\"id\":1,\"property\":\"model\",\"description\":\"Model pojazdu (np. Corolla, E46)\",\"type\":\"string\",\"required\":false},{\"id\":2,\"property\":\"year\",\"description\":\"Rok produkcji pojazdu\",\"type\":\"string\",\"required\":false},{\"id\":3,\"property\":\"engine\",\"description\":\"Silnik pojazdu (np. 1.8 - 141 kW / 192 KM) — podaj po wybraniu przez użytkownika\",\"type\":\"string\",\"required\":false}]",
- "func": "const fetch = require('node-fetch')\n\nconst base = String(($vars && ($vars.relay_base || $vars.webhook_base)) || 'http://localhost:8080').replace(/\\/$/,'')\nconst secret = String(($vars && $vars.relay_shared_secret) || '')\n\nconst make = typeof $make !== 'undefined' && $make ? String($make) : ''\nconst model = typeof $model !== 'undefined' && $model ? String($model) : ''\nconst year = typeof $year !== 'undefined' && $year ? String($year) : ''\nconst engine = typeof $engine !== 'undefined' && $engine ? String($engine) : ''\n\nif (!make && !model) return 'Error: provide at least make or model'\nif (!secret) return 'Error: missing $vars.relay_shared_secret'\n\ntry {\n const body = {}\n if (make) body.make = make\n if (model) body.model = model\n if (year) body.year = year\n if (engine) body.engine = engine\n\n const res = await fetch(`${base}/tools/get_car_data`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${secret}`\n },\n body: JSON.stringify(body)\n })\n const data = await res.json()\n if (data.ok) {\n const result = data.data\n\n // Opcje do wyboru (model, marka, silnik)\n if (result && result.error === 'options') {\n const fieldName = result.field || 'pole'\n const options = (result.options || []).map(o => String(o).trim()).filter(Boolean)\n if (options.length === 0) {\n const carDesc = [make, model, year].filter(Boolean).join(' ')\n return `No data found for vehicle \"${carDesc}\" in our database. The car may be outside the supported year range, or make/model was entered incorrectly. Inform the customer that we do not have data for this vehicle.`\n }\n return `Selection required for field\"${fieldName}\". Available options:\\n${options.map((o, i) => `${i + 1}. ${o}`).join('\\n')}\\nAsk the user to choose, then call the tool again with the selected value as parameter\"${fieldName}\".`\n }\n\n // Sukces — dane o klimatyzacji auta\n if (result && result.success) {\n const car = result.selected_car || {}\n const gasType = (result.ac_gas_type || car.ek_ac_gas_type || '').toUpperCase()\n const engineStr = car.ek_engine_type && car.ek_engine_type.trim() && car.ek_engine_type.trim() !== '0.0 - kW / KM' ? ' ' + car.ek_engine_type.trim() : ''\n const carLabel = `${car.ek_brand || make} ${car.ek_model || model} ${car.ek_year || year}${engineStr}`\n\n let text = `AC data for ${carLabel}:\\n`\n text += `- Refrigerant type: ${gasType}\\n`\n if (result.ac_gas_amount) text += `- Refrigerant amount: ${result.ac_gas_amount}\\n`\n if (result.ac_oil) text += `- Oil: ${result.ac_oil} ${result.ac_oil_amount || ''}\\n`\n if (result.ac_ports_count) text += `- AC ports: ${result.ac_ports_count}\\n`\n if (result.adapters) text += `- Required adapters: ${result.adapters}\\n`\n if (result.shop_url) text += `- Car page: ${result.shop_url}\\n`\n\n if (result.maybe_different_layout) {\n const gas2 = (result.different_layout_ac_gas_type || '').toUpperCase()\n text += `\\nWARNING: This car may have two different AC system configurations. The second configuration uses refrigerant ${gas2}.\\n`\n }\n\n text += `\\n[INSTRUCTION: Reply to the customer IN THEIR OWN LANGUAGE — the exact language they are currently writing in. If the customer's ORIGINAL question was about PRODUCTS to buy, immediately call get_product_compatibility with: car_brand=\"${car.ek_brand || make}\", car_model=\"${car.ek_model || model}\", car_year=\"${car.ek_year || year}\" — do NOT show this AC data first. Only share the AC data above if the customer specifically asked about their car's AC specifications.]`\n return text\n }\n\n // Błąd z backendu (np. nie znaleziono auta)\n if (result && result.error) {\n return `Database info: ${result.error}`\n }\n\n return JSON.stringify(result, null, 2)\n }\n return `Info: ${data.message || JSON.stringify(data)}`\n} catch (error) {\n return `Connection error: ${error?.message || String(error)}`\n}\n"
- }
|