forked from stackblitz/bolt.new
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(code-template): code template with AI tool Calling Feature added…
… with optin feature
- Loading branch information
1 parent
b16a457
commit 2776200
Showing
12 changed files
with
244 additions
and
51 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
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,32 @@ | ||
import { IconButton } from '../ui/IconButton'; | ||
import { Popover, PopoverContent, PopoverTrigger } from '../ui/Popover'; | ||
import { ToggleSwitch } from '../ui/ToggleSwitch'; | ||
import type { IToolsConfig } from '~/utils/types'; | ||
|
||
interface ToolManagerProps { | ||
toolConfig: IToolsConfig; | ||
onConfigChange?: (val: IToolsConfig) => void; | ||
} | ||
|
||
export function ToolManager({ toolConfig, onConfigChange }: ToolManagerProps) { | ||
return ( | ||
<> | ||
{toolConfig && ( | ||
<div className="grid gap-4 text-sm"> | ||
<div className="flex items-center gap-2"> | ||
<label className="text-sm text-bolt-elements-textSecondary">Tool Calling</label> | ||
<ToggleSwitch | ||
checked={toolConfig.enabled} | ||
onCheckedChange={(e) => { | ||
onConfigChange?.({ | ||
enabled: e, | ||
config: toolConfig.config, | ||
}); | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
)} | ||
</> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as React from 'react'; | ||
import * as PopoverPrimitive from '@radix-ui/react-popover'; | ||
|
||
const Popover = PopoverPrimitive.Root; | ||
const PopoverTrigger = PopoverPrimitive.Trigger; | ||
|
||
const PopoverContent = React.forwardRef< | ||
React.ElementRef<typeof PopoverPrimitive.Content>, | ||
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> | ||
>(({ className, align = 'center', sideOffset = 4, ...props }, ref) => ( | ||
<PopoverPrimitive.Content | ||
ref={ref} | ||
align={align} | ||
sideOffset={sideOffset} | ||
className={[ | ||
'z-50', | ||
'w-auto', | ||
'rounded-md', | ||
'border border-bolt-elements-borderColor', | ||
'bg-bolt-elements-background-depth-2', // Using depth-2 for better contrast | ||
'p-4', | ||
'text-bolt-elements-textPrimary', | ||
'shadow-md', | ||
'outline-none', | ||
// Focus and ring states could use your theme colors | ||
// 'focus-visible:(outline-none ring-2 ring-bolt-elements-item-contentAccent ring-offset-2 ring-offset-bolt-elements-background-depth-1)', | ||
// Transitions | ||
'transition-all duration-800', | ||
'transform-gpu', | ||
// State animations | ||
'data-[state=open]:(opacity-100 scale-100)', | ||
'data-[state=closed]:(opacity-0 scale-95)', | ||
// Position animations | ||
'data-[side=bottom]:translate-y-2', | ||
'data-[side=left]:translate-x-2', | ||
'data-[side=right]:-translate-x-2', | ||
'data-[side=top]:-translate-y-2', | ||
className, | ||
] | ||
.filter(Boolean) | ||
.join(' ')} | ||
{...props} | ||
/> | ||
)); | ||
PopoverContent.displayName = PopoverPrimitive.Content.displayName; | ||
|
||
export { Popover, PopoverTrigger, PopoverContent }; |
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,55 @@ | ||
import * as React from 'react'; | ||
import * as SwitchPrimitives from '@radix-ui/react-switch'; | ||
|
||
const ToggleSwitch = React.forwardRef< | ||
React.ElementRef<typeof SwitchPrimitives.Root>, | ||
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<SwitchPrimitives.Root | ||
className={[ | ||
'peer', | ||
'inline-flex', | ||
'h-4', | ||
'w-9', | ||
'shrink-0', | ||
'cursor-pointer', | ||
'items-center', | ||
'rounded-full', | ||
'border-2', | ||
'border-transparent', | ||
'transition-colors duration-200 bolt-ease-cubic-bezier', | ||
// Focus styles | ||
'focus-visible:(outline-none ring-1)', | ||
// Disabled styles | ||
'disabled:(cursor-not-allowed opacity-50)', | ||
// State styles | ||
'data-[state=checked]:bg-bolt-elements-item-contentAccent', | ||
'data-[state=unchecked]:bg-bolt-elements-button-secondary-background', | ||
'hover:data-[state=unchecked]:bg-bolt-elements-button-secondary-backgroundHover', | ||
className, | ||
] | ||
.filter(Boolean) | ||
.join(' ')} | ||
{...props} | ||
ref={ref} | ||
> | ||
<SwitchPrimitives.Thumb | ||
className={[ | ||
'pointer-events-none', | ||
'block', | ||
'h-3', | ||
'w-3', | ||
'rounded-full', | ||
'bg-bolt-elements-textPrimary', | ||
'shadow-lg', | ||
'ring-0', | ||
'transition-transform duration-200 bolt-ease-cubic-bezier', | ||
'data-[state=checked]:translate-x-5', | ||
'data-[state=unchecked]:translate-x-0', | ||
].join(' ')} | ||
/> | ||
</SwitchPrimitives.Root> | ||
)); | ||
ToggleSwitch.displayName = SwitchPrimitives.Root.displayName; | ||
|
||
export { ToggleSwitch }; |
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
Oops, something went wrong.