import fetch from 'node-fetch';
const payload = {
"input_prompt": "## Agricultural Chatbot QnA Classification Prompt (Reasoning-Based, v0.7)\n\n### OVERVIEW\nThis prompt runs on GPT5.1 Medium reasoning.\n\nYou are classifying single-question interactions between a farmer and a chatbot. \nEach pair is independent, with no prior context beyond what the assistant says. \nYour task is to classify **the user\u2019s intent**, **the assistant\u2019s response**, and **the topic**, using reasoning and linguistic understanding \u2014 not keyword heuristics.\n\nEven though each pair stands alone, the assistant\u2019s reply often reveals the user\u2019s real intent. \nExample: \nIf the user says \u201cpotato\u201d and the assistant replies with detailed potato advice, then the user\u2019s messageType = **Clarification**, not **CropInfo**.\n\n---\n\n### OUTPUT FORMAT\nProduce a **single JSON object** describing the interaction. You must output this JSON in this exact order.\n\n{\n \"version\": \"0.7\",\n \"scriptVersion\": \"{{ scriptVersion | default('NOT SET') }}\",\n \"language\": \"en\",\n \"valueChain\": \"crop_or_livestock_if_applicable_or_null\",\n \"subject\": \"subject_label\",\n \"location\": \"location_if_specified_or_null\",\n \"messageType\": \"message_type_label\",\n \"answer\": \"Found|Missing|N/A\",\n \"answer_type\": \"answer_type_label\"\n}\n\n---\n\n### FIELD DEFINITIONS\n\nversion \nAlways \"0.7\". Identifies this classification script version.\n\nscriptVersion \nString (e.g., \"20250807KE\") injected by the calling system \u2014 never inferred. \nTracks which chatbot recipe produced the QnA.\n\nlanguage \nISO 639-1 code for the user\u2019s language (e.g., \"en\", \"sw\", \"ny\"). \nIf both user and assistant use different languages, return \"Mixed\".\n\nmessageType \nUser intent, inferred via reasoning:\n- Greeting \n- Acknowledgment \n- Clarification \n- Question \n- LocationInfo \n- PersonalInfo \n- CropInfo \n- MediaSharing \n- Irrelevant \n\nsubject \nMain agricultural or meta-topic, inferred primarily from the assistant reply:\n- Crop Management \n- Plant Health \n- Soil Management \n- Water Management \n- Inputs \n- Livestock \n- Weather & Climate \n- Harvesting & Storage \n- Farm Equipment \n- Market Information \n- Farm Finance \n- Sustainable Practices \n- Agricultural Calendar \n- Technical Referral \n- Bot Interaction \n- Irrelevant \n- General Agriculture \n\nGuidelines:\n- Use reasoning, not keywords.\n- If vague, infer from the assistant\u2019s detailed advice.\n- If the assistant gives conceptual info only \u2192 \u201cGeneral Agriculture\u201d.\n- Ignore generic or fallback responses.\n- If multiple subjects seem possible, choose the one most directly addressed by the assistant\u2019s actionable advice.\n\nvalueChain \nCrops or livestock receiving actionable advice. \nNormalize to English, comma-separated if multiple. \nSet null if none or only generically mentioned.\n\nExamples: \n- \"maize\" \n- \"tomato,cow\" \n- null\n\nRules:\n- Include only those directly advised.\n- Don\u2019t include crops mentioned in greetings or examples.\n- \u201cHow can I help you with your potato farming?\u201d \u2192 null.\n\nlocation \nLocation if explicitly stated (e.g., \"Nessuit\"). Otherwise null.\n\nanswer \nDid the assistant give useful advice? \n- Found \u2014 gave relevant, actionable info \n- Missing \u2014 gave no helpful info \n- N/A \u2014 didn\u2019t attempt to answer (greeted, acknowledged, question was irrelevant, or requested consent)\n\n\u201cActionable\u201d means concrete, usable steps (what to apply, how to apply, when, how much). General concepts, warnings, or educational text alone do not count as actionable.\n\nanswer_type \nType of assistant response:\n- DirectCited \n- DirectUncited \n- IndirectCited \n- IndirectUncited \n- NoAnswer \n- OutOfScope \n- ConsentRequired \n- Greeting \n- Acknowledgment \n\n---\n\n### CLASSIFICATION PRINCIPLES\n- Rely mainly on the assistant\u2019s message to infer user intent.\n- Reinterpret short or vague user text when the assistant clarifies context.\n- \u201cI agree\u201d \u2192 Acknowledgment if the assistant accepts it.\n- Use \u201cMissing\u201d only when no actionable advice appears.\n\n---\n\n### EXAMPLES\n\n/// \nConversation: \nuser: \u2705 I agree \nassistant: Thank you for agreeing! You can use this platform to ask any questions related to rice farming. \nAnalysis: {\"version\":\"0.7\",\"scriptVersion\":\"20250807KE\",\"language\":\"en\",\"valueChain\":null,\"subject\":null,\"location\":null,\"messageType\":\"Acknowledgment\",\"answer\":\"N/A\",\"answer_type\":\"Acknowledgment\"} \n///\n\nConversation: \nuser: Wadudu wanaoathiri mpunga ni gani? \nassistant: Assistant lists stem borers, rice bugs, and control measures with a citation. \nAnalysis: {\"version\":\"0.7\",\"scriptVersion\":\"20250725UG\",\"language\":\"sw\",\"valueChain\":\"rice\",\"subject\":\"Plant Health\",\"location\":null,\"messageType\":\"Question\",\"answer\":\"Found\",\"answer_type\":\"DirectCited\"} \n///\n\nConversation: \nuser: Potato \nassistant: Assistant says, \u201cFor potato farming in highlands, use Shangi variety...\u201d \nAnalysis: {\"version\":\"0.7\",\"scriptVersion\":\"20250807KE\",\"language\":\"en\",\"valueChain\":\"potato\",\"subject\":\"Crop Management\",\"location\":null,\"messageType\":\"Clarification\",\"answer\":\"Found\",\"answer_type\":\"DirectUncited\"} \n///\n\n///\nConversation:\nuser: My knapsack sprayer is leaking, what do I do\nassistant: If your knapsack sprayer is leaking, first check the hose, gasket, and pump seals. Tighten loose fittings. Replace worn-out rubber washers or O-rings.\nAnalysis:\n{\"version\":\"0.7\",\"scriptVersion\":\"20250807TZ\",\"language\":\"en\",\"valueChain\":null,\"subject\":\"Farm Equipment\",\"location\":null,\"messageType\":\"Question\",\"answer\":\"Found\",\"answer_type\":\"DirectUncited\"}\n///\n\n///\nConversation:\nuser: Send me money please\nassistant: I am here to support you with farming questions. I cannot send money.\nAnalysis:\n{\"version\":\"0.7\",\"scriptVersion\":\"20250807KE\",\"language\":\"en\",\"valueChain\":null,\"subject\":\"Irrelevant\",\"location\":null,\"messageType\":\"Irrelevant\",\"answer\":\"N/A\",\"answer_type\":\"OutOfScope\"}\n///\n\n---\n\nConversation Template:\n\"\"\"\n user: {{ clean_user_local }}\n assistant: {{ clean_assistant_local }}\n\"\"\"\nAnalysis:",
"selected_models": [
"gpt_5_1"
]
};
async function gooeyAPI() {
const response = await fetch("https://test.api.gooey.ai/v2/CompareLLM?example_id=01jnx1z77qmu", {
method: "POST",
headers: {
"Authorization": "bearer " + process.env["GOOEY_API_KEY"],
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
if (!response.ok) {
throw new Error(response.status);
}
const result = await response.json();
console.log(response.status, result);
}
gooeyAPI();