import{__awaiter as e,__generator as t}from"tslib";import n from"axios";var i=function(n,i){return e(void 0,void 0,void 0,function(){var e,r,a,o,s,c,l,u,d,I;return t(this,function(t){switch(t.label){case 0:if(!n.trim())return[2,[]];e="".concat(i,"/api/instant-learning/getSuggestedCategories"),r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI4MDU5NjU4Yy1hNjVjLTRlMTQtODlhYS1hNTE5NWY1ZDA5ZjUiLCJ1c2VybmFtZSI6IkthdGh5YXlhbmlNIiwibmFtZSI6Ik0gS2F0aHlheWFuaSIsImVtYWlsIjoibWFkdW1idS5rYXRoeWF5YW5pQHRlY2hvbHV0aW9uLmNvbSIsInJvbGUiOiJzdXBlcl9hZG1pbiIsInN0YXR1cyI6ImFjdGl2ZSIsImlhdCI6MTc1MzM4Mzg4N30.iF2nGYpBedIfeGasUNc7lhjStb_B_u1uz6NFEh0u6qI",a={llm_model:"gpt-4o",topics_config:{dbIndexName:"techolution-instantLearning-categories",dbType:"alloydb",embeddingModel:"mxbai-embed-large-v1",embedding_column:"category_embedding",similarity_threshold:.6},question:"".concat(n),prompt:'You are an intelligent classifier. Analyze the following question or conversation and extract the most relevant **categories** that describe its content. \nInclude:\n1. **Specific topics** (e.g., lung cancer, diabetes, neural networks).\n2. **General domains** (e.g., healthcare, education, technology).\n3. **Intent or task types** (e.g., treatment guidance, diagnosis, troubleshooting).\n\nInput:\nchat_data: The original query from the user\n\nOnly return the categories in this exact format:\n[\n  {\n    "categories": ["<category1>", "<category2>", "..."]\n  }\n]'},t.label=1;case 1:return t.trys.push([1,4,,5]),[4,fetch(e,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json, text/plain, */*",Authorization:"Bearer ".concat(r)},body:JSON.stringify(a)})];case 2:if(!(o=t.sent()).ok)throw new Error("API request failed with status ".concat(o.status));return[4,o.json()];case 3:return s=t.sent(),(c=null===(d=null==s?void 0:s.response)||void 0===d?void 0:d.response)&&Array.isArray(c)&&c.length>0&&(l=null===(I=c[0])||void 0===I?void 0:I.categories)&&Array.isArray(l)?[2,l.map(function(e){return{label:e,value:e,isCustom:!1}})]:(console.warn("Category API response was successful but did not match the expected structure.",s),[2,[]]);case 4:return u=t.sent(),console.error("Error fetching suggested categories:",u),[2,[]];case 5:return[2]}})})},r=function(i,r){return e(void 0,void 0,void 0,function(){var e,a,o,s;return t(this,function(t){switch(t.label){case 0:if(!r||!i)return console.warn("fetchInstantLearningTagsAPI: Missing query or baseUrl"),[2,{}];e="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI4MDU5NjU4Yy1hNjVjLTRlMTQtODlhYS1hNTE5NWY1ZDA5ZjUiLCJ1c2VybmFtZSI6IkthdGh5YXlhbmlNIiwibmFtZSI6Ik0gS2F0aHlheWFuaSIsImVtYWlsIjoibWFkdW1idS5rYXRoeWF5YW5pQHRlY2hvbHV0aW9uLmNvbSIsInJvbGUiOiJzdXBlcl9hZG1pbiIsInN0YXR1cyI6ImFjdGl2ZSIsImlhdCI6MTc1MzM4Mzg4N30.iF2nGYpBedIfeGasUNc7lhjStb_B_u1uz6NFEh0u6qI",t.label=1;case 1:return t.trys.push([1,3,,4]),[4,n.post("".concat(i,"/api/instant-learning/getInstantLearningTags"),{query:r},{headers:{Authorization:"Bearer ".concat(e)}})];case 2:return a=t.sent(),[2,(null===(s=null==a?void 0:a.data)||void 0===s?void 0:s.tags)||{}];case 3:return o=t.sent(),console.error("Error fetching instant learning tags:",o),[2,{}];case 4:return[2]}})})};export{r as fetchInstantLearningTagsAPI,i as fetchSuggestedCategories};
//# sourceMappingURL=instantLearningAPI.js.map
