ai-compare-candidates 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/.editorconfig +51 -0
  2. package/.vscode/settings.json +3 -0
  3. package/.yarnrc.yml +16 -0
  4. package/LICENSE +6 -0
  5. package/README.md +77 -0
  6. package/dist/index.cjs +24 -0
  7. package/dist/index.cjs.map +1 -0
  8. package/dist/index.d.cts +134 -0
  9. package/dist/index.d.cts.map +1 -0
  10. package/dist/index.d.mts +134 -0
  11. package/dist/index.d.mts.map +1 -0
  12. package/dist/index.mjs +24 -0
  13. package/dist/index.mjs.map +1 -0
  14. package/example/.editorconfig +51 -0
  15. package/example/.vscode/extensions.json +13 -0
  16. package/example/.vscode/settings.json +5 -0
  17. package/example/README.md +21 -0
  18. package/example/index.html +21 -0
  19. package/example/package.json +37 -0
  20. package/example/postcss.config.js +29 -0
  21. package/example/public/favicon.ico +0 -0
  22. package/example/public/icons/favicon-128x128.png +0 -0
  23. package/example/public/icons/favicon-16x16.png +0 -0
  24. package/example/public/icons/favicon-32x32.png +0 -0
  25. package/example/public/icons/favicon-96x96.png +0 -0
  26. package/example/quasar.config.ts +222 -0
  27. package/example/src/App.vue +5 -0
  28. package/example/src/boot/electronHuggingFaceFix.ts +8 -0
  29. package/example/src/boot/icons.ts +20 -0
  30. package/example/src/css/app.scss +1 -0
  31. package/example/src/css/quasar.variables.scss +25 -0
  32. package/example/src/env.d.ts +7 -0
  33. package/example/src/layouts/app.vue +147 -0
  34. package/example/src/router/index.ts +37 -0
  35. package/example/src/router/routes.ts +8 -0
  36. package/example/src/stores/index.ts +32 -0
  37. package/example/src/stores/store.ts +19 -0
  38. package/example/tsconfig.json +3 -0
  39. package/package.json +55 -0
  40. package/src/index.ts +478 -0
  41. package/tsconfig.json +12 -0
  42. package/tsconfig.node.json +12 -0
  43. package/tsconfig.tsbuildinfo +1 -0
  44. package/tsdown.config.ts +12 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["matches:string[]","match:RegExpExecArray|null","selectedCandidates:Candidate[]","summaries:string[]","summarisableSubstringIndices:AICompareCandidates.SummarisableSubstringIndices"],"sources":["../src/index.ts"],"sourcesContent":["import{\n\tenv,\n\tpipeline,\n\tAutoTokenizer,\n\tTextGenerationPipeline,\n\tProgressInfo,\n\tProgressCallback,\n\tSummarizationPipeline,\n\tFeatureExtractionPipeline,\n\tPreTrainedTokenizer,\n\tTextGenerationConfig\n}from '@huggingface/transformers';\nimport {MemoryVectorStore} from '@langchain/classic/vectorstores/memory';\nimport {Embeddings} from '@langchain/core/embeddings';\nimport lodash from 'lodash';\nimport jsan from 'jsan';\n\nexport class AICompareCandidates extends Embeddings{\n\treadonly env=env;\n\tDEBUG=true;\n\n\tgenerator:TextGenerationPipeline|null=null;\n\tgeneratorModelName='Xenova/LaMini-GPT-774M';\n\tgeneratorPromise:Promise<TextGenerationPipeline>|null=null;\n\tgeneratorProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tgeneratorProgressCallback:ProgressCallback|null=null;\n\n\tsummariser:SummarizationPipeline|null=null;\n\tsummariserModelName='Xenova/distilbart-cnn-12-6';\n\tsummariserPromise:Promise<SummarizationPipeline>|null=null;\n\tsummariserProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tsummariserProgressCallback:ProgressCallback|null=null;\n\n\tembedder:FeatureExtractionPipeline|null=null;\n\tembedderModelName='Xenova/all-MiniLM-L12-v2';\n\tembedderPromise:Promise<FeatureExtractionPipeline>|null=null;\n\tembedderProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tembedderProgressCallback:ProgressCallback|null=null;\n\n\ttokeniser:PreTrainedTokenizer|null=null;\n\ttokeniserModelName=this.generatorModelName;\n\ttokeniserPromise:Promise<PreTrainedTokenizer>|null=null;\n\ttokeniserProgressInfo:ProgressInfo=<ProgressInfo>{};\n\ttokeniserProgressCallback:ProgressCallback|null=null;\n\n\tgenerateSearchAreasMaxNewTokens=64;\n\tgenerateSearchAreasTemperature=0.35;\n\tgenerateSearchAreasRepetitionPenalty=1.5;\n\n\trankingMaxNewTokens=64;\n\trankingTemperature=0.35;\n\trankingRepetitionPenalty=1.5;\n\n\ttargetSummarisedStringTokenCount=420;\n\n\tstatic{\n\t\tenv.localModelPath='';\n\t\tenv.allowRemoteModels=true;\n\t\tenv.allowLocalModels=false;\n\t}\n\n\tconstructor(){\n\t\tsuper({});\n\t}\n\t\n\tasync loadGenerator({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.generatorModelName=modelName;\n\t\tif(!this.generatorModelName)throw new Error('Invalid generator model name');\n\t\tif(progressCallback)this.generatorProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.generatorPromise=pipeline('text-generation',this.generatorModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.generatorProgressInfo,progressInfo);\n\t\t\t\treturn this.generatorProgressCallback?.(progressInfo);\n\t\t\t}\n\t\t});\n\t\tthis.generator=await this.generatorPromise;\n\t\treturn this.generator;\n\t}\n\n\tasync checkGeneratorLoaded(){\n\t\tif(!this.generatorPromise)this.loadGenerator();\n\t\tif(!this.generator)await this.generatorPromise;\n\t\tif(!this.generator)throw new Error('Unable to load generator');\n\t}\n\n\tasync loadSummariser({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.summariserModelName=modelName;\n\t\tif(!this.summariserModelName)throw new Error('Invalid summariser model name');\n\t\tif(progressCallback)this.summariserProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.summariserPromise=pipeline('summarization',this.summariserModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.summariserProgressInfo,progressInfo);\n\t\t\t\treturn this.summariserProgressCallback?.(progressInfo);\n\t\t\t}\n\t\t});\n\t\tthis.summariser=await this.summariserPromise;\n\t\treturn this.summariser;\n\t}\n\n\tasync checkSummariserLoaded(){\n\t\tif(!this.summariserPromise)this.loadSummariser();\n\t\tif(!this.summariser)await this.summariserPromise;\n\t\tif(!this.summariser)throw new Error('Unable to load summariser');\n\t}\n\n\tasync loadEmbedder({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.embedderModelName=modelName;\n\t\tif(!this.embedderModelName)throw new Error('Invalid embedder model name');\n\t\tif(progressCallback)this.embedderProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.embedderPromise=pipeline('feature-extraction',this.embedderModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.embedderProgressInfo,progressInfo);\n\t\t\t\treturn this.embedderProgressCallback?.(progressInfo);\n\t\t\t}\n\t\t});\n\t\tthis.embedder=await this.embedderPromise;\n\t\treturn this.embedder;\n\t}\n\n\tasync checkEmbedderLoaded(){\n\t\tif(!this.embedderPromise)this.loadEmbedder();\n\t\tif(!this.embedder)await this.embedderPromise;\n\t\tif(!this.embedder)throw new Error('Unable to load embedder');\n\t}\n\n\tasync loadTokeniser({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.tokeniserModelName=modelName;\n\t\tif(!this.tokeniserModelName)throw new Error('Invalid tokeniser model name');\n\t\tif(progressCallback)this.tokeniserProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.tokeniserPromise=AutoTokenizer.from_pretrained(this.tokeniserModelName,{\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.tokeniserProgressInfo,progressInfo);\n\t\t\t\treturn this.tokeniserProgressCallback?.(progressInfo);\n\t\t\t}\n\t\t})\n\t\tthis.tokeniser=await this.tokeniserPromise;\n\t\treturn this.tokeniser;\n\t}\n\n\tasync checkTokeniserLoaded(){\n\t\tif(!this.tokeniserPromise)this.loadTokeniser();\n\t\tif(!this.tokeniser)await this.tokeniserPromise;\n\t\tif(!this.tokeniser)throw new Error('Unable to load tokeniser');\n\t}\n\n\tasync embedQuery(text:string):Promise<number[]>{\n\t\tawait this.checkEmbedderLoaded();\n\t\treturn Array.from((await this.embedder?.(text,{\n\t\t\tpooling:'mean',\n\t\t\tnormalize:true\n\t\t}))?.data);\n\t}\n\n\tasync embedDocuments(texts:string[]):Promise<number[][]>{\n\t\treturn Promise.all(texts.map(text=>this.embedQuery(text)));\n\t}\n\n\tgeneratePromptTemplate(prompt:string){\n\t\treturn 'Below is an instruction that describes a task. Write a response that appropriately completes the request.\\n\\n'+\n\t\t\t'### Instruction:\\n'+\n\t\t\tprompt+\n\t\t\t'\\n\\n### Response:';\n\t}\n\n\tdefaultGenerateSearchAreasInstruction(problemDescription:string){\n\t\treturn 'List the relevant subject areas for the following issues. Limit your response to 100 words.\\nIssues: \"'+problemDescription+'\"';\n\t}\n\n\tdefaultConvertCandidateToDocument<Candidate>({\n\t\tcandidate,\n\t\tindex\n\t}:AICompareCandidates.ConvertCandidateToDocumentArguments<Candidate>=<AICompareCandidates.ConvertCandidateToDocumentArguments<Candidate>>{}){\n\t\tlet document='Start of Candidate #'+index;\n\t\tfor(let i in candidate)document+='\\n'+lodash.startCase(i)+': '+(typeof candidate[i]==='object'?jsan.stringify(candidate[i]):String(candidate[i]));\n\t\tdocument+='\\nEnd of Candidate #'+index;\n\t\treturn document;\n\t}\n\n\tdefaultGenerateRankingInstruction({\n\t\tproblemDescription,\n\t\tsummaries,\n\t\tcandidatesForFinalSelection,\n\t\tcandidateIdentifierField\n\t}:AICompareCandidates.GenerateRankingInstructionArguments=<AICompareCandidates.GenerateRankingInstructionArguments>{}){\n\t\treturn 'Strictly follow these rules:\\n'+\n\t\t\t'1. Rank ONLY the top '+candidatesForFinalSelection+' candidates with one 15-word sentence explaining why\\n'+\n\t\t\t'2. Rank the candidates based on \"'+problemDescription.replace(/(\\r|\\n)/g,' ')+'\"\\n'+\n\t\t\t'3. If unclear, say \"Insufficient information to determine\"\\n\\n'+\n\t\t\t'Candidates:\\n\\n'+summaries.join('\\n\\n')+'\\n\\n'+\n\t\t\t'Format exactly:\\n'+\n\t\t\t'#1. \"Full '+lodash.startCase(candidateIdentifierField)+'\": 15-word explanation\\n'+\n\t\t\t'#2. ...';\n\t}\n\n\tregexIndexOf(text:string,regex:RegExp,startIndex:number){\n \tlet indexInSuffix=text.slice(startIndex).search(regex);\n \treturn indexInSuffix<0?indexInSuffix:indexInSuffix+startIndex;\n\t}\n\n\tdefaultExtractIdentifierFromCandidateDocument({\n\t\tcandidateDocument,\n\t\tcandidateIdentifierField\n\t}:AICompareCandidates.ExtractIdentifierFromCandidateDocumentArguments=<AICompareCandidates.ExtractIdentifierFromCandidateDocumentArguments>{}){\n\t\tif(this.DEBUG)console.log(candidateDocument,candidateIdentifierField);\n\t\tlet startCase=lodash.startCase(candidateIdentifierField);\n\t\tlet startIndex=candidateDocument.indexOf(startCase);\n\t\tif(startIndex<0)startIndex=candidateDocument.toLowerCase().indexOf(startCase.toLowerCase());\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex>=0)startIndex+=startCase.length;\n\t\tif(startIndex<0){\n\t\t\tstartIndex=candidateDocument.toLowerCase().indexOf(candidateIdentifierField.toLowerCase());\n\t\t\tif(startIndex>=0)startIndex+=candidateIdentifierField.length;\n\t\t}\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\telse return '';\n\t\tstartIndex=candidateDocument.indexOf(':',startIndex);\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex<0)startIndex=this.regexIndexOf(candidateDocument,/\\s+/,startIndex);\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex<0)return '';\n\t\tlet endIndex=candidateDocument.indexOf('\\n',startIndex);\n\t\tif(endIndex<0)endIndex=candidateDocument.length;\n\t\tif(this.DEBUG)console.log(endIndex);\n\t\treturn candidateDocument.substring(startIndex,endIndex).trim();\n\t}\n\n\tdefaultExtractIdentifiersFromRationale(rationale:string){\n\t\tlet regex=/^\\s*#\\s*\\d+\\s*\\.?\\s*\"([^\"]+)\"/gm;\n\t\tlet matches:string[]=[];\n\t\tfor(let match:RegExpExecArray|null;Array.isArray(match=regex.exec(rationale));)if(match[1])matches.push(match[1]);\n\t\treturn matches;\n\t}\n\n\tasync compareCandidates<Candidate>({\n\t\tcandidates,\n\t\tproblemDescription='',\n\t\tgenerateSearchAreasInstruction=this.defaultGenerateSearchAreasInstruction.bind(this),\n\t\tconvertCandidateToDocument=this.defaultConvertCandidateToDocument.bind(this),\n\t\tcandidatesForInitialSelection=2,\n\t\tcandidatesForFinalSelection=1,\n\t\tgenerateRankingInstruction=this.defaultGenerateRankingInstruction.bind(this),\n\t\textractIdentifiersFromRationale=this.defaultExtractIdentifiersFromRationale.bind(this),\n\t\textractIdentifierFromCandidateDocument=this.defaultExtractIdentifierFromCandidateDocument.bind(this),\n\t\tcandidateIdentifierField=undefined,\n\t\tgetSummarisableSubstringIndices\n\t}:AICompareCandidates.CompareArguments<Candidate>=<AICompareCandidates.CompareArguments<Candidate>>{}):Promise<AICompareCandidates.CompareCandidatesReturn<Candidate>|void>{\n\t\tif(!Array.isArray(candidates)||candidates.length<=0)throw new Error('No candidates provided');\n\t\tcandidatesForInitialSelection=lodash.toSafeInteger(candidatesForInitialSelection);\n\t\tif(candidatesForInitialSelection<=0)throw new Error('Candidates for initial selection must be a positive integer bigger than 0');\n\t\tcandidatesForFinalSelection=lodash.toSafeInteger(candidatesForFinalSelection);\n\t\tif(candidatesForFinalSelection<=0)throw new Error('Candidates for initial selection must be a positive integer bigger than 0');\n\t\tif(candidatesForInitialSelection<candidatesForFinalSelection)throw new Error('Candidates for initial selection must be equal or more than candidates for final selection');\n\t\tif(candidatesForInitialSelection>candidates.length)throw new Error('There are '+candidatesForInitialSelection+'candidates for initial selection which is more than the total number of candidates of '+candidates.length);\n\t\tif(candidatesForFinalSelection>candidates.length)throw new Error('There are '+candidatesForFinalSelection+'candidates for initial selection which is more than the total number of candidates of '+candidates.length);\n\t\tif(!candidateIdentifierField){\n\t\t\tcandidateIdentifierField=Object.keys(candidates[0] as object)[0] as keyof Candidate;\n\t\t\tif(!candidateIdentifierField)throw new Error('No candidate identifier field');\n\t\t}\n\n\t\tlet rationale='';\n\t\tlet selectedCandidates:Candidate[]=[];\n\n\t\tawait this.checkEmbedderLoaded();\n\t\tif(!this.embedder)return;\n\t\tlet candidateDocuments=candidates.map((candidate,index)=>convertCandidateToDocument({\n\t\t\tcandidate,\n\t\t\tindex\n\t\t}));\n\t\tlet vectorStore=await MemoryVectorStore.fromTexts(\n\t\t\tlodash.cloneDeep(candidateDocuments),\n\t\t\tcandidateDocuments.map((document,index)=>index),\n\t\t\tthis\n\t\t);\n\n\t\tlet searchAreasPromptTemplate=this.generatePromptTemplate(generateSearchAreasInstruction(problemDescription));\n\t\tif(this.DEBUG)console.log('Formatted search areas prompt: '+searchAreasPromptTemplate);\n\t\tawait this.checkTokeniserLoaded();\n\t\tif(!this.tokeniser)return;\n\t\tlet searchAreasPromptTokens=this.tokeniser.encode(searchAreasPromptTemplate);\n\t\tif(searchAreasPromptTokens.length>this.tokeniser.model_max_length)throw new Error('Search areas instruction prompt is too long for the tokeniser model');\n\n\t\tawait this.checkGeneratorLoaded();\n\t\tif(!this.generator)return;\n\t\tlet pad_token_id=this.tokeniser.pad_token_id??this.tokeniser.sep_token_id??0;\n\t\tlet eos_token_id=this.tokeniser.sep_token_id??2;\n\t\tlet searchAreasReplyArray=await this.generator(searchAreasPromptTemplate,{\n\t\t\tmax_new_tokens:this.generateSearchAreasMaxNewTokens,\n\t\t\ttemperature:this.generateSearchAreasTemperature,\n\t\t\trepetition_penalty:this.generateSearchAreasRepetitionPenalty,\n\t\t\tpad_token_id,\n\t\t\teos_token_id\n\t\t});\n\t\tlet searchAreasReply=Array.isArray(searchAreasReplyArray?.[0])?searchAreasReplyArray?.[0]?.[0]:searchAreasReplyArray?.[0];\n\t\tif(!searchAreasReply.generated_text)throw new Error('No generated text for search areas');\n\t\tif(this.DEBUG)console.log('Generated search areas response: '+searchAreasReply.generated_text);\n\t\tlet searchAreasResponseIndex=searchAreasReply.generated_text.toString().indexOf('### Response:');\n\t\tif(searchAreasResponseIndex>=0)searchAreasResponseIndex+='### Response:'.length;\n\t\telse searchAreasResponseIndex=0;\n\n\t\tlet vectorSearchQuery=searchAreasReply.generated_text.toString().substring(searchAreasResponseIndex).trim();\n\t\t//generally the first sentence has the greatest relevance to the actual prompt\n\t\t//if(vectorSearchQuery.includes('.'))vectorSearchQuery=vectorSearchQuery.split('.')[0].trim();\n\t\tif(this.DEBUG)console.log('Vector search query: '+vectorSearchQuery);\n\t\tlet queryResult=await vectorStore.similaritySearch(vectorSearchQuery,candidatesForInitialSelection);\n\t\tif(this.DEBUG)console.log('Vector search results: ',queryResult);\n\n\t\tlet summaries:string[]=[];\n\t\t//only bother doing summarisation if there are candidates which exceed the token count\n\t\tif(queryResult.some(result=>result.pageContent.trim().split(/\\s+/).length>this.targetSummarisedStringTokenCount)){\n\t\t\tawait this.checkSummariserLoaded();\n\t\t\tif(!this.summariser)return;\n\t\t\tsummaries=(await Promise.allSettled(queryResult.map(async result=>{\n\t\t\t\tif(!result.pageContent||typeof result.pageContent!=='string')return '';\n\t\t\t\tif(result.pageContent.trim().split(/\\s+/).length<=this.targetSummarisedStringTokenCount)return result.pageContent;\n\t\t\t\tlet summarisableSubstringIndices:AICompareCandidates.SummarisableSubstringIndices={\n\t\t\t\t\tstart:0,\n\t\t\t\t\tend:result.pageContent.length\n\t\t\t\t};\n\t\t\t\tif(getSummarisableSubstringIndices)Object.assign(summarisableSubstringIndices,getSummarisableSubstringIndices(result.pageContent));\n\t\t\t\tsummarisableSubstringIndices.start=lodash.clamp(lodash.toSafeInteger(summarisableSubstringIndices.start),0,result.pageContent.length);\n\t\t\t\tsummarisableSubstringIndices.end=lodash.clamp(lodash.toSafeInteger(summarisableSubstringIndices.end),0,result.pageContent.length);\n\t\t\t\tlet summarisableSubstring=result.pageContent.substring(summarisableSubstringIndices.start,summarisableSubstringIndices.end);\n\t\t\t\tlet contentBefore=result.pageContent.substring(0,summarisableSubstringIndices.start);\n\t\t\t\tlet contentAfter=result.pageContent.substring(summarisableSubstringIndices.end);\n\t\t\t\tlet wordsWithoutSummarisable=contentBefore.split(/s+/).length+contentAfter.split(/s+/).length;\n\t\t\t\tlet targetSummarisedSubstringTokenCount=Math.max(1,420-wordsWithoutSummarisable);\n\t\t\t\tlet summarisedSubstringArray=await this.summariser?.(summarisableSubstring,<TextGenerationConfig>{\n\t\t\t\t\tmax_length:targetSummarisedSubstringTokenCount\n\t\t\t\t});\n\t\t\t\tlet summarisedSubstring=Array.isArray(summarisedSubstringArray?.[0])?summarisedSubstringArray?.[0]?.[0]:summarisedSubstringArray?.[0];\n\t\t\t\tlet summarisedString=contentBefore+(summarisedSubstring?.summary_text??'').split(/s+/).slice(targetSummarisedSubstringTokenCount).join(' ')+contentAfter;\n\t\t\t\tif(this.DEBUG)console.log('Summarised candidate: '+summarisedString);\n\t\t\t\treturn summarisedString;\n\t\t\t}))).filter(result=>result.status==='fulfilled'&&result.value).map(result=>(result as PromiseFulfilledResult<string>).value);\n\t\t}else{\n\t\t\tsummaries=queryResult.map(result=>result.pageContent);\n\t\t}\n\n\t\tlet rankingPromptTemplate=this.generatePromptTemplate(generateRankingInstruction({\n\t\t\tproblemDescription,\n\t\t\tsummaries,\n\t\t\tcandidatesForFinalSelection,\n\t\t\tcandidateIdentifierField:String(candidateIdentifierField)\n\t\t}));\n\t\tif(this.DEBUG)console.log('Formatted ranking prompt: '+rankingPromptTemplate);\n\t\tlet rankingPromptTokens=this.tokeniser.encode(rankingPromptTemplate);\n\t\tif(rankingPromptTokens.length>this.tokeniser.model_max_length)throw new Error('Ranking instruction prompt is too long for the tokeniser model');\n\t\tlet rankingArray=await this.generator(rankingPromptTemplate,{\n\t\t\tmax_new_tokens:this.rankingMaxNewTokens,\n\t\t\ttemperature:this.rankingTemperature,\n\t\t\trepetition_penalty:this.rankingRepetitionPenalty,\n\t\t\tpad_token_id,\n\t\t\teos_token_id\n\t\t});\n\t\tlet ranking=Array.isArray(rankingArray?.[0])?rankingArray?.[0]?.[0]:rankingArray[0];\n\t\trationale=ranking.generated_text.toString().trim().replace(/(\\*\\*)|(<\\/?s>)|(\\[.*?\\])\\s*/g, '');\n\t\tif(this.DEBUG)console.log('Generated rationale: '+rationale);\n\t\tlet rationaleResponseIndex=rationale.indexOf('### Response:');\n\t\tif(rationaleResponseIndex>=0)rationaleResponseIndex+='### Response:'.length;\n\t\telse rationaleResponseIndex=0;\n\t\trationale=rationale.substring(rationaleResponseIndex);\n\t\t//if(!rationale)throw new Error('No rationale generated');\n\n\t\tif(rationale){\n\t\t\tlet identifiers=extractIdentifiersFromRationale(rationale);\n\t\t\tif(identifiers.length>candidatesForFinalSelection)identifiers=identifiers.slice(0,candidatesForFinalSelection);\n\t\t\tselectedCandidates=lodash.compact(identifiers.map(identifier=>{\n\t\t\t\tlet selectedCandidate=candidates.find(candidate=>String(candidate[candidateIdentifierField]).toLowerCase()===identifier.toLowerCase());\n\t\t\t\tif(selectedCandidate)return selectedCandidate;\n\t\t\t\tselectedCandidate=candidates.find(candidate=>String(candidate[candidateIdentifierField]).toLowerCase().includes(identifier.toLowerCase()));\n\t\t\t\tif(selectedCandidate)return selectedCandidate;\n\t\t\t\tselectedCandidate=candidates.find(candidate=>identifier.toLowerCase().includes(String(candidate[candidateIdentifierField]).toLowerCase()));\n\t\t\t\tif(selectedCandidate)return selectedCandidate;\n\t\t\t\treturn null;\n\t\t\t}));\n\t\t}\n\n\t\tif(!Array.isArray(selectedCandidates)||selectedCandidates.length<=0){\n\t\t\tselectedCandidates=lodash.uniq(lodash.compact(queryResult.map(result=>{\n\t\t\t\tlet identifier=extractIdentifierFromCandidateDocument({\n\t\t\t\t\tcandidateDocument:result.pageContent,\n\t\t\t\t\tcandidateIdentifierField:String(candidateIdentifierField)\n\t\t\t\t});\n\t\t\t\tif(this.DEBUG)console.log('Extracted identifier from candidate document: '+identifier);\n\t\t\t\tlet selectedCandidate=candidates.find(candidate=>String(candidate[candidateIdentifierField]).toLowerCase()===identifier.toLowerCase());\n\t\t\t\tif(selectedCandidate)return selectedCandidate;\n\t\t\t\tselectedCandidate=candidates.find(candidate=>String(candidate[candidateIdentifierField]).toLowerCase().includes(identifier.toLowerCase()));\n\t\t\t\tif(selectedCandidate)return selectedCandidate;\n\t\t\t\tselectedCandidate=candidates.find(candidate=>identifier.toLowerCase().includes(String(candidate[candidateIdentifierField]).toLowerCase()));\n\t\t\t\tif(selectedCandidate)return selectedCandidate;\n\t\t\t\treturn null;\n\t\t\t}))).slice(candidatesForFinalSelection);\n\t\t}\n\t\tif(this.DEBUG)console.log('Selected candidates',selectedCandidates);\n\n\t\treturn{\n\t\t\trationale,\n\t\t\tselectedCandidates\n\t\t};\n\t}\n};\n\nexport namespace AICompareCandidates{\n\texport interface LoadArguments{\n\t\tprogressCallback?:ProgressCallback;\n\t\tmodelName:string;\n\t};\n\n\texport interface SummarisableSubstringIndices{\n\t\tstart:number;\n\t\tend:number;\n\t};\n\n\texport interface CompareArguments<Candidate>{\n\t\tcandidates:Candidate[];\n\t\tproblemDescription:string;\n\t\tgenerateSearchAreasInstruction?:(problemDescription:string)=>string;\n\t\tconvertCandidateToDocument?:(convertCandidateToDocumentArguments:ConvertCandidateToDocumentArguments<Candidate>)=>string;\n\t\tcandidatesForInitialSelection?:number;\n\t\tcandidatesForFinalSelection?:number;\n\t\tgenerateRankingInstruction?:(generateRankingInstructionArguments:GenerateRankingInstructionArguments)=>string;\n\t\textractIdentifiersFromRationale?:(rationale:string)=>string[];\n\t\textractIdentifierFromCandidateDocument?:(extractIdentifierFromCandidateDocumentArguments:ExtractIdentifierFromCandidateDocumentArguments)=>string;\n\t\tcandidateIdentifierField?:keyof Candidate;\n\t\tgetSummarisableSubstringIndices?:(candidateDocument:string)=>SummarisableSubstringIndices;\n\t};\n\n\texport interface ConvertCandidateToDocumentArguments<Candidate>{\n\t\tcandidate:Candidate;\n\t\tindex:number;\n\t};\n\n\texport interface ExtractIdentifierFromCandidateDocumentArguments{\n\t\tcandidateDocument:string;\n\t\tcandidateIdentifierField:string;\n\t};\n\n\texport interface GenerateRankingInstructionArguments{\n\t\tproblemDescription:string;\n\t\tsummaries:string[];\n\t\tcandidatesForFinalSelection:number;\n\t\tcandidateIdentifierField:string;\n\t};\n\n\texport interface CompareCandidatesReturn<Candidate>{\n\t\tselectedCandidates:Candidate[],\n\t\trationale:string\n\t};\n};\n\nexport default AICompareCandidates;"],"mappings":"8PAiBA,IAAa,EAAb,cAAyC,CAAU,CAClD,IAAa,EACb,MAAM,GAEN,UAAsC,KACtC,mBAAmB,yBACnB,iBAAsD,KACtD,sBAAiD,EAAE,CACnD,0BAAgD,KAEhD,WAAsC,KACtC,oBAAoB,6BACpB,kBAAsD,KACtD,uBAAkD,EAAE,CACpD,2BAAiD,KAEjD,SAAwC,KACxC,kBAAkB,2BAClB,gBAAwD,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,CACL,YACA,qBACA,2BAoDH,IAAA,EAAe"}
