1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| import akasha.prompts as prompts import akasha import akasha.eval as eval
formatter = [ prompts.OutputSchema(name="學歷", description="受試者的就讀大學", type="str"), prompts.OutputSchema(name="經驗", description="受試者的工作經驗", type="str"), prompts.OutputSchema(name="專長", description="受試者的專長能力", type="list"), prompts.OutputSchema(name="年資", description="受試者的總工作年數", type="int") ]
formatter2 = prompts.JSON_formatter_list(names=["學歷","經驗","專長","年資"], types=["str","str","list","int"],\ descriptions=["受試者的就讀大學","受試者的工作經驗","受試者的專長能力","受試者的總工作年數"])
formatter3 = prompts.JSON_formatter_dict([{ "name": "學歷", "description": "受試者的就讀大學", "type": "str" },\ { "name": "經驗", "description": "受試者的工作經驗", "type": "str" },\ { "name": "專長", "description": "受試者的專長能力", "type": "list" },\ { "name": "年資", "description": "受試者的總工作年數", "type": "int" }])
JSON_prompt = prompts.JSON_formatter(formatter) # JSON_prompt = prompts.JSON_formatter(formatter2) # JSON_prompt = prompts.JSON_formatter(formatter3)
ak = akasha.Doc_QA()
response = ak.ask_whole_file(file_path="docs/resume_pool/A.docx", system_prompt=JSON_prompt, prompt=f'''以上是受試者的履歷,請回答該受試者的學歷、經驗、專長、年資''')
parse_json = akasha.helper.extract_json(resposne)
print(parse_json) print(type(parse_json))
|