import fetch from 'node-fetch';
const payload = {
"input_prompt": "Your job is to analyze incoming chat messages from farmers and the responses from a farming AI chatbot and output a JSON object following this taxonomy.\n\nUse the following 3-level schema. If a field is not inferable, set it to null.\n\nLevel 1 \u2014 Why_the_farmer_is_asking__intent\n- intent: one of [\"asking\", \"doing\", \"expressing\", \"validating\"], lowercase.\n \u2022 asking: seeking information, clarification, or decision support.\n \u2022 doing: asking the bot to generate a plan, schedule, calculation, or other concrete output to execute.\n \u2022 expressing: sharing experience, emotions, barriers, or trust cues (e.g., thanks, complaints).\n \u2022 validating: checking or confirming something (e.g., \"Is this correct?\").\n\nLevel 2 \u2014 What_the_query_concerns__domain_task_and_production_system\n\n[2a] domain_context\n- domain_context: one of [\"farming_related\", \"weather_related\", \"meta_query\", \"out_of_context\"].\n \u2022 farming_related: on-farm production, inputs, markets, programs, or app help directly tied to farming.\n \u2022 weather_related: weather/season info that affects farm decisions.\n \u2022 meta_query: meta/system chatter about the bot/app; greetings and social niceties.\n \u2022 out_of_context: non-agricultural / unrelated to farming.\n\n[2b] task_tier_category and subcategory\n- task_tier_category: one of [\n \"crop_soil_management\",\n \"pest_disease_management\",\n \"weather_climate\",\n \"finance_inputs\",\n \"harvest_storage\",\n \"market\",\n \"community_programs\",\n \"wellbeing_behavior\",\n \"other_farming\",\n \"unclear\"\n ]\n- task_subcategory: allowed values by category:\n \u2022 crop_soil_management: [\"land_prep\", \"seed_selection\", \"sowing\", \"irrigation\", \"weed_control\", \"fertilizers\", \"compost\", \"soil_tests\"]\n \u2022 pest_disease_management: [\"identification\", \"chemical_control\", \"bio_control\", \"prevention\"]\n \u2022 weather_climate: [\"forecast\", \"seasonal_outlook\", \"adaptation\", \"weather_triggered\"]\n \u2022 finance_inputs: [\"credit\", \"insurance\", \"input_dealers\", \"subsidies\"]\n \u2022 harvest_storage: [\"harvest_timing\", \"harvest_tip\", \"storage\", \"processing\", \"grading\", \"transportation\", \"aggregation\"]\n \u2022 market: [\"price\", \"marketing\", \"transportation\"]\n \u2022 community_programs: [\"government_schemes\", \"shg_vsla_fpo\", \"trainings_events\"]\n \u2022 wellbeing_behavior: [\"motivation\", \"household_roles\", \"nutrition\", \"stress\"]\n \u2022 other_farming: use when clearly farming-related but does not fit above subcategories (set task_subcategory to null).\n \u2022 unclear: use when there is insufficient information to categorize (set task_subcategory to null).\n\n[2c] which_production_system_it_covers__category and subcategory\n- production_system_category: one of [\n \"field_crops\", \"horticultural_crops\", \"floriculture\", \"tree_crops\",\n \"livestock\", \"aquaculture\", \"apiculture\", \"cross_cutting_mixed\", \"unknown\"\n ]\n- production_system_subcategory: one of the listed crops/species/systems below, or \"unknown\" if not explicitly stated or visually obvious:\n \u2022 field_crops: [\"maize\", \"rice\", \"sorghum\", \"millet\", \"wheat\", \"pigeon_pea\", \"cowpea\", \"groundnut\", \"sesame\", \"mustard\", \"cotton\", \"soybean\", \"chickpea\", \"lentil\", \"black_gram_urd\", \"green_gram_mung\", \"sunflower\", \"barley\", \"jute\", \"teff\", \"fava_bean\", \"common_bean\"]\n \u2022 horticultural_crops: [\"tomato\", \"okra\", \"onion\", \"chilli\", \"banana\", \"mango\", \"papaya\", \"pineapple\", \"passion_fruit\", \"cassava\", \"potato\", \"ginger\", \"turmeric\", \"marigold\", \"eggplant_brinjal\", \"cabbage\", \"cauliflower\", \"spinach_amaranth\", \"lettuce\", \"kale\", \"cucumber\", \"squash_pumpkin\", \"bitter_gourd\", \"carrot\", \"beetroot\", \"sweet_potato\", \"yam\", \"citrus\", \"guava\", \"plantain\", \"avocado\", \"garlic\", \"green_french_beans\"]\n \u2022 floriculture: [\"unspecified\"] (use if it is clearly floriculture but crop not in list)\n \u2022 tree_crops: [\"coffee\", \"tea\", \"sugarcane\", \"coconut\", \"cashew\", \"oil_palm\", \"cocoa\", \"banana\", \"mango\", \"avocado\", \"macadamia\", \"cinnamon\", \"vanilla\", \"pomegranate\"]\n \u2022 livestock: [\"cattle\", \"goat\", \"sheep\", \"chickens\", \"other_poultry\", \"pig\", \"rabbits\", \"camels\", \"other\"]\n \u2022 aquaculture: [\"fish\", \"shrimp_prawn\"]\n \u2022 apiculture: [\"bees\"]\n \u2022 cross_cutting_mixed: [\"intercropping\", \"agroforestry\", \"kitchen_garden\", \"animal_crop\"]\n \u2022 unknown: [\"unknown\"]\n\nLevel 3 \u2014 Contextual_layers (how and who)\n\n[3a] interaction_context\nInfer only when directly implied; otherwise use null.\n- interaction_language: ISO-like code if obvious from content (e.g., \"en\", \"hi\", \"te\"), else null.\n- interaction_modality: one of [\"text\", \"voice\", \"image\"]. For these chat logs, default to \"text\" unless otherwise specified.\n- conversation_type: one of [\"new\", \"follow_up_synthetic\", \"follow_up_user\"].\n \u2022 If there is only one user message shown, treat it as \"new\".\n- user_prompt_clarity: one of [\"clear\", \"somewhat_clear\", \"unclear\"].\n- personalization_level: one of [\"generic\", \"localized\", \"farm_specific\"].\n \u2022 generic: no specific location or farm details.\n \u2022 localized: includes region/weather/soil/market details.\n \u2022 farm_specific: includes user farm details like acreage, crop stage, prior actions.\n- interaction_pattern: one of [\"directive\", \"feedback_loop\", \"iterative\", \"learning\", \"validation\"].\n \u2022 directive: one-shot request for an answer or output.\n \u2022 learning: asking for explanation or teaching.\n \u2022 validation: checking correctness.\n \u2022 feedback_loop / iterative: follow-up refinements.\n- temporal_context: one of [\"pre_season\", \"in_season\", \"off_season\"], or null if not derivable.\n- urgency_signal: one of [\"high\", \"normal\"]. Default to \"normal\" unless explicit urgency.\n- sophistication_level: one of [\"basic\", \"applied\", \"compound\"].\n \u2022 basic: simple, single-fact question.\n \u2022 applied: uses one local factor to adapt a decision.\n \u2022 compound: integrates two or more dimensions or tradeoffs.\n\n[3b] user_profile (who)\nThese should be filled only if explicitly present in the conversation or clearly specified elsewhere; otherwise null.\n- user_gender: one of [\"female\", \"male\", \"unknown\"].\n- user_age_group: one of [\"under_25\", \"_25_40\", \"_41_60\", \"over_60\", \"unknown\"].\n- user_role: one of [\"farmer\", \"extension_agent\", \"other\", \"unknown\"]. Default to \"unknown\" unless explicit.\n- geo_region: free-text if location is mentioned (e.g., \"India/Andhra Pradesh/Anantapur\"), else null.\n- farm_size: one of [\"landless\", \"lt_1_acre\", \"_1_3_acres\", \"gt_3_acres\", \"gt_50_acres\", \"unknown\"].\n- farm_crop: crop name from production_system_subcategory if explicitly tagged; otherwise null.\n\nAssistant answer quality (legacy fields you must still output)\n\nYou must also output a nested \"legacy\" section that mirrors the older Farmer.CHAT schema, for backward compatibility:\n- legacy.user.crop: the main crop mentioned, or null.\n- legacy.user.subject: one of [\"Salutation\", \"Plant Death (Infestation and Infection)\", \"Farming Practice\", \"Irrigation\", \"Video\", \"Supplements (Fertilizers and Pesticides)\", \"Unknown Category\"]. Map from the new taxonomy as best as possible.\n- legacy.user.location: a simplified location string or null.\n- legacy.user.gender: one of [\"male\", \"female\", \"unspecified\"]. Map from user_gender (unknown -> \"unspecified\").\n- legacy.assistant.answer: \"Found\" or \"Missing\".\n \u2022 Missing if and only if ALL of these are true in the assistant reply: (1) it says it cannot give any additional information, AND (2) it apologizes, AND (3) it tells the user to check a website.\n \u2022 Otherwise, answer = \"Found\".\n\nOutput format\n-------------\nGiven a conversation snippet in this exact form:\nConversation: \"\"\"\n user: <user text>\n assistant: <assistant text>\n\"\"\"\nAnalysis:\n\nRespond with a single JSON object ONLY, no extra text, matching this structure:\n{\n \"intent\": \"...\",\n \"domain_context\": \"...\",\n \"task_tier_category\": \"...\",\n \"task_subcategory\": \"...\",\n \"production_system_category\": \"...\",\n \"production_system_subcategory\": \"...\",\n \"interaction_context\": {\n \"interaction_language\": null,\n \"interaction_modality\": \"text\",\n \"conversation_type\": \"new\",\n \"user_prompt_clarity\": \"clear\",\n \"personalization_level\": \"generic\",\n \"interaction_pattern\": \"directive\",\n \"temporal_context\": null,\n \"urgency_signal\": \"normal\",\n \"sophistication_level\": \"basic\"\n },\n \"user_profile\": {\n \"user_gender\": \"unknown\",\n \"user_age_group\": \"unknown\",\n \"user_role\": \"unknown\",\n \"geo_region\": null,\n \"farm_size\": \"unknown\",\n \"farm_crop\": null\n },\n \"legacy\": {\n \"user\": {\n \"crop\": null,\n \"subject\": \"Unknown Category\",\n \"location\": null,\n \"gender\": \"unspecified\"\n },\n \"assistant\": {\n \"answer\": \"Found\"\n }\n }\n}\n\nFill in all fields with appropriate values for each new conversation.\n\nConversation: \"\"\"\n user: {{ user_msg }}\n assistant: {{ assistant_msg }}\n\"\"\"\nAnalysis:",
"selected_models": [
"gpt_4_o"
]
};
async function gooeyAPI() {
const response = await fetch("https://test.api.gooey.ai/v2/CompareLLM?example_id=lbjnoem7", {
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();