generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: ben <ben@prologe.io>
- Loading branch information
1 parent
be13d93
commit 369f621
Showing
8 changed files
with
107 additions
and
24 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
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
49 changes: 49 additions & 0 deletions
49
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,49 @@ | ||
import React, { useState } from 'react'; | ||
import { usePlugin } from '../../provider'; | ||
import { ModelType } from '../types'; | ||
|
||
interface SearchToggleProps { | ||
selectedModel: ModelType; | ||
} | ||
|
||
export function SearchToggle({ selectedModel }: SearchToggleProps) { | ||
const plugin = usePlugin(); | ||
const [isEnabled, setIsEnabled] = useState(plugin.settings.enableSearchGrounding); | ||
|
||
const handleToggle = async () => { | ||
plugin.settings.enableSearchGrounding = !plugin.settings.enableSearchGrounding; | ||
await plugin.saveSettings(); | ||
setIsEnabled(!isEnabled); | ||
}; | ||
|
||
if (selectedModel !== 'gpt-4o') { | ||
return null; | ||
} | ||
|
||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export type ModelType = "gpt-4o" | "llama3.2" | "gemini-2.0-flash-exp" | string; | ||
export type ModelType = "gpt-4o" | "llama3.2" | string; |
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