-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from MichealWayne/feat-utils-npm
feat update ai utils & links
- Loading branch information
Showing
11 changed files
with
314 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# fe-tools datas | ||
|
||
供 chrome 插件进行搜索和查询的数据。 | ||
- `moo-css.json`:样式查询 | ||
- `regex.json`:正则规则查询 | ||
- `tools.json`:各常用链接查询 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,247 @@ | ||
[{ | ||
"id": "mail", | ||
"name": "邮箱", | ||
"description": "只允许英文字母、数字、下划线、英文句号、以及中划线组成", | ||
"regexStr": "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$" | ||
}, | ||
{ | ||
"id": "phone", | ||
"name": "手机号", | ||
"description": "", | ||
"regexStr": "^1(3|4|5|6|7|8|9)\\d{9}$" | ||
}, | ||
{ | ||
"id": "tel", | ||
"name": "电话", | ||
"description": "固定电话", | ||
"regexStr": "(\\(\\d{3,4}\\)|\\d{3,4}-|\\s)?\\d{8}" | ||
}, | ||
{ | ||
"id": "url", | ||
"name": "URL地址", | ||
"description": "", | ||
"regexStr": "^((http:\/\/)|(https:\/\/))?([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}(\/?)" | ||
}, | ||
{ | ||
"id": "ipv4", | ||
"name": "IP", | ||
"description": "符合IPV4", | ||
"regexStr": "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" | ||
}, | ||
{ | ||
"id": "ipv6", | ||
"name": "IP", | ||
"description": "符合IPV6", | ||
"regexStr": "^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$" | ||
}, | ||
{ | ||
"id": "userName", | ||
"name": "用户名", | ||
"description": "字母开头,允许5-16字节,允许字母数字下划线", | ||
"regexStr": "^[a-zA-Z][a-zA-Z0-9_]{4,15}$" | ||
}, | ||
{ | ||
"id": "chinese", | ||
"name": "中文", | ||
"description": "", | ||
"regexStr": "^[\u4e00-\u9fa5]{1,}$" | ||
}, | ||
{ | ||
"id": "Integer", | ||
"name": "整数数字", | ||
"description": "", | ||
"regexStr": "^-?[1-9]\\d*$" | ||
}, | ||
{ | ||
"id": "PositiveInteger", | ||
"name": "正整数数字", | ||
"description": "", | ||
"regexStr": "^[1-9]\\d*$" | ||
}, | ||
{ | ||
"id": "NegativeInteger", | ||
"name": "负整数数字", | ||
"description": "", | ||
"regexStr": "^-[1-9]\\d*$" | ||
}, | ||
{ | ||
"id": "number4", | ||
"name": "非负整数数字", | ||
"description": "", | ||
"regexStr": "^[1-9]\\d*|0$" | ||
}, | ||
{ | ||
"id": "number5", | ||
"name": "非正整数数字", | ||
"description": "", | ||
"regexStr": "^-[1-9]\\d*|0$" | ||
}, | ||
{ | ||
"id": "Positivenumber", | ||
"name": "零和正数", | ||
"description": "", | ||
"regexStr": "^\\d*\\.?\\d+$" | ||
}, | ||
{ | ||
"id": "Negativenumber", | ||
"name": "负数", | ||
"description": "", | ||
"regexStr": "^-\\d*\\.?\\d+$" | ||
}, | ||
{ | ||
"id": "number6", | ||
"name": "浮点数", | ||
"description": "不能为整数", | ||
"regexStr": "^-?([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|0?\\.0+|0)$" | ||
}, | ||
{ | ||
"id": "number7", | ||
"name": "正浮点数", | ||
"description": "不能为整数", | ||
"regexStr": "^[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*$" | ||
}, | ||
{ | ||
"id": "number8", | ||
"name": "负浮点数", | ||
"description": "不能为整数", | ||
"regexStr": "^-([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*)$" | ||
}, | ||
{ | ||
"id": "number9", | ||
"name": "非负浮点数", | ||
"description": "不能为整数", | ||
"regexStr": "^[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|0?\\.0+|0$" | ||
}, | ||
{ | ||
"id": "number10", | ||
"name": "非正浮点数", | ||
"description": "不能为整数", | ||
"regexStr": "^(-([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*))|0?\\.0+|0$" | ||
}, | ||
{ | ||
"id": "englishAndNumber", | ||
"name": "英文和数字", | ||
"description": "", | ||
"regexStr": "^[A-Za-z0-9]+$" | ||
}, | ||
{ | ||
"id": "englishAndNumberAndLine", | ||
"name": "中文英文数字或下划线", | ||
"description": "由中文、数字、26个英文字母或者下划线组成的字符串", | ||
"regexStr": "^[\u4E00-\u9FA5A-Za-z0-9_]+$" | ||
}, | ||
{ | ||
"id": "chineseAndEnglishAndNumberAndLine", | ||
"name": "中文英文数字或下划线", | ||
"description": "中文、英文、数字包括下划线", | ||
"regexStr": "^\\w+$" | ||
}, | ||
{ | ||
"id": "chineseAndEnglishAndNumberNotLine", | ||
"name": "中文英文数字无符号", | ||
"description": "中文、英文、数字但不包括下划线等符号", | ||
"regexStr": "^[\u4E00-\u9FA5A-Za-z0-9]+$" | ||
}, | ||
{ | ||
"id": "lengthExample", | ||
"name": "长度限制", | ||
"description": "长度为6~8,任意字符", | ||
"regexStr": "^.{6,8}$" | ||
}, | ||
{ | ||
"id": "english", | ||
"name": "英文", | ||
"description": "由26个英文字母组成的字符串", | ||
"regexStr": "^[A-Za-z]+$" | ||
}, | ||
{ | ||
"id": "english2", | ||
"name": "英文", | ||
"description": "由26个大写英文字母组成的字符串", | ||
"regexStr": "^[A-Z]+$" | ||
}, | ||
{ | ||
"id": "english3", | ||
"name": "英文", | ||
"description": "由26个小写英文字母组成的字符串", | ||
"regexStr": "^[a-z]+$" | ||
}, | ||
{ | ||
"id": "noSymbol1", | ||
"name": "禁止符号", | ||
"description": "禁止输入含有%&\",;=?$\"等字符", | ||
"regexStr": "[^%&\",;=?$\\x22]+" | ||
}, | ||
{ | ||
"id": "noWave", | ||
"name": "禁止~符号", | ||
"description": "禁止输入含有~的字符", | ||
"regexStr": "[^~\\x22]+" | ||
}, | ||
{ | ||
"id": "dateFormat", | ||
"name": "日期格式", | ||
"description": "日期格式符合mm/dd/yyyy规范", | ||
"regexStr": "^(0?[1-9]|[12][0-9]|3[01])([\/\\-])(0?[1-9]|1[012])\\2([0-9][0-9][0-9][0-9])(([-])([0-1]?[0-9]|2[0-3]):[0-5]?[0-9]:[0-5]?[0-9])?$" | ||
}, | ||
{ | ||
"id": "timeFormat", | ||
"name": "时间格式hh:mm", | ||
"description": "时间格式符合24小时格式规范", | ||
"regexStr": "^([01]?[0-9]|2[0-3]):[0-5][0-9]$" | ||
}, | ||
{ | ||
"id": "md5", | ||
"name": "MD5", | ||
"description": "32位MD5字符串", | ||
"regexStr": "^[a-f0-9]{32}$" | ||
}, | ||
{ | ||
"id": "base64", | ||
"name": "BASE64", | ||
"description": "BASE64字符串", | ||
"regexStr": "^\\s*data:(?:[a-z]+\/[a-z0-9-+.]+(?:;[a-z-]+=[a-z0-9-]+)?)?(?:;base64)?,([a-z0-9!$&',()*+;=\\-._~:@\/?%\\s]*?)\\s*$" | ||
}, | ||
{ | ||
"id": "hexColor", | ||
"name": "十六进制颜色", | ||
"description": "", | ||
"regexStr": "^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$" | ||
}, | ||
{ | ||
"id": "video", | ||
"name": "视频文件", | ||
"description": "", | ||
"regexStr": ".*?(?:swf|avi|flv|mpg|rm|mov|wav|asf|3gp|mkv|rmvb|mp4)$" | ||
}, | ||
{ | ||
"id": "image", | ||
"name": "图片文件", | ||
"description": "", | ||
"regexStr": ".*?(?:gif|png|jpg|jpeg|webp|svg|psd|bmp|tif)$" | ||
}, | ||
{ | ||
"id": "newEnergyLicense", | ||
"name": "新能源车牌", | ||
"description": "", | ||
"regexStr": "[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领 A-Z]{1}[A-HJ-NP-Z]{1}(([0-9]{5}[DF])|([DF][A-HJ-NP-Z0-9][0-9]{4}))$" | ||
}, | ||
{ | ||
"id": "license", | ||
"name": "普通车牌", | ||
"description": "新能源车+非新能源车", | ||
"regexStr": "^(?:[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领 A-Z]{1}[A-HJ-NP-Z]{1}(?:(?:[0-9]{5}[DF])|(?:[DF](?:[A-HJ-NP-Z0-9])[0-9]{4})))|(?:[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领 A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9 挂学警港澳]{1})$" | ||
}, | ||
{ | ||
"id": "A-SHARE", | ||
"name": "股票-A股", | ||
"description": "股票代码", | ||
"regexStr": "^(s[hz]|S[HZ])(000[\\d]{3}|002[\\d]{3}|300[\\d]{3}|600[\\d]{3}|60[\\d]{4})$" | ||
}, | ||
{ | ||
"id": "wechatId", | ||
"name": "微信号", | ||
"description": "", | ||
"regexStr": "^[a-zA-Z][-_a-zA-Z0-9]{5,19}$" | ||
} | ||
] |
Large diffs are not rendered by default.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
utils/packages/ai-utils/src/applications/createUnitTestCases.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @author Wayne | ||
* @Date 2024-05-11 10:40:18 | ||
* @LastEditTime 2024-05-11 10:47:53 | ||
*/ | ||
import { estimateTokenLength } from '../llm/prompts'; | ||
const MAX_TOKEN_LEN = 4000; // GPT3.5 4096 | ||
|
||
export function getCreateUnitTestCases(patch: string) { | ||
return `### Unit Test ### | ||
You are an expert software tester tasked with thoroughly testing a given piece of code, you are proficient in JavaScript/TypeScript. | ||
Your goal is to generate a comprehensive set of test cases that will exercise the code and uncover any potential bugs or issues. | ||
First, carefully analyze the provided code. Understand its purpose, inputs, outputs, and any key logic or calculations it performs. Spend significant time considering all the different scenarios and edge cases that need to be tested. | ||
Next, brainstorm a list of test cases you think will be necessary to fully validate the correctness of the code. | ||
Your current role is: UnitTest code generator | ||
## | ||
- use jest test framework | ||
- use typescript | ||
- the test environment is Node.js | ||
- only generate code with no explain | ||
- write the\`prepareChatMessages\` and \`getFirstAnswerMsg\` and \`setChatMessages\` and \`setModel\` method's unit test cases | ||
Here is your target code to generate tests: | ||
\`\`\` | ||
{{your_code_here}} | ||
\`\`\` | ||
`; | ||
} | ||
|
||
export function genUnitTestCasesPrompt(codeStr: string, maxLen = MAX_TOKEN_LEN) { | ||
const promptTxt = getCreateUnitTestCases(codeStr); | ||
|
||
if (estimateTokenLength(promptTxt) > maxLen) { | ||
return ''; | ||
} | ||
return promptTxt; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.