generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add search toggle component and integrate with chat interface
- 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
Showing
4 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/plugin/views/assistant/ai-chat/components/search-toggle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters