浏览代码

refactor(agent): 优化智能代理提示和交互逻辑

- 更新智能代理提示信息,增加失败时用中文回答和默认使用百度搜索的指示
- 修改导航器模板中的响应规则,简化为"一定要用中文回答"
- 在验证器提示中添加用中文回答的指示
- 注释掉 ModelSettings 组件中的两个按钮,暂时不使用
- 在 MessageList 组件中,将"done"消息内容改为"完成"
chd 3 月之前
父节点
当前提交
b3c2c094ca

+ 3 - 1
chrome-extension/src/background/agent/prompts/planner.ts

@@ -48,7 +48,9 @@ NOTE:
 
 REMEMBER:
   - Keep your responses concise and focused on actionable insights.
-  - 用中文回答.`);
+  - 用中文回答.
+  - 失败也要用中文回答.
+  - 默认使用百度搜索.`);
   }
 
   async getUserMessage(context: AgentContext): Promise<HumanMessage> {

+ 1 - 3
chrome-extension/src/background/agent/prompts/templates/navigator.ts

@@ -22,7 +22,6 @@ Interactive Elements
 - Elements with * are new elements that were added after the previous step (if url has not changed)
 
 # Response Rules
-
 1. RESPONSE FORMAT: You must ALWAYS respond with valid JSON in this exact format:
    {"current_state": {"evaluation_previous_goal": "Success|Failed|Unknown - Analyze the current elements and the image to check if the previous goals/actions are successful like intended by the task. Mention if something unexpected happened. Shortly state why/why not",
    "memory": "Description of what has been done and what you need to remember. Be very specific. Count here ALWAYS how many times you have done something and how many remain. E.g. 0 out of 10 websites analyzed. Continue with abc and xyz",
@@ -114,6 +113,5 @@ Common action sequences:
 - Plan is a json string wrapped by the <plan> tag
 - If a plan is provided, follow the instructions in the next_steps exactly first
 - If no plan is provided, just continue with the task
-REMEMBER:
--用中文回答.
+12. 一定要用中文回答
 `;

+ 2 - 0
chrome-extension/src/background/agent/prompts/validator.ts

@@ -27,6 +27,8 @@ The above task is a follow up task of the following tasks, please take the previ
 
 Previous tasks:
 ${previousTasks}
+REMEMBER:
+- 用中文回答.
 `;
     return tasksString;
   }

+ 4 - 4
pages/options/src/components/ModelSettings.tsx

@@ -1114,7 +1114,7 @@ export const ModelSettings = ({ isDarkMode = false }: ModelSettingsProps) => {
                           取消
                         </Button>
                       )}
-                      <Button
+                      {/* <Button
                         variant={getButtonProps(providerId).variant}
                         disabled={getButtonProps(providerId).disabled}
                         onClick={() =>
@@ -1123,7 +1123,7 @@ export const ModelSettings = ({ isDarkMode = false }: ModelSettingsProps) => {
                             : handleSave(providerId)
                         }>
                         {getButtonProps(providerId).children}
-                      </Button>
+                      </Button> */}
                     </div>
                   </div>
 
@@ -1495,7 +1495,7 @@ export const ModelSettings = ({ isDarkMode = false }: ModelSettingsProps) => {
 
           {/* Add Provider button and dropdown */}
           <div className="provider-selector-container relative pt-4">
-            <Button
+            {/* <Button
               variant="secondary"
               onClick={() => setIsProviderSelectorOpen(prev => !prev)}
               className={`flex w-full items-center justify-center font-medium ${
@@ -1504,7 +1504,7 @@ export const ModelSettings = ({ isDarkMode = false }: ModelSettingsProps) => {
                   : 'border-blue-200 bg-blue-100 text-blue-800 hover:bg-blue-200'
               }`}>
               <span className="mr-2 text-sm">+</span> <span className="text-sm">添加新模型</span>
-            </Button>
+            </Button> */}
 
             {isProviderSelectorOpen && (
               <div

+ 2 - 0
pages/side-panel/src/components/MessageList.tsx

@@ -65,6 +65,8 @@ function MessageBlock({ message, isSameActor, isDarkMode = false }: MessageBlock
               <div className={`h-1 overflow-hidden rounded ${isDarkMode ? 'bg-gray-700' : 'bg-gray-200'}`}>
                 <div className="animate-progress h-full bg-blue-500" />
               </div>
+            ) : message.content === 'done' ? (
+              '完成'
             ) : (
               message.content
             )}