优化LLM提示词

This commit is contained in:
2026-02-28 22:34:51 +08:00
parent 6beb8b5be9
commit 53f1c4902c
9 changed files with 292 additions and 30 deletions

View File

@@ -1,17 +1,11 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
@@ -21,15 +15,8 @@ using CommunityToolkit.Mvvm.Messaging;
using LangChain.Providers;
using LangChain.Providers.DeepSeek;
using LangChain.Providers.DeepSeek.Predefined;
using LangChain.Providers.OpenAI.Predefined;
using Markdig;
using Markdig.Syntax;
using Markdig.Wpf.ColorCode;
using tryAGI.OpenAI;
//using LangChain.Schema;
//using static LangChain.Chains.Chain;
@@ -142,13 +129,13 @@ public partial class ChatDialogueViewModel : ObservableObject
{
if (ChatHistory.Count == 0)
{
CurrentRequest += Message.Human($"你是专业的Revit二次开发工程师不随意捏造事实能客观地回答用户的问题对于不确定或难以理解的问题需要用户补充说明的需要主动提出。你需要在{GlobalVariables.UIApplication.Application.VersionName}二次开发中使用已定义的uidoc、doc两个变量构造一个可以正确执行的C#代码块保证使用的RevitAPI的所有方法都能在{GlobalVariables.UIApplication.Application.VersionName}版本的API文档中找到在代码中添加关键的注释不需要Excute方法签名和using命名空间使用类声明对象时需要完整的命名空间。需求是{UserInput}");
ChatHistory.Add(CurrentRequest);
var systemPrompt = new PromptManager(Path.Combine(GlobalVariables.DirAssembly, "Templates/SystemPrompt.txt")).GetSystemPrompt();
CurrentRequest += Message.Ai($"{systemPrompt}\n\r注意当前的Revit版本是{GlobalVariables.UIApplication.Application.VersionName}");
ChatHistory.Add(Message.Human($"{UserInput}"));
}
else
{
ChatHistory.Add(Message.Human(UserInput));
CurrentRequest += Message.Human(UserInput);
}