前言
昨天的Demo以txt文件为例进行说明,并且评估标准写死了,跟真实的简历评估系统差别太大了。今天分享的是经过改进后更加真实的基于LLM的简历评估系统。
使用AI生成了5份不同的简历,如下所示:
程序员A:

程序员B:

程序员C:

程序员D:

程序员E:

输入要求:
shared["requirements"] = """ - 具备前端开发能力 - 使用过Vue """;
效果:

更改要求:
shared["requirements"] = """ - 具备后端开发能力 - 熟悉go语言 """;

全部代码已上传至GitHub,地址:https://github.com/Ming-jiayou/PocketFlowSharp/tree/main/PocketFlowSharpSamples.Console/Real_Resume_Qualification_Demo
C#读取PDF内容
本次更改主要涉及到C#读取PDF内容。
使用的是pdfpig,项目地址:https://github.com/UglyToad/PdfPig

项目简介:使用 C# 读取和提取 PDF 中的文本和其他内容(PDFBox 的移植)
修改Utils类,增加读取PDF内容功能:
public static string ExtractTextFromPdf(string pdfPath) { StringBuilder text = new StringBuilder(); using (PdfDocument document = PdfDocument.Open(pdfPath)) { foreach (Page page in document.GetPages()) { text.AppendLine(page.Text); } } return text.ToString(); }
效果如下所示:

灵活更改简历要求
可以将要求存入共享内存,然后通过$插值字符串,插入到提示词中即可:
string prompt = $@" 评估以下简历并确定候选人是否符合职位的要求。 资格标准: {requirements} 简历内容: {content} 请以YAML格式返回您的评估: ```yaml candidate_name: [候选人姓名] qualifies: [true/false] reasons: - [资格认定/不认定的第一个原因] - [第二个原因(如果适用)] ``` ";
运行时就会变成这样:

与LLM交互
public static string ModelName { get; set; } public static string EndPoint { get; set; } public static string ApiKey { get; set; } public static string CallLLM(string prompt) { ApiKeyCredential apiKeyCredential = new ApiKeyCredential(ApiKey); OpenAIClientOptions openAIClientOptions = new OpenAIClientOptions(); openAIClientOptions.Endpoint = new Uri(EndPoint); ChatClient client = new(model: ModelName, apiKeyCredential, openAIClientOptions); ChatCompletion completion = client.CompleteChat(prompt); return completion.Content[0].Text; }
以上就是通过这个Demo可以学习到的一些内容。