Skip to content

Commit

Permalink
feat: add search toggle component and integrate with chat interface
Browse files Browse the repository at this point in the history
- Add SearchToggle component with globe icon
- Update chat route to handle enableSearchGrounding
- Fix model selection to use gpt-4o instead of gpt-4o-mini
- Update settings to include enableSearchGrounding flag

Co-Authored-By: ben <ben@prologe.io>
  • Loading branch information
1 parent 42ae342 commit 56d2340
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/plugin/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class FileOrganizerSettings {
enableFabric = false;
useFolderEmbeddings = false;
useVaultTitles = true;
enableSearchGrounding = false;
showLocalLLMInChat = false;
customFolderInstructions = "";
selectedModel: "gpt-4o" | "llama3.2" = "gpt-4o";
Expand Down
12 changes: 8 additions & 4 deletions packages/plugin/views/assistant/ai-chat/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ModelSelector } from "./model-selector";
import { ModelType } from "./types";
import { AudioRecorder } from "./audio-recorder";
import { logger } from "../../../services/logger";
import { SearchToggle } from "./components/search-toggle";
import { SubmitButton } from "./submit-button";
import { getUniqueReferences, useContextItems } from "./use-context-items";
import { ContextItems } from "./components/context-items";
Expand Down Expand Up @@ -499,10 +500,13 @@ export const ChatComponent: React.FC<ChatComponentProps> = ({
unifiedContext={contextString}
maxContextSize={maxContextSize}
/>
<ModelSelector
selectedModel={selectedModel}
onModelSelect={setSelectedModel}
/>
<div className="flex items-center space-x-2">
<SearchToggle />
<ModelSelector
selectedModel={selectedModel}
onModelSelect={setSelectedModel}
/>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { usePlugin } from '../../provider';

export function SearchToggle() {
const plugin = usePlugin();
const isEnabled = plugin.settings.enableSearchGrounding;

const handleToggle = async () => {
plugin.settings.enableSearchGrounding = !plugin.settings.enableSearchGrounding;
await plugin.saveSettings();
};

return (
<button
onClick={handleToggle}
className={`flex items-center space-x-1 text-sm px-2 py-1 rounded transition-colors ${
isEnabled
? "bg-blue-600 text-white hover:bg-blue-700"
: "bg-[--background-primary-alt] text-[--text-muted] hover:text-[--text-normal] hover:bg-[--background-modifier-hover]"
}`}
title={isEnabled ? "Disable internet search" : "Enable internet search"}
>
<svg
className="w-4 h-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<circle cx="12" cy="12" r="10" />
<line x1="2" y1="12" x2="22" y2="12" />
<path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" />
</svg>
{isEnabled && <span>Search</span>}
</button>
);
}
2 changes: 1 addition & 1 deletion packages/web/app/api/(newai)/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function POST(req: NextRequest) {
chosenModelName = "gpt-4o";
}
} else {
chosenModelName = "gpt-4o-mini";
chosenModelName = "gpt-4o";
}
console.log("Chat using model:", chosenModelName);
const model = getModel(chosenModelName);
Expand Down

0 comments on commit 56d2340

Please sign in to comment.