XML格式

XML Formatter

如果你想讓語言模型的回答為XML格式,可以使用XMLformatter

範例

如以下範例,首先先定義你想要回傳的key值的名稱、說明和型別,並利用XML_formatter轉換成xml格式的prompt,並在問問題時把xml_prompt丟入system_prompt中。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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")
]
xml_prompt = prompts.XML_formatter(formatter)


ak = akasha.Doc_QA()

response = ak.ask_whole_file(file_path="docs/resume_pool/A.docx",
system_prompt=xml_prompt, prompt=f'''以上是受試者的履歷,請回答該受試者的學歷、經驗、專長、年資''')

print(response)
1
2
3
4
5
6
7
8
9
10
11
<?xml version="1.0" encoding="UTF-8"?>
<resume>
<學歷>國立臺北科技大學電資學士班 四技 就學中</學歷>
<經驗>英文短期文理補習班補習班導師/管理人員</經驗>
<專長>
<能力>語言能力</能力>
<英文>聽-中等, 說-中等, 讀-中等, 寫-中等</英文>
<證照>TOEIC </證照>
</專長>
<年資>0-1</年資>
</resume>