Skip to content

Commit

Permalink
Add index button to plus mode, disable unnecessary calls (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
logancyang authored Nov 27, 2024
1 parent 2b1aa23 commit 68b8ad7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/components/Chat.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -109,7 +110,8 @@ const Chat: React.FC<ChatProps> = ({
app.vault,
contextNotes,
includeActiveNote,
activeNote
activeNote,
currentChain
);
};

Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/components/chat-components/ChatControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" />}
Expand Down
16 changes: 14 additions & 2 deletions src/contextProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ChainType } from "@/chainFactory";
import { CustomPromptProcessor } from "@/customPromptProcessor";
import { FileParserManager } from "@/tools/FileParserManager";
import { TFile, Vault } from "obsidian";
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 68b8ad7

Please sign in to comment.