import fetch from 'node-fetch';
const payload = {
"input_prompt": "## Agricultural Chatbot QnA Classification Prompt (Reasoning-Based, v0.6)\n\n<!--\nChanges in v0.6:\n- Flattened schema (no `user` / `assistant` nesting)\n- `version` hardcoded to \"0.6\"\n- Retains `scriptVersion` as a top-level variable passed in externally\n-->\n\n\n### OVERVIEW\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.\n\n{\n \"version\": \"0.6\",\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.6\". 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\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, or requested consent)\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- Never default to \u201cGeneral Agriculture\u201d unless clearly conceptual.\n- \u201cMixed\u201d for code-switching between languages.\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.6\",\"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.6\",\"scriptVersion\":\"20250725UG\",\"language\":\"sw\",\"valueChain\":\"rice\",\"subject\":\"Plant Health\",\"location\":null,\"messageType\":\"Question\",\"answer\":\"Found\",\"answer_type\":\"DirectCited\"} \n///\n\nConversation: \nuser: Control cabbage rust \nassistant: Assistant gives detailed disease management for cabbage. \nAnalysis: {\"version\":\"0.6\",\"scriptVersion\":\"20250730TZ\",\"language\":\"en\",\"valueChain\":\"cabbage\",\"subject\":\"Plant Health\",\"location\":null,\"messageType\":\"Question\",\"answer\":\"Found\",\"answer_type\":\"DirectUncited\"} \n///\n\nConversation: \nuser: Potato \nassistant: Assistant says, \u201cFor potato farming in highlands, use Shangi variety...\u201d \nAnalysis: {\"version\":\"0.6\",\"scriptVersion\":\"20250807KE\",\"language\":\"en\",\"valueChain\":\"potato\",\"subject\":\"Crop Management\",\"location\":null,\"messageType\":\"Clarification\",\"answer\":\"Found\",\"answer_type\":\"DirectUncited\"} \n///\n\n---\n\nConversation Template:\n\"\"\"\n user: {{ user_msg_local }}\n assistant: {{ assistant_msg_local }}\n\"\"\"\nAnalysis:",
"selected_models": [
"gpt_4_1"
]
};
async function gooeyAPI() {
const response = await fetch("https://test.api.gooey.ai/v2/CompareLLM?example_id=s7mcntasd47r", {
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();