Remove image prompt generation functionality
This commit is contained in:
44
src/App.tsx
44
src/App.tsx
@@ -6,8 +6,6 @@ import { getCurrentWebview } from "@tauri-apps/api/webview";
|
|||||||
import { markdownToHTML } from "./markdown/markdown";
|
import { markdownToHTML } from "./markdown/markdown";
|
||||||
import "./markdown/markdown-render.css";
|
import "./markdown/markdown-render.css";
|
||||||
|
|
||||||
const IMAGE_PROMPT_PLACEHOLDER = "Generated image prompt will appear here.";
|
|
||||||
|
|
||||||
type FileEntry = {
|
type FileEntry = {
|
||||||
kind: "file";
|
kind: "file";
|
||||||
path: string;
|
path: string;
|
||||||
@@ -82,7 +80,6 @@ export default function App() {
|
|||||||
const [markdownPreview, setMarkdownPreview] = useState(false);
|
const [markdownPreview, setMarkdownPreview] = useState(false);
|
||||||
const [title, setTitle] = useState("");
|
const [title, setTitle] = useState("");
|
||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState("");
|
||||||
const [imagePrompt, setImagePrompt] = useState(IMAGE_PROMPT_PLACEHOLDER);
|
|
||||||
const [ollamaHost, setOllamaHost] = useState("http://localhost:11434");
|
const [ollamaHost, setOllamaHost] = useState("http://localhost:11434");
|
||||||
const [ollamaModel, setOllamaModel] = useState("Select model...");
|
const [ollamaModel, setOllamaModel] = useState("Select model...");
|
||||||
const [searxUrl, setSearxUrl] = useState("http://localhost:8888");
|
const [searxUrl, setSearxUrl] = useState("http://localhost:8888");
|
||||||
@@ -368,37 +365,6 @@ export default function App() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onGenerateImagePrompt = async () => {
|
|
||||||
if (!ollamaModel || ollamaModel === "Select model...") {
|
|
||||||
window.alert("Please select a model first.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const ideaText = [title ? `Title: ${title}` : "", description ? `Description: ${description}` : "", concept || notes]
|
|
||||||
.filter(Boolean)
|
|
||||||
.join("\n\n");
|
|
||||||
if (!ideaText.trim()) {
|
|
||||||
window.alert("Add concept text or notes first.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setBusy((prev) => ({ ...prev, imagePrompt: true }));
|
|
||||||
setStatus("Generating image prompt...");
|
|
||||||
try {
|
|
||||||
const promptText = await runBackend<string>("generate_image_prompt", {
|
|
||||||
idea_text: ideaText,
|
|
||||||
ollama_host: ollamaHost,
|
|
||||||
model: ollamaModel,
|
|
||||||
});
|
|
||||||
setImagePrompt(promptText);
|
|
||||||
setStatus("Image prompt ready");
|
|
||||||
} catch (err) {
|
|
||||||
setStatus("Image prompt failed");
|
|
||||||
console.error(err);
|
|
||||||
window.alert("Image prompt failed. Check console for details.");
|
|
||||||
} finally {
|
|
||||||
setBusy((prev) => ({ ...prev, imagePrompt: false }));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const onPriorArt = async () => {
|
const onPriorArt = async () => {
|
||||||
if (!ollamaModel || ollamaModel === "Select model...") {
|
if (!ollamaModel || ollamaModel === "Select model...") {
|
||||||
window.alert("Please select a model first.");
|
window.alert("Please select a model first.");
|
||||||
@@ -476,7 +442,6 @@ export default function App() {
|
|||||||
setConcept("");
|
setConcept("");
|
||||||
setTitle("");
|
setTitle("");
|
||||||
setDescription("");
|
setDescription("");
|
||||||
setImagePrompt(IMAGE_PROMPT_PLACEHOLDER);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSaveSession = async () => {
|
const onSaveSession = async () => {
|
||||||
@@ -501,7 +466,6 @@ export default function App() {
|
|||||||
websites: websites.map((w) => ({ url: w.url })),
|
websites: websites.map((w) => ({ url: w.url })),
|
||||||
rephrase_variants: rephraseVariants,
|
rephrase_variants: rephraseVariants,
|
||||||
rephrase_selected_key: rephraseSelected,
|
rephrase_selected_key: rephraseSelected,
|
||||||
image_prompt: imagePrompt === IMAGE_PROMPT_PLACEHOLDER ? "" : imagePrompt,
|
|
||||||
},
|
},
|
||||||
allow_overwrite: true,
|
allow_overwrite: true,
|
||||||
});
|
});
|
||||||
@@ -556,7 +520,6 @@ export default function App() {
|
|||||||
);
|
);
|
||||||
setRephraseVariants(data.rephrase_variants || []);
|
setRephraseVariants(data.rephrase_variants || []);
|
||||||
setRephraseSelected(data.rephrase_selected_key || null);
|
setRephraseSelected(data.rephrase_selected_key || null);
|
||||||
setImagePrompt(data.image_prompt || IMAGE_PROMPT_PLACEHOLDER);
|
|
||||||
setSessionModalOpen(false);
|
setSessionModalOpen(false);
|
||||||
setStatus("Session loaded");
|
setStatus("Session loaded");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -737,14 +700,7 @@ export default function App() {
|
|||||||
<button onClick={() => setMarkdownPreview((value) => !value)}>
|
<button onClick={() => setMarkdownPreview((value) => !value)}>
|
||||||
{markdownPreview ? "Edit Markdown" : "Preview Markdown"}
|
{markdownPreview ? "Edit Markdown" : "Preview Markdown"}
|
||||||
</button>
|
</button>
|
||||||
<button onClick={onGenerateImagePrompt} disabled={busy.imagePrompt}>Generate image prompt</button>
|
|
||||||
</div>
|
</div>
|
||||||
<textarea
|
|
||||||
className="image-prompt"
|
|
||||||
value={imagePrompt}
|
|
||||||
onChange={(e) => setImagePrompt(e.target.value)}
|
|
||||||
placeholder={IMAGE_PROMPT_PLACEHOLDER}
|
|
||||||
/>
|
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user