mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
Add index button to plus mode, disable unnecessary calls (#873)
This commit is contained in:
parent
2b1aa238b7
commit
68b8ad745b
3 changed files with 24 additions and 6 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { useAIState } from "@/aiState";
|
||||
import { ChainType } from "@/chainFactory";
|
||||
import { updateChatMemory } from "@/chatUtils";
|
||||
import ChatInput from "@/components/chat-components/ChatInput";
|
||||
import ChatMessages from "@/components/chat-components/ChatMessages";
|
||||
|
|
@ -109,7 +110,8 @@ const Chat: React.FC<ChatProps> = ({
|
|||
app.vault,
|
||||
contextNotes,
|
||||
includeActiveNote,
|
||||
activeNote
|
||||
activeNote,
|
||||
currentChain
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -167,8 +169,11 @@ const Chat: React.FC<ChatProps> = ({
|
|||
app.workspace.getActiveFile() as TFile | undefined
|
||||
);
|
||||
|
||||
// Extract Mentions (such as URLs) from original input message only
|
||||
const urlContextAddition = await mention.processUrls(inputMessage || "");
|
||||
// Extract Mentions (such as URLs) from original input message only if using Copilot Plus chain
|
||||
const urlContextAddition =
|
||||
currentChain === ChainType.COPILOT_PLUS_CHAIN
|
||||
? await mention.processUrls(inputMessage || "")
|
||||
: "";
|
||||
|
||||
// Add context notes
|
||||
const noteContextAddition = await processContextNotes(customPromptProcessor, fileParserManager);
|
||||
|
|
|
|||
|
|
@ -179,7 +179,8 @@ const ChatControls: React.FC<ChatControlsProps> = ({
|
|||
<TooltipActionButton onClick={onSaveAsNote} Icon={<Download className="icon-scaler" />}>
|
||||
Save as Note
|
||||
</TooltipActionButton>
|
||||
{selectedChain === "vault_qa" && (
|
||||
{(selectedChain === ChainType.VAULT_QA_CHAIN ||
|
||||
selectedChain === ChainType.COPILOT_PLUS_CHAIN) && (
|
||||
<TooltipActionButton
|
||||
onClick={onRefreshVaultContext}
|
||||
Icon={<Puzzle className="icon-scaler" />}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ChainType } from "@/chainFactory";
|
||||
import { CustomPromptProcessor } from "@/customPromptProcessor";
|
||||
import { FileParserManager } from "@/tools/FileParserManager";
|
||||
import { TFile, Vault } from "obsidian";
|
||||
|
|
@ -48,20 +49,31 @@ export class ContextProcessor {
|
|||
vault: Vault,
|
||||
contextNotes: TFile[],
|
||||
includeActiveNote: boolean,
|
||||
activeNote: TFile | null
|
||||
activeNote: TFile | null,
|
||||
currentChain: ChainType
|
||||
): Promise<string> {
|
||||
const processedVars = await customPromptProcessor.getProcessedVariables();
|
||||
let additionalContext = "";
|
||||
|
||||
const processNote = async (note: TFile) => {
|
||||
try {
|
||||
if (currentChain !== ChainType.COPILOT_PLUS_CHAIN && note.extension !== "md") {
|
||||
if (!fileParserManager.supportsExtension(note.extension)) {
|
||||
console.warn(`Unsupported file type: ${note.extension}`);
|
||||
} else {
|
||||
console.warn(`File type ${note.extension} only supported in Copilot Plus mode`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fileParserManager.supportsExtension(note.extension)) {
|
||||
console.warn(`Unsupported file type: ${note.extension}`);
|
||||
return;
|
||||
}
|
||||
|
||||
let content = await fileParserManager.parseFile(note, vault);
|
||||
|
||||
if (note.extension === "md") {
|
||||
if (note.extension === "md" && currentChain === ChainType.COPILOT_PLUS_CHAIN) {
|
||||
content = await this.processEmbeddedPDFs(content, vault, fileParserManager);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue