1
0

4 کامیت‌ها ff850a586d ... b86ce911e5

نویسنده SHA1 پیام تاریخ
  wzg b86ce911e5 refactor(side-panel): 重构侧边栏组件布局和功能 3 ماه پیش
  chd c58233706e feat(chrome-extension): 为 AI 任务指令添加中文回答要求 3 ماه پیش
  wzg bc65a74950 Merge remote-tracking branch 'second-origin/wzg' into merge_branch 3 ماه پیش
  chd b3c2c094ca refactor(agent): 优化智能代理提示和交互逻辑 3 ماه پیش

+ 1 - 1
chrome-extension/src/background/agent/messages/service.ts

@@ -138,7 +138,7 @@ export default class MessageManager {
    * @returns A HumanMessage object containing the task instructions
    */
   private static taskInstructions(task: string): HumanMessage {
-    const content = `Your ultimate task is: """${task}""". If you achieved your ultimate task, stop everything and use the done action in the next step to complete the task. If not, continue as usual.`;
+    const content = `Your ultimate task is: """${task}""". If you achieved your ultimate task, stop everything and use the done action in the next step to complete the task. If not, continue as usual.你的所有回答都要用中文回答.`;
     return new HumanMessage({ content });
   }
 

+ 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

+ 56 - 83
pages/side-panel/src/SidePanel.tsx

@@ -8,9 +8,7 @@ import { type Message, Actors, chatHistoryStore } from '@extension/storage';
 import MessageList from './components/MessageList';
 import ChatInput from './components/ChatInput';
 import ChatHistoryList from './components/ChatHistoryList';
-import TemplateList from './components/TemplateList';
 import { EventType, type AgentEvent, ExecutionState } from './types/event';
-import { defaultTemplates } from './templates';
 import './SidePanel.css';
 
 const SidePanel = () => {
@@ -540,60 +538,13 @@ const SidePanel = () => {
     <div>
       <div
         className={`flex h-screen flex-col ${isDarkMode ? 'bg-slate-900' : ''} overflow-hidden border ${isDarkMode ? 'border-sky-800' : 'border-[rgb(186,230,253)]'} rounded-2xl`}>
-        <header className="header relative">
-          <div className="header-logo">
-            {showHistory ? (
-              <button
-                type="button"
-                onClick={handleBackToChat}
-                className={`${isDarkMode ? 'text-sky-400 hover:text-sky-300' : 'text-sky-400 hover:text-sky-500'} cursor-pointer`}
-                aria-label="返回聊天">
-                ← 返回
-              </button>
-            ) : (
-              <img src="/icon.png" alt="Extension Logo" className="size-6" />
-            )}
-          </div>
-          <div className="header-icons">
-            {!showHistory && (
-              <>
-                <button
-                  type="button"
-                  onClick={handleNewChat}
-                  onKeyDown={e => e.key === 'Enter' && handleNewChat()}
-                  className={`header-icon ${isDarkMode ? 'text-sky-400 hover:text-sky-300' : 'text-sky-400 hover:text-sky-500'} cursor-pointer`}
-                  aria-label="New Chat"
-                  tabIndex={0}>
-                  <PiPlusBold size={20} />
-                </button>
-                <button
-                  type="button"
-                  onClick={handleLoadHistory}
-                  onKeyDown={e => e.key === 'Enter' && handleLoadHistory()}
-                  className={`header-icon ${isDarkMode ? 'text-sky-400 hover:text-sky-300' : 'text-sky-400 hover:text-sky-500'} cursor-pointer`}
-                  aria-label="Load History"
-                  tabIndex={0}>
-                  <GrHistory size={20} />
-                </button>
-              </>
-            )}
-            <button
-              type="button"
-              onClick={() => chrome.runtime.openOptionsPage()}
-              onKeyDown={e => e.key === 'Enter' && chrome.runtime.openOptionsPage()}
-              className={`header-icon ${isDarkMode ? 'text-sky-400 hover:text-sky-300' : 'text-sky-400 hover:text-sky-500'} cursor-pointer`}
-              aria-label="Settings"
-              tabIndex={0}>
-              <FiSettings size={20} />
-            </button>
-          </div>
-        </header>
         {showHistory ? (
           <div className="flex-1 overflow-hidden">
             <ChatHistoryList
               sessions={chatSessions}
               onSessionSelect={handleSessionSelect}
               onSessionDelete={handleSessionDelete}
+              handleBackToChat={handleBackToChat}
               visible={true}
               isDarkMode={isDarkMode}
             />
@@ -602,26 +553,14 @@ const SidePanel = () => {
           <>
             {messages.length === 0 && (
               <>
-                <div
-                  className={`border-t ${isDarkMode ? 'border-sky-900' : 'border-sky-100'} mb-2 p-2 shadow-sm backdrop-blur-sm`}>
-                  <ChatInput
-                    onSendMessage={handleSendMessage}
-                    onStopTask={handleStopTask}
-                    disabled={!inputEnabled || isHistoricalSession}
-                    showStopButton={showStopButton}
-                    setContent={setter => {
-                      setInputTextRef.current = setter;
-                    }}
-                    isDarkMode={isDarkMode}
-                  />
+                <div className="w-full h-full pt-20">
+                  <div className="max-w-[720px] text-left m-auto p-5">
+                    <p className="font-black text-4xl mb-4 text-black">你好,</p>
+                    <p className="font-black text-3xl mb-4 text-black">我是PVS智能助手,</p>
+                    <p className="font-black text-2xl mb-4 text-black">我今天能帮你什么?</p>
+                    {/*<span className="text-black">作为你的智能伙伴,我既能写文案、想点子,又能陪你聊天、答疑解惑。</span>*/}
+                  </div>
                 </div>
-                {/*<div>*/}
-                {/*  <TemplateList*/}
-                {/*    templates={defaultTemplates}*/}
-                {/*    onTemplateSelect={handleTemplateSelect}*/}
-                {/*    isDarkMode={isDarkMode}*/}
-                {/*  />*/}
-                {/*</div>*/}
               </>
             )}
             <div
@@ -629,21 +568,55 @@ const SidePanel = () => {
               <MessageList messages={messages} isDarkMode={isDarkMode} />
               <div ref={messagesEndRef} />
             </div>
-            {messages.length > 0 && (
-              <div
-                className={`border-t ${isDarkMode ? 'border-sky-900' : 'border-sky-100'} p-2 shadow-sm backdrop-blur-sm`}>
-                <ChatInput
-                  onSendMessage={handleSendMessage}
-                  onStopTask={handleStopTask}
-                  disabled={!inputEnabled || isHistoricalSession}
-                  showStopButton={showStopButton}
-                  setContent={setter => {
-                    setInputTextRef.current = setter;
-                  }}
-                  isDarkMode={isDarkMode}
-                />
+            <header className="header relative">
+              <div className="header-logo"></div>
+              <div className="header-icons">
+                {!showHistory && (
+                  <>
+                    <button
+                      type="button"
+                      onClick={handleNewChat}
+                      onKeyDown={e => e.key === 'Enter' && handleNewChat()}
+                      className={`header-icon ${isDarkMode ? 'text-sky-400 hover:text-sky-300' : 'text-sky-400 hover:text-sky-500'} cursor-pointer`}
+                      aria-label="New Chat"
+                      tabIndex={0}>
+                      <PiPlusBold size={20} />
+                    </button>
+                    <button
+                      type="button"
+                      onClick={handleLoadHistory}
+                      onKeyDown={e => e.key === 'Enter' && handleLoadHistory()}
+                      className={`header-icon ${isDarkMode ? 'text-sky-400 hover:text-sky-300' : 'text-sky-400 hover:text-sky-500'} cursor-pointer`}
+                      aria-label="Load History"
+                      tabIndex={0}>
+                      <GrHistory size={20} />
+                    </button>
+                  </>
+                )}
+                <button
+                  type="button"
+                  onClick={() => chrome.runtime.openOptionsPage()}
+                  onKeyDown={e => e.key === 'Enter' && chrome.runtime.openOptionsPage()}
+                  className={`header-icon ${isDarkMode ? 'text-sky-400 hover:text-sky-300' : 'text-sky-400 hover:text-sky-500'} cursor-pointer`}
+                  aria-label="Settings"
+                  tabIndex={0}>
+                  <FiSettings size={20} />
+                </button>
               </div>
-            )}
+            </header>
+            <div
+              className={`border-t ${isDarkMode ? 'border-sky-900' : 'border-sky-100'} p-2 shadow-sm backdrop-blur-sm`}>
+              <ChatInput
+                onSendMessage={handleSendMessage}
+                onStopTask={handleStopTask}
+                disabled={!inputEnabled || isHistoricalSession}
+                showStopButton={showStopButton}
+                setContent={setter => {
+                  setInputTextRef.current = setter;
+                }}
+                isDarkMode={isDarkMode}
+              />
+            </div>
           </>
         )}
       </div>

+ 15 - 3
pages/side-panel/src/components/ChatHistoryList.tsx

@@ -1,4 +1,3 @@
-/* eslint-disable react/prop-types */
 import { FaTrash } from 'react-icons/fa';
 
 interface ChatSession {
@@ -11,19 +10,22 @@ interface ChatHistoryListProps {
   sessions: ChatSession[];
   onSessionSelect: (sessionId: string) => void;
   onSessionDelete: (sessionId: string) => void;
+  handleBackToChat: () => void;
   visible: boolean;
   isDarkMode?: boolean;
 }
 
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-expect-error
 const ChatHistoryList: React.FC<ChatHistoryListProps> = ({
   sessions,
   onSessionSelect,
   onSessionDelete,
+  handleBackToChat,
   visible,
   isDarkMode = false,
 }) => {
   if (!visible) return null;
-
   const formatDate = (timestamp: number) => {
     const date = new Date(timestamp);
     return date.toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' });
@@ -31,7 +33,17 @@ const ChatHistoryList: React.FC<ChatHistoryListProps> = ({
 
   return (
     <div className="h-full overflow-y-auto p-4">
-      <h2 className={`mb-4 text-lg font-semibold ${isDarkMode ? 'text-gray-200' : 'text-gray-800'}`}>历史对话</h2>
+      <h2
+        className={`mb-4 flex  justify-between text-lg font-semibold ${isDarkMode ? 'text-gray-200' : 'text-gray-800'}`}>
+        <span>历史对话</span>
+        <button
+          type="button"
+          onClick={handleBackToChat}
+          className={`${isDarkMode ? 'text-sky-400 hover:text-sky-300' : 'text-sky-400 hover:text-sky-500'} cursor-pointer text-xs font-normal`}
+          aria-label="返回聊天">
+          返回
+        </button>
+      </h2>
       {sessions.length === 0 ? (
         <div
           className={`rounded-lg ${isDarkMode ? 'bg-slate-800 text-gray-400' : 'bg-white/30 text-gray-500'} p-4 text-center backdrop-blur-sm`}>

+ 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
             )}