mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Move imageModel to VFS
This commit is contained in:
7 files changed
+11
-22
No files matched your search
@@ -172,7 +172,7 @@ export const AIMessageItem = memo(({
|
||||
case 'generate_image':
|
||||
return {
|
||||
icon: Image,
|
||||
title: args.prompt ? `Generated: ${args.prompt.slice(0, 40)}${args.prompt.length > 40 ? '...' : ''}` : 'Generated Image'
|
||||
title: args.prompt ? `Generated: ${args.prompt}` : 'Generated Image'
|
||||
};
|
||||
default:
|
||||
return {
|
||||
|
||||
@@ -50,7 +50,6 @@ const AppConfigSchema = z.object({
|
||||
sentryDsn: z.string(),
|
||||
sentryEnabled: z.boolean(),
|
||||
systemPrompt: z.string(),
|
||||
imageModel: z.string(),
|
||||
}) satisfies z.ZodType<AppConfig>;
|
||||
|
||||
export function AppProvider(props: AppProviderProps) {
|
||||
|
||||
@@ -186,9 +186,9 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
}
|
||||
|
||||
// Add generate_image tool if imageModel is configured
|
||||
if (config.imageModel) {
|
||||
if (settings.imageModel) {
|
||||
try {
|
||||
const { provider, model } = parseProviderModel(config.imageModel, settings.providers);
|
||||
const { provider, model } = parseProviderModel(settings.imageModel, settings.providers);
|
||||
tools.generate_image = new GenerateImageTool(
|
||||
fs,
|
||||
tmpPath,
|
||||
@@ -203,7 +203,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
}
|
||||
|
||||
return tools;
|
||||
}, [fs, git, cwd, user, projectId, projectsPath, tmpPath, pluginsPath, config.corsProxy, config.imageModel, settings.providers, handleFileChanged]);
|
||||
}, [fs, git, cwd, user, projectId, projectsPath, tmpPath, pluginsPath, config.corsProxy, settings.imageModel, settings.providers, handleFileChanged]);
|
||||
|
||||
// MCP tools wrapped for execution
|
||||
const mcpToolWrappers = useMemo(() => createMCPTools(mcpClients), [mcpClients]);
|
||||
|
||||
@@ -22,6 +22,7 @@ export interface MCPServers {
|
||||
export interface AISettings {
|
||||
providers: AIProvider[];
|
||||
recentlyUsedModels: string[];
|
||||
imageModel?: string;
|
||||
mcpServers?: MCPServers;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,6 @@ export interface AppConfig {
|
||||
sentryEnabled: boolean;
|
||||
/** System prompt EJS template */
|
||||
systemPrompt?: string;
|
||||
/** Image generation model */
|
||||
imageModel?: string;
|
||||
}
|
||||
|
||||
export interface AppContextType {
|
||||
|
||||
@@ -53,6 +53,7 @@ const mcpServerSchema: z.ZodType<MCPServer> = z.object({
|
||||
const aiSettingsSchema = z.object({
|
||||
providers: filteredArray(aiProviderSchema),
|
||||
recentlyUsedModels: filteredArray(providerModelSchema),
|
||||
imageModel: providerModelSchema.optional(),
|
||||
mcpServers: z.record(z.string(), mcpServerSchema).optional(),
|
||||
});
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ function generateIdFromName(name: string): string {
|
||||
|
||||
export function AISettings() {
|
||||
const { t } = useTranslation();
|
||||
const { settings, setProvider, removeProvider, setProviders } = useAISettings();
|
||||
const { settings, updateSettings, setProvider, removeProvider, setProviders } = useAISettings();
|
||||
const isMobile = useIsMobile();
|
||||
const navigate = useNavigate();
|
||||
const { user } = useCurrentUser();
|
||||
@@ -682,25 +682,15 @@ export function AISettings() {
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<ModelInput
|
||||
value={config.imageModel || ''}
|
||||
onChange={(value) => {
|
||||
updateConfig((current) => ({
|
||||
...current,
|
||||
imageModel: value || undefined,
|
||||
}));
|
||||
}}
|
||||
value={settings.imageModel || ''}
|
||||
onChange={(value) => updateSettings({ imageModel: value || undefined })}
|
||||
className="flex-1"
|
||||
/>
|
||||
{config.imageModel && (
|
||||
{settings.imageModel && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
updateConfig((current) => {
|
||||
const { imageModel, ...rest } = current;
|
||||
return rest;
|
||||
});
|
||||
}}
|
||||
onClick={() => updateSettings({ imageModel: undefined })}
|
||||
className="h-10 px-3"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
|
||||
Reference in new issue
Block a user