@@ -0,0 +1,51 @@
1
+ root=true
2
+
3
+ [*]
4
+ charset=utf-8
5
+ indent_style=tab
6
+ indent_size=4
7
+ end_of_line=lf
8
+ insert_final_newline=false
9
+ trim_trailing_whitespace=false
10
+ space_before_type_parameters_brackets=false
11
+ space_within_type_parameters_brackets=false
12
+ space_before_colon_in_type_annotation=false
13
+ space_after_colon_in_type_annotation=false
14
+ space_around_pipe_or_amper_in_type_usage=false
15
+ space_after_comma=false
16
+ space_before_comma=false
17
+ space_before_semicolon=false
18
+ space_before_semicolon_in_for_statement=false
19
+ space_after_semicolon_in_for_statement=false
20
+ space_before_method_call_parentheses=false
21
+ space_before_empty_method_call_parentheses=false
22
+ space_between_method_call_parameter_list_parentheses=false
23
+ space_between_method_call_empty_parameter_list_parentheses=false
24
+ space_before_method_parentheses=false
25
+ space_before_method_parentheses_anonymous=false
26
+ space_between_method_declaration_empty_parameter_list_parentheses=false
27
+ space_between_method_declaration_parameter_list_parentheses=false
28
+ space_after_keywords_in_control_flow_statements=false
29
+ space_between_parentheses_of_control_flow_statements=false
30
+ space_before_open_square_brackets=false
31
+ space_between_square_brackets=false
32
+ space_before_ternary_quest=false
33
+ space_after_ternary_quest=false
34
+ space_before_ternary_colon=false
35
+ space_after_ternary_colon=false
36
+ space_before_property_colon=false
37
+ space_after_property_colon=false
38
+ space_within_object_literal_braces=false
39
+ space_within_empty_object_literal_braces=false
40
+ space_within_import_braces=false
41
+ space_between_square_brackets=false
42
+ space_between_empty_square_brackets=false
43
+ space_around_binary_operator=false
44
+ space_around_assignment_operator=false
45
+ space_around_dot=false
46
+ space_within_parentheses=false
47
+ space_before_colon_in_case=false
48
+ space_before_arrow=false
49
+ space_after_arrow=false
50
+ space_within_template_argument=false
51
+ types_braces=end_of_line_no_space
@@ -0,0 +1,13 @@
1
+ {
2
+ "recommendations": [
3
+ "editorconfig.editorconfig",
4
+ "vue.volar",
5
+ "wayou.vscode-todo-highlight"
6
+ ],
7
+ "unwantedRecommendations": [
8
+ "octref.vetur",
9
+ "hookyqr.beautify",
10
+ "dbaeumer.jshint",
11
+ "ms-vscode.vscode-typescript-tslint-plugin"
12
+ ]
13
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "editor.bracketPairColorization.enabled": true,
3
+ "editor.guides.bracketPairs": true,
4
+ "typescript.tsdk": "node_modules/typescript/lib"
5
+ }
@@ -0,0 +1,21 @@
1
+ # AI Compare Candidates Example (ai-compare-candidates-example)
2
+
3
+ An example for the ai-compare-candidates library
4
+
5
+ ## Install the dependencies
6
+ ```bash
7
+ yarn workspaces focus
8
+ ```
9
+
10
+ ### Start the app in development mode (hot-code reloading, error reporting, etc.)
11
+ ```bash
12
+ quasar dev
13
+ ```
14
+
15
+ ### Build the app for production
16
+ ```bash
17
+ quasar build
18
+ ```
19
+
20
+ ### Customize the configuration
21
+ See [Configuring quasar.config.ts](https://v2.quasar.dev/quasar-cli-vite/quasar-config-js).
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= productName %></title>
5
+
6
+ <meta charset="utf-8">
7
+ <meta name="description" content="<%= productDescription %>">
8
+ <meta name="format-detection" content="telephone=no">
9
+ <meta name="msapplication-tap-highlight" content="no">
10
+ <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width<% if (ctx.mode.cordova || ctx.mode.capacitor) { %>, viewport-fit=cover<% } %>">
11
+
12
+ <link rel="icon" type="image/png" sizes="128x128" href="icons/favicon-128x128.png">
13
+ <link rel="icon" type="image/png" sizes="96x96" href="icons/favicon-96x96.png">
14
+ <link rel="icon" type="image/png" sizes="32x32" href="icons/favicon-32x32.png">
15
+ <link rel="icon" type="image/png" sizes="16x16" href="icons/favicon-16x16.png">
16
+ <link rel="icon" type="image/ico" href="favicon.ico">
17
+ </head>
18
+ <body>
19
+ <!-- quasar:entry-point -->
20
+ </body>
21
+ </html>
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "ai-compare-candidates-example",
3
+ "version": "0.0.1",
4
+ "description": "An example for the ai-compare-candidates library",
5
+ "productName": "AI Compare Candidates Example",
6
+ "author": "Wilson Foo Yu Kang <wilson.foo@customautosys.com>",
7
+ "type": "module",
8
+ "private": true,
9
+ "scripts": {
10
+ "dev": "quasar dev",
11
+ "build": "quasar build",
12
+ "postinstall": "quasar prepare"
13
+ },
14
+ "dependencies": {
15
+ "@quasar/extras": "^1.16.4",
16
+ "jsan": "^3.1.14",
17
+ "lodash": "^4.17.21",
18
+ "pinia": "^3.0.1",
19
+ "quasar": "^2.16.0",
20
+ "vue": "^3.5.22",
21
+ "vue-router": "^4.0.12"
22
+ },
23
+ "devDependencies": {
24
+ "@quasar/app-vite": "^2.1.0",
25
+ "@types/jsan": "^3",
26
+ "@types/lodash": "^4",
27
+ "@types/node": "^20.5.9",
28
+ "ai-compare-candidates": "workspace:*",
29
+ "autoprefixer": "^10.4.2",
30
+ "typescript": "^5.9.2"
31
+ },
32
+ "engines": {
33
+ "node": "^28 || ^26 || ^24 || ^22 || ^20",
34
+ "npm": ">= 6.13.4",
35
+ "yarn": ">= 1.21.1"
36
+ }
37
+ }
@@ -0,0 +1,29 @@
1
+ // https://github.com/michael-ciniawsky/postcss-load-config
2
+
3
+ import autoprefixer from 'autoprefixer'
4
+ // import rtlcss from 'postcss-rtlcss'
5
+
6
+ export default{
7
+ plugins:[
8
+ // https://github.com/postcss/autoprefixer
9
+ autoprefixer({
10
+ overrideBrowserslist:[
11
+ 'last 4 Chrome versions',
12
+ 'last 4 Firefox versions',
13
+ 'last 4 Edge versions',
14
+ 'last 4 Safari versions',
15
+ 'last 4 Android versions',
16
+ 'last 4 ChromeAndroid versions',
17
+ 'last 4 FirefoxAndroid versions',
18
+ 'last 4 iOS versions'
19
+ ]
20
+ }),
21
+
22
+ // https://github.com/elchininet/postcss-rtlcss
23
+ // If you want to support RTL css, then
24
+ // 1. yarn/pnpm/bun/npm install postcss-rtlcss
25
+ // 2. optionally set quasar.config.js > framework > lang to an RTL language
26
+ // 3. uncomment the following line (and its import statement above):
27
+ // rtlcss()
28
+ ]
29
+ };
Binary file
@@ -0,0 +1,222 @@
1
+ // Configuration for your app
2
+ // https://v2.quasar.dev/quasar-cli-vite/quasar-config-file
3
+
4
+ import {defineConfig} from '#q-app/wrappers';
5
+
6
+ export default defineConfig((ctx)=>{
7
+ return{
8
+ // https://v2.quasar.dev/quasar-cli-vite/prefetch-feature
9
+ // preFetch: true,
10
+
11
+ // app boot file (/src/boot)
12
+ // --> boot files are part of "main.js"
13
+ // https://v2.quasar.dev/quasar-cli-vite/boot-files
14
+ boot:[
15
+ 'electronHuggingFaceFix',
16
+ 'icons'
17
+ ],
18
+
19
+ // https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#css
20
+ css:[
21
+ 'app.scss'
22
+ ],
23
+
24
+ // https://github.com/quasarframework/quasar/tree/dev/extras
25
+ extras:[
26
+ // 'ionicons-v4',
27
+ // 'mdi-v7',
28
+ // 'fontawesome-v6',
29
+ // 'eva-icons',
30
+ // 'themify',
31
+ // 'line-awesome',
32
+ // 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both!
33
+
34
+ 'roboto-font', // optional, you are not bound to it
35
+ // 'material-icons', // optional, you are not bound to it
36
+ ],
37
+
38
+ // Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#build
39
+ build:{
40
+ target:{
41
+ browser:[
42
+ 'es2022',
43
+ 'firefox115',
44
+ 'chrome115',
45
+ 'safari14'
46
+ ],
47
+ node:'node20'
48
+ },
49
+
50
+ typescript:{
51
+ strict:true,
52
+ vueShim:true
53
+ // extendTsConfig (tsConfig) {}
54
+ },
55
+
56
+ vueRouterMode:'history', // available values: 'hash', 'history'
57
+ // vueRouterBase,
58
+ // vueDevtools,
59
+ // vueOptionsAPI: false,
60
+
61
+ // rebuildCache: true, // rebuilds Vite/linter/etc cache on startup
62
+
63
+ // publicPath: '/',
64
+ // analyze: true,
65
+ // env: {},
66
+ // rawDefine: {}
67
+ // ignorePublicFolder: true,
68
+ // minify: false,
69
+ // polyfillModulePreload: true,
70
+ // distDir
71
+
72
+ // extendViteConf (viteConf) {},
73
+ // viteVuePluginOptions: {},
74
+
75
+ // vitePlugins: [
76
+ // [ 'package-name', { ..pluginOptions.. }, { server: true, client: true } ]
77
+ // ]
78
+ },
79
+
80
+ // Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#devserver
81
+ devServer:{
82
+ // https: true,
83
+ open:false // opens browser window automatically
84
+ },
85
+
86
+ // https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#framework
87
+ framework:{
88
+ config:{},
89
+
90
+ iconSet: 'svg-fontawesome-v6', // Quasar icon set
91
+ // lang: 'en-US', // Quasar language pack
92
+
93
+ // For special cases outside of where the auto-import strategy can have an impact
94
+ // (like functional components as one of the examples),
95
+ // you can manually specify Quasar components/directives to be available everywhere:
96
+ //
97
+ // components: [],
98
+ // directives: [],
99
+
100
+ // Quasar plugins
101
+ plugins:[
102
+ 'Dialog',
103
+ 'Loading'
104
+ ]
105
+ },
106
+
107
+ // animations: 'all', // --- includes all animations
108
+ // https://v2.quasar.dev/options/animations
109
+ animations:[],
110
+
111
+ // https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#sourcefiles
112
+ // sourceFiles: {
113
+ // rootComponent: 'src/App.vue',
114
+ // router: 'src/router/index',
115
+ // store: 'src/store/index',
116
+ // pwaRegisterServiceWorker: 'src-pwa/register-service-worker',
117
+ // pwaServiceWorker: 'src-pwa/custom-service-worker',
118
+ // pwaManifestFile: 'src-pwa/manifest.json',
119
+ // electronMain: 'src-electron/electron-main',
120
+ // electronPreload: 'src-electron/electron-preload'
121
+ // bexManifestFile: 'src-bex/manifest.json
122
+ // },
123
+
124
+ // https://v2.quasar.dev/quasar-cli-vite/developing-ssr/configuring-ssr
125
+ ssr:{
126
+ prodPort:3000, // The default port that the production server should use
127
+ // (gets superseded if process.env.PORT is specified at runtime)
128
+
129
+ middlewares:[
130
+ 'render' // keep this as last one
131
+ ],
132
+
133
+ // extendPackageJson (json) {},
134
+ // extendSSRWebserverConf (esbuildConf) {},
135
+
136
+ // manualStoreSerialization: true,
137
+ // manualStoreSsrContextInjection: true,
138
+ // manualStoreHydration: true,
139
+ // manualPostHydrationTrigger: true,
140
+
141
+ pwa:false
142
+ // pwaOfflineHtmlFilename: 'offline.html', // do NOT use index.html as name!
143
+
144
+ // pwaExtendGenerateSWOptions (cfg) {},
145
+ // pwaExtendInjectManifestOptions (cfg) {}
146
+ },
147
+
148
+ // https://v2.quasar.dev/quasar-cli-vite/developing-pwa/configuring-pwa
149
+ pwa:{
150
+ workboxMode:'GenerateSW' // 'GenerateSW' or 'InjectManifest'
151
+ // swFilename: 'sw.js',
152
+ // manifestFilename: 'manifest.json',
153
+ // extendManifestJson (json) {},
154
+ // useCredentialsForManifestTag: true,
155
+ // injectPwaMetaTags: false,
156
+ // extendPWACustomSWConf (esbuildConf) {},
157
+ // extendGenerateSWOptions (cfg) {},
158
+ // extendInjectManifestOptions (cfg) {}
159
+ },
160
+
161
+ // Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-cordova-apps/configuring-cordova
162
+ cordova:{
163
+ // noIosLegacyBuildFlag: true, // uncomment only if you know what you are doing
164
+ },
165
+
166
+ // Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-capacitor-apps/configuring-capacitor
167
+ capacitor:{
168
+ hideSplashscreen:true
169
+ },
170
+
171
+ // Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-electron-apps/configuring-electron
172
+ electron:{
173
+ // extendElectronMainConf (esbuildConf) {},
174
+ // extendElectronPreloadConf (esbuildConf) {},
175
+
176
+ // extendPackageJson (json) {},
177
+
178
+ // Electron preload scripts (if any) from /src-electron, WITHOUT file extension
179
+ preloadScripts:['electron-preload'],
180
+
181
+ // specify the debugging port to use for the Electron app when running in development mode
182
+ inspectPort:5858,
183
+
184
+ bundler:'packager', // 'packager' or 'builder'
185
+
186
+ packager:{
187
+ // https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options
188
+
189
+ // OS X / Mac App Store
190
+ // appBundleId: '',
191
+ // appCategoryType: '',
192
+ // osxSign: '',
193
+ // protocol: 'myapp://path',
194
+
195
+ // Windows only
196
+ // win32metadata: { ... }
197
+ },
198
+
199
+ builder:{
200
+ // https://www.electron.build/configuration/configuration
201
+
202
+ appId:'ai-compare-candidates-example'
203
+ }
204
+ },
205
+
206
+ // Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-browser-extensions/configuring-bex
207
+ bex:{
208
+ // extendBexScriptsConf (esbuildConf) {},
209
+ // extendBexManifestJson (json) {},
210
+
211
+ /**
212
+ * The list of extra scripts (js/ts) not in your bex manifest that you want to
213
+ * compile and use in your browser extension. Maybe dynamic use them?
214
+ *
215
+ * Each entry in the list should be a relative filename to /src-bex/
216
+ *
217
+ * @example [ 'my-script.ts', 'sub-folder/my-other-script.js' ]
218
+ */
219
+ extraScripts:[]
220
+ }
221
+ }
222
+ });
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <router-view/>
3
+ </template>
4
+ <script setup lang="ts">
5
+ </script>
@@ -0,0 +1,8 @@
1
+ import {defineBoot} from '#q-app/wrappers';
2
+
3
+ export default defineBoot(()=>{
4
+ if(process.env.MODE==='electron'){
5
+ delete (process.release as any).name;
6
+ delete (process.versions as any).node;
7
+ }
8
+ });
@@ -0,0 +1,20 @@
1
+ import {defineBoot} from '#q-app/wrappers';
2
+ import * as fontawesomeImport from '@quasar/extras/fontawesome-v6';
3
+ import * as materialIconsImport from '@quasar/extras/material-icons';
4
+ import type {QVueGlobals} from 'quasar';
5
+
6
+ export default defineBoot(({app})=>{
7
+ (app.config.globalProperties.$q as QVueGlobals).iconMapFn=iconName=>{
8
+ const fontawesome=fontawesomeImport as {[key:string]:string};
9
+ const materialIcons=materialIconsImport as {[key:string]:string};
10
+ if(materialIcons[iconName])return {icon:materialIcons[iconName]};
11
+ if(fontawesome[iconName])return {icon:fontawesome[iconName]};
12
+ let matches=iconName.match(/(fa[A-Za-z]) fa-(.*?)(as {[key:string]:s\s|$)/);
13
+ if(matches&&matches[1]&&matches[2]){
14
+ let icon=fontawesome[matches[1]+matches[2].replace(/(^|-)([a-z])/g,letters=>String(letters[letters.length-1]).toUpperCase())];
15
+ if(icon)return {icon};
16
+ }
17
+ let icon=materialIcons['mat'+iconName.replace(/(^|-)([a-z])/g,letters=>String(letters[letters.length-1]).toUpperCase())];
18
+ if(icon)return {icon};
19
+ }
20
+ });
@@ -0,0 +1 @@
1
+ // app global css in SCSS form
@@ -0,0 +1,25 @@
1
+ // Quasar SCSS (& Sass) Variables
2
+ // --------------------------------------------------
3
+ // To customize the look and feel of this app, you can override
4
+ // the Sass/SCSS variables found in Quasar's source Sass/SCSS files.
5
+
6
+ // Check documentation for full list of Quasar variables
7
+
8
+ // Your own variables (that are declared here) and Quasar's own
9
+ // ones will be available out of the box in your .vue/.scss/.sass files
10
+
11
+ // It's highly recommended to change the default colors
12
+ // to match your app's branding.
13
+ // Tip: Use the "Theme Builder" on Quasar's documentation website.
14
+
15
+ $primary : #1976D2;
16
+ $secondary : #26A69A;
17
+ $accent : #9C27B0;
18
+
19
+ $dark : #1D1D1D;
20
+ $dark-page : #121212;
21
+
22
+ $positive : #21BA45;
23
+ $negative : #C10015;
24
+ $info : #31CCEC;
25
+ $warning : #F2C037;
@@ -0,0 +1,7 @@
1
+ declare namespace NodeJS{
2
+ interface ProcessEnv{
3
+ NODE_ENV:string;
4
+ VUE_ROUTER_MODE:'hash'|'history'|'abstract'|undefined;
5
+ VUE_ROUTER_BASE:string|undefined;
6
+ }
7
+ }