feat: 更新智能账单解析助手的分类信息提示,增强用户体验
This commit is contained in:
@@ -428,15 +428,40 @@ public class SmartHandleService(
|
||||
var categories = await categoryRepository.GetAllAsync();
|
||||
var categoryList = string.Join("、", categories.Select(c => $"{GetTypeName(c.Type)}-{c.Name}"));
|
||||
|
||||
var sysPrompt = $"""
|
||||
// 构建分类信息
|
||||
var categoryInfo = new StringBuilder();
|
||||
foreach (var type in new[] { 0, 1, 2 })
|
||||
{
|
||||
var typeName = GetTypeName((TransactionType)type);
|
||||
categoryInfo.AppendLine($"{typeName}: ");
|
||||
var categoriesOfType = categories.Where(c => (int)c.Type == type).ToList();
|
||||
foreach (var category in categoriesOfType)
|
||||
{
|
||||
categoryInfo.AppendLine($"- {category.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
var sysPrompt = $$"""
|
||||
你是一个智能账单解析助手。请从用户提供的文本中提取交易信息,包括日期、金额、摘要、类型和分类。
|
||||
|
||||
可用的分类列表:
|
||||
{{categoryInfo}}
|
||||
|
||||
请返回 JSON 格式,包含以下字段:
|
||||
- OccurredAt: 日期时间,格式 yyyy-MM-dd HH:mm:ss。当前系统时间为{DateTime.Now:yyyy-MM-dd HH:mm:ss}。
|
||||
- OccurredAt: 日期时间,格式 yyyy-MM-dd HH:mm:ss。当前系统时间为{{DateTime.Now:yyyy-MM-dd HH:mm:ss}}。
|
||||
- Amount: 金额,数字。
|
||||
- Reason: 备注/摘要,原文或其他补充信息。
|
||||
- Type: 交易类型,0=支出,1=收入,2=不计入收支。根据语义判断。
|
||||
- Classify: 分类,请从以下现有分类中选择最匹配的一个:{categoryList}。如果无法匹配,请返回""其他""。
|
||||
- Classify: 分类,请从以下现有分类中选择最匹配的一个:如果无法匹配,请留空。
|
||||
|
||||
返回示例
|
||||
{
|
||||
"OccurredAt": "2024-06-15 14:30:00",
|
||||
"Amount": 150.75,
|
||||
"Reason": "午餐消费",
|
||||
"Type": 0,
|
||||
"Classify": "餐饮"
|
||||
}
|
||||
|
||||
只返回 JSON,不要包含 markdown 标记。
|
||||
""";
|
||||
|
||||
Reference in New Issue
Block a user