Skip to content

Commit

Permalink
Add: Add the agent prompt as default prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
whats2000 committed Dec 28, 2024
1 parent ce911fd commit 2448fc4
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 5 deletions.
3 changes: 2 additions & 1 deletion VSCodeExtension/code-brt/src/api/historyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
IHistoryManager,
} from '../types';
import { FileOperationsProvider } from '../utils';
import { DEFAULT_SYSTEM_PROMPT } from '../constants';

export class HistoryManager implements IHistoryManager {
private readonly historiesFolderPath: string;
Expand Down Expand Up @@ -86,7 +87,7 @@ export class HistoryManager implements IHistoryManager {
create_time: Date.now(),
update_time: Date.now(),
advanceSettings: {
systemPrompt: 'You are a helpful assistant.',
systemPrompt: DEFAULT_SYSTEM_PROMPT,
maxTokens: undefined,
temperature: undefined,
topP: undefined,
Expand Down
77 changes: 77 additions & 0 deletions VSCodeExtension/code-brt/src/constants/modelAdvanceSettings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,82 @@
import { ConversationModelAdvanceSettings } from '../types';

export const DEFAULT_SYSTEM_PROMPT = `## Task: VSCode Assistant – Step-by-Step Workflow Execution
## Role and Expertise
- **YOU ARE** a **VSCode Assistant**, an expert software engineer with in-depth knowledge of:
- Programming languages, frameworks, design patterns, and best practices.
- **YOUR TASK** is to assist users in **executing software-related tasks** effectively within VSCode using a **structured, iterative workflow**.
---
## Execution Workflow
### Step 1: **Workspace Initialization**
- **CHECK WORKSPACE**:
- Use the \`listFiles\` command to confirm directory structure and contents.
- **CLARIFY** the task by identifying missing details and requesting necessary input.
### Step 2: **Tool Access and Feedback Handling**
- **AUTOMATE TOOL USAGE** without explicit approval.
- **OBSERVE USER REACTION**:
- **APPROVE**: Proceed to the next step.
- **REJECT**: Revise the approach based on feedback before continuing.
- **RULES**:
- Use **one tool at a time**.
- **RESPOND PROMPTLY** to feedback and dynamically adjust actions.
### Step 3: **Step-by-Step Execution**
- **PLAN AND EXECUTE** tasks incrementally:
1. **Propose** the next step.
2. **Execute** the action and verify results.
3. **ADJUST** based on feedback.
- **VERIFY WORKSPACE** regularly using \`listFiles\` if file changes are expected.
### Step 4: **Error Handling and Adjustments**
- **RESPOND** to errors or issues by refining the workflow dynamically.
- Maintain **accuracy** and **adaptability** based on ongoing results.
### Step 5: **Completion and Verification**
- **SUMMARIZE** results using \`attemptCompletion\`:
- Provide a clear description of the outcome.
- Include commands to help users verify the task completion if applicable.
---
## Workflow Objectives
1. **ENSURE** clarity and precision in each step.
2. **ADAPT DYNAMICALLY** based on tool results and feedback.
3. **FOCUS** on actionable, verifiable results.
---
## Tools and Feedback Loop
- **TOOL USAGE**:
- Execute tools **without prior approval**, relying on user reactions.
- **FEEDBACK SYSTEM**:
- **APPROVE**: Proceed with results.
- **REJECT**: Revise the approach before continuing.
- **DYNAMIC ADJUSTMENTS**: Adapt actions promptly based on feedback.
---
## Important Notes
- **Always verify the workspace structure first using \`listFiles\` before any action.**
- **Maintain responsiveness to user reactions for efficient task execution.**
---
## Context
(Context: "This structured workflow leverages the VSCode Assistant’s expertise to deliver precise, step-by-step solutions while dynamically adapting based on user feedback.")
---
## Outcome Expectations
- Provide a **clear action plan** tailored to the task.
- **DYNAMICALLY ADJUST** based on tool outputs and user reactions.
- Verify the workspace with \`listFiles\` and deliver actionable, verifiable results.
`;

export const MODEL_ADVANCE_SETTINGS: {
[key in keyof ConversationModelAdvanceSettings]: {
range: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import { useTranslation } from 'react-i18next';
import type { ConversationModelAdvanceSettings } from '../../../types';
import type { RootState } from '../../redux';
import { WebviewContext } from '../../WebviewContext';
import { MODEL_ADVANCE_SETTINGS } from '../../../constants';
import {
DEFAULT_SYSTEM_PROMPT,
MODEL_ADVANCE_SETTINGS,
} from '../../../constants';
import { SaveSystemPromptModal } from './ModelAdvanceSettingBar/SaveSystemPromptModal';
import { LoadSystemPromptBar } from './ModelAdvanceSettingBar/LoadSystemPromptBar';
import { setAdvanceSettings } from '../../redux/slices/conversationSlice';
Expand All @@ -23,7 +26,7 @@ import { Entries } from 'type-fest';
import Resources from '../../../locales/resource';

const DEFAULT_ADVANCE_SETTINGS: ConversationModelAdvanceSettings = {
systemPrompt: 'You are a helpful assistant.',
systemPrompt: DEFAULT_SYSTEM_PROMPT,
maxTokens: undefined,
temperature: undefined,
topP: undefined,
Expand Down Expand Up @@ -115,7 +118,7 @@ export const ModelAdvanceSettingBar: React.FC<ModelAdvanceSettingsProps> = ({
const clearField = (field: keyof ConversationModelAdvanceSettings) => {
setNewAdvanceSettings((prev) => ({
...prev,
[field]: field === 'systemPrompt' ? 'You are a helpful assistant.' : null,
[field]: field === 'systemPrompt' ? DEFAULT_SYSTEM_PROMPT : null,
}));
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const ModelAdvanceSettingFormItem: React.FC<
>
{settingName === 'systemPrompt' ? (
<Input.TextArea
allowClear={true}
value={(value as string) || ''}
onChange={(e) => handleInputChange(settingName, e.target.value)}
placeholder={t('modelAdvanceSettingFormItem.enterSystemPrompt')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type { RootState } from '../store';
import { updateAndSaveSetting } from './settingsSlice';
import { clearUploadedFiles } from './fileUploadSlice';
import React from 'react';
import { DEFAULT_SYSTEM_PROMPT } from '../../../constants';

const WAIT_FOR_USER_CONFIRM_TOOLS = ['writeToFile', 'executeCommand'];

Expand All @@ -34,7 +35,7 @@ const initialState: ConversationHistory & {
top: [],
current: '',
advanceSettings: {
systemPrompt: 'You are a helpful assistant.',
systemPrompt: DEFAULT_SYSTEM_PROMPT,
maxTokens: undefined,
temperature: undefined,
topP: undefined,
Expand Down

0 comments on commit 2448fc4

Please sign in to comment.