add system prompt
This commit is contained in:
parent
898cb6da7b
commit
080865615c
18
main.ts
18
main.ts
|
|
@ -9,10 +9,12 @@ import 'src/css/styles.css'; // Путь к твоему новому CSS фай
|
|||
|
||||
interface LLMAgentSettings {
|
||||
apiBaseUrl: string;
|
||||
systemPrompt: string;
|
||||
}
|
||||
|
||||
const DEFAULT_SETTINGS: LLMAgentSettings = {
|
||||
apiBaseUrl: 'http://localhost:5000/api'
|
||||
apiBaseUrl: 'http://localhost:5000/api',
|
||||
systemPrompt: 'Ты полезный ИИ ассистент.',
|
||||
};
|
||||
|
||||
// ----------------------------------------------- Main Plugin Class ---------------------------------------------------------------
|
||||
|
|
@ -138,5 +140,19 @@ class SampleSettingTab extends PluginSettingTab {
|
|||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
// Новое поле для системного промпта
|
||||
new Setting(containerEl)
|
||||
.setName('Системный промпт')
|
||||
.setDesc('Этот промпт будет отправляться LLM перед каждым диалогом.')
|
||||
.addTextArea((text) =>
|
||||
text
|
||||
.setPlaceholder('Ты полезный ИИ ассистент.')
|
||||
.setValue(this.plugin.settings.systemPrompt)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.systemPrompt = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ export class ChatPanel {
|
|||
<div class="chat-message-icon">
|
||||
${
|
||||
msg.role === 'user'
|
||||
? `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucude-user"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>`
|
||||
? `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>`
|
||||
: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-bot"><path d="M12 8V4H8"></path><rect width="16" height="12" x="4" y="8" rx="2"></rect><path d="M2 14h2"></path><path d="M20 14h2"></path><path d="M15 13v2"></path><path d="M9 13v2"></path></svg>`
|
||||
}
|
||||
</div>
|
||||
|
|
@ -144,20 +144,12 @@ export class ChatPanel {
|
|||
)
|
||||
.join('');
|
||||
|
||||
const chatPanelContainer = this.container.querySelector('.llm-agent-chat-panel') as HTMLElement;
|
||||
|
||||
// Прокручиваем к последнему сообщению
|
||||
// Обычный `historyContainer.scrollTop = historyContainer.scrollHeight;` не работает
|
||||
if (this.chatHistory.length > 0) {
|
||||
setTimeout(() => {
|
||||
if (chatPanelContainer.scrollHeight > chatPanelContainer.clientHeight) {
|
||||
// Используем scrollTop для более точного контроля
|
||||
// Прокручиваем на всю высоту скролла
|
||||
chatPanelContainer.scrollTop = chatPanelContainer.scrollHeight;
|
||||
// Затем отнимаем немного, чтобы создать отступ снизу
|
||||
// 20px - это пример, можно настроить это значение
|
||||
const offset = 20; // Величина отступа от низа
|
||||
chatPanelContainer.scrollTop -= offset;
|
||||
const lastMessage = historyContainer.lastElementChild as HTMLElement;
|
||||
if (lastMessage) {
|
||||
lastMessage.scrollIntoView({ behavior: 'smooth', block: 'end' });
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,8 @@ export class ChatView extends ItemView {
|
|||
body: JSON.stringify({
|
||||
message: message,
|
||||
graph_id: this.selectedGraphId,
|
||||
parent_node_id: this.currentNode
|
||||
parent_node_id: this.currentNode,
|
||||
system_prompt: this.plugin.settings.systemPrompt
|
||||
})
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export class GraphView extends ItemView {
|
|||
historyPanel: HistoryPanel | null;
|
||||
historyContainer: HTMLDivElement;
|
||||
graphContainer: HTMLDivElement;
|
||||
reactRoot: ReactDOM.Root | null; // <-- ИСПРАВЛЕНО: Указываем тип для reactRoot
|
||||
reactRoot: ReactDOM.Root | null;
|
||||
|
||||
constructor(leaf: WorkspaceLeaf, plugin: LLMAgentPlugin) {
|
||||
super(leaf);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user