Skip to content

AutoShorts is a local-first desktop application for turning long-form video or audio recordings into high-impact, vertical short-form clip candidates (9:16 portrait) with AI-powered viral moment ranking.

Rust

feat: add support for Gemini, OpenAI, and OpenRouter LLM providers

JayWebtech518964fb7ff2
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index bb2d37c..63308ea 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -51,6 +51,9 @@ async fn environment_status(state: tauri::State<'_, AppState>) -> Result<Environ
has_deepgram_key: std::env::var("DEEPGRAM_API_KEY").is_ok(),
has_anthropic_key: std::env::var("ANTHROPIC_API_KEY").is_ok(),
has_deepseek_key: std::env::var("DEEPSEEK_API_KEY").is_ok(),
+ has_gemini_key: std::env::var("GEMINI_API_KEY").is_ok(),
+ has_openai_key: std::env::var("OPENAI_API_KEY").is_ok(),
+ has_openrouter_key: std::env::var("OPENROUTER_API_KEY").is_ok(),
llm_provider,
has_local_whisper_model,
has_ollama,
@@ -456,6 +459,30 @@ async fn generate_candidates(
.await
.map_err(to_command_error)?
}
+ "gemini" => {
+ let key = api_key
+ .or_else(|| std::env::var("GEMINI_API_KEY").ok())
+ .ok_or_else(|| "Set GEMINI_API_KEY or supply Gemini API Key to generate candidates.".to_string())?;
+ llm::detect_candidates_with_gemini(&normalized, &key)
+ .await
+ .map_err(to_command_error)?
+ }
+ "openai" => {
+ let key = api_key
+ .or_else(|| std::env::var("OPENAI_API_KEY").ok())
+ .ok_or_else(|| "Set OPENAI_API_KEY or supply OpenAI API Key to generate candidates.".to_string())?;
+ llm::detect_candidates_with_openai(&normalized, &key)
+ .await
+ .map_err(to_command_error)?
+ }
+ "openrouter" => {
+ let key = api_key
+ .or_else(|| std::env::var("OPENROUTER_API_KEY").ok())
+ .ok_or_else(|| "Set OPENROUTER_API_KEY or supply OpenRouter API Key to generate candidates.".to_string())?;
+ llm::detect_candidates_with_openrouter(&normalized, &key)
+ .await
+ .map_err(to_command_error)?
+ }
_ => {
let key = api_key
.or_else(|| std::env::var("DEEPSEEK_API_KEY").ok())
diff --git a/src-tauri/src/llm.rs b/src-tauri/src/llm.rs
index 27907a3..0a2cd5f 100644
--- a/src-tauri/src/llm.rs
+++ b/src-tauri/src/llm.rs
@@ -4,7 +4,6 @@ use serde_json::json;
use crate::models::{CandidateDraft, NormalizedTranscript, TranscriptSegment};
-
#[derive(Debug, Deserialize)]
struct AnthropicMessage {
content: Vec<AnthropicContent>,
@@ -86,6 +85,223 @@ Avoid rambling setup, context-dependent references, and pure filler. Return up t
parse_candidate_json(&text, min_duration)
}
+#[derive(Debug, Deserialize)]
+struct GeminiResponse {
+ candidates: Vec<GeminiCandidate>,
+}
+
+#[derive(Debug, Deserialize)]
+struct GeminiCandidate {
+ content: GeminiContent,
+}
+
+#[derive(Debug, Deserialize)]
+struct GeminiContent {
+ parts: Vec<GeminiPart>,
+}
+
+#[derive(Debug, Deserialize)]
+struct GeminiPart {
+ text: Option<String>,
+}
+
+pub async fn detect_candidates_with_gemini(
+ transcript: &NormalizedTranscript,
+ api_key: &str,
+) -> Result<Vec<CandidateDraft>> {
+ let segments = compact_segments(&transcript.segments);
+ let prompt = format!(
+ "You are identifying the most viral moments and strongest short-form clip candidates from a long-form transcript. \
+For each candidate, the clip must be self-contained, starting with an extremely engaging hook within the first 3 seconds (to capture immediate attention on social feeds), \
+30-90 seconds long, and cut at clean sentence/thought boundaries. Favor highly shareable content: concrete stories, \
+strong opinions, emotional turns, surprising or counter-intuitive claims, clear payoffs, and high-energy/dramatic peaks. \
+Avoid rambling setup, context-dependent references, and pure filler. Return up to 10 candidates as JSON matching this schema: \
+{{\"candidates\":[{{\"start\":0.0,\"end\":0.0,\"score\":0.0,\"hook\":\"...\",\"rationale\":\"...\"}}]}}\n\nTranscript:\n{segments}"
+ );
+
+ let model = std::env::var("GEMINI_MODEL").unwrap_or_else(|_| "gemini-2.5-flash".to_string());
+ let url = format!(
+ "https://generativelanguage.googleapis.com/v1beta/models/{}:generateContent?key={}",
+ model, api_key
+ );
+
+ let response = reqwest::Client::new()
+ .post(&url)
+ .json(&json!({
+ "contents": [
+ {
+ "parts": [
+ {
+ "text": prompt
+ }
+ ]
+ }
+ ],
+ "generationConfig": {
+ "responseMimeType": "application/json",
+ "temperature": 0.2
+ }
+ }))
+ .send()
+ .await
+ .context("calling Gemini")?;
+
+ if !response.status().is_success() {
+ let status = response.status();
+ let body = response.text().await.unwrap_or_default();
+ return Err(anyhow!("Gemini request failed ({status}): {body}"));
+ }
+
+ let res_body: GeminiResponse = response.json().await.context("parsing Gemini response")?;
+ let text = res_body
+ .candidates
+ .first()
+ .and_then(|c| c.content.parts.first())
+ .and_then(|p| p.text.clone())
+ .ok_or_else(|| anyhow!("Gemini response did not include content text"))?;
+
+ let min_duration = if transcript.duration < 60.0 {
+ (transcript.duration * 0.5).max(5.0)
+ } else {
+ 30.0
+ };
+ parse_candidate_json(&text, min_duration)
+}
+
+#[derive(Debug, Deserialize)]
+struct ChatCompletionResponse {
+ choices: Vec<ChatCompletionChoice>,
+}
+
+#[derive(Debug, Deserialize)]
+struct ChatCompletionChoice {
+ message: ChatCompletionMessage,
+}
+
+#[derive(Debug, Deserialize)]
+struct ChatCompletionMessage {
+ content: String,
+}
+
+pub async fn detect_candidates_with_openai(
+ transcript: &NormalizedTranscript,
+ api_key: &str,
+) -> Result<Vec<CandidateDraft>> {
+ let segments = compact_segments(&transcript.segments);
+ let prompt = format!(
+ "You are identifying the most viral moments and strongest short-form clip candidates from a long-form transcript. \
+For each candidate, the clip must be self-contained, starting with an extremely engaging hook within the first 3 seconds (to capture immediate attention on social feeds), \
+30-90 seconds long, and cut at clean sentence/thought boundaries. Favor highly shareable content: concrete stories, \
+strong opinions, emotional turns, surprising or counter-intuitive claims, clear payoffs, and high-energy/dramatic peaks. \
+Avoid rambling setup, context-dependent references, and pure filler. Return up to 10 candidates as JSON matching this schema: \
+{{\"candidates\":[{{\"start\":0.0,\"end\":0.0,\"score\":0.0,\"hook\":\"...\",\"rationale\":\"...\"}}]}}\n\nTranscript:\n{segments}"
+ );
+
+ let model = std::env::var("OPENAI_MODEL").unwrap_or_else(|_| "gpt-4o-mini".to_string());
+
+ let response = reqwest::Client::new()
+ .post("https://api.openai.com/v1/chat/completions")
+ .header("Authorization", format!("Bearer {api_key}"))
+ .json(&json!({
+ "model": model,
+ "messages": [
+ {
+ "role": "user",
+ "content": prompt,
+ }
+ ],
+ "temperature": 0.2,
+ "response_format": {
+ "type": "json_object"
+ }
+ }))
+ .send()
+ .await
+ .context("calling OpenAI")?;
+
+ if !response.status().is_success() {
+ let status = response.status();
+ let body = response.text().await.unwrap_or_default();
+ return Err(anyhow!("OpenAI request failed ({status}): {body}"));
+ }
+
+ let res_body: ChatCompletionResponse =
+ response.json().await.context("parsing OpenAI response")?;
+ let text = res_body
+ .choices
+ .first()
+ .map(|c| c.message.content.clone())
+ .ok_or_else(|| anyhow!("OpenAI response did not include choices content"))?;
+
+ let min_duration = if transcript.duration < 60.0 {
+ (transcript.duration * 0.5).max(5.0)
+ } else {
+ 30.0
+ };
+ parse_candidate_json(&text, min_duration)
+}
+
+pub async fn detect_candidates_with_openrouter(
+ transcript: &NormalizedTranscript,
+ api_key: &str,
+) -> Result<Vec<CandidateDraft>> {
+ let segments = compact_segments(&transcript.segments);
+ let prompt = format!(
+ "You are identifying the most viral moments and strongest short-form clip candidates from a long-form transcript. \
+For each candidate, the clip must be self-contained, starting with an extremely engaging hook within the first 3 seconds (to capture immediate attention on social feeds), \
+30-90 seconds long, and cut at clean sentence/thought boundaries. Favor highly shareable content: concrete stories, \
+strong opinions, emotional turns, surprising or counter-intuitive claims, clear payoffs, and high-energy/dramatic peaks. \
+Avoid rambling setup, context-dependent references, and pure filler. Return up to 10 candidates as JSON matching this schema: \
+{{\"candidates\":[{{\"start\":0.0,\"end\":0.0,\"score\":0.0,\"hook\":\"...\",\"rationale\":\"...\"}}]}}\n\nTranscript:\n{segments}"
+ );
+
+ let model =
+ std::env::var("OPENROUTER_MODEL").unwrap_or_else(|_| "google/gemini-2.5-flash".to_string());
+
+ let response = reqwest::Client::new()
+ .post("https://openrouter.ai/api/v1/chat/completions")
+ .header("Authorization", format!("Bearer {api_key}"))
+ .json(&json!({
+ "model": model,
+ "messages": [
+ {
+ "role": "user",
+ "content": prompt,
+ }
+ ],
+ "temperature": 0.2,
+ "response_format": {
+ "type": "json_object"
+ }
+ }))
+ .send()
+ .await
+ .context("calling OpenRouter")?;
+
+ if !response.status().is_success() {
+ let status = response.status();
+ let body = response.text().await.unwrap_or_default();
+ return Err(anyhow!("OpenRouter request failed ({status}): {body}"));
+ }
+
+ let res_body: ChatCompletionResponse = response
+ .json()
+ .await
+ .context("parsing OpenRouter response")?;
+ let text = res_body
+ .choices
+ .first()
+ .map(|c| c.message.content.clone())
+ .ok_or_else(|| anyhow!("OpenRouter response did not include choices content"))?;
+
+ let min_duration = if transcript.duration < 60.0 {
+ (transcript.duration * 0.5).max(5.0)
+ } else {
+ 30.0
+ };
+ parse_candidate_json(&text, min_duration)
+}
+
#[derive(Debug, Serialize)]
struct ClaudeMessage<'a> {
role: &'a str,
@@ -164,7 +380,7 @@ pub async fn detect_candidates_with_local_llm(
model_name: &str,
) -> Result<Vec<CandidateDraft>> {
let segments = compact_segments(&transcript.segments);
-
+
let system_instructions = "You are identifying the most viral moments and strongest short-form clip candidates from a long-form transcript. \
For each candidate, the clip must be self-contained, starting with an extremely engaging hook within the first 3 seconds (to capture immediate attention on social feeds), \
30-90 seconds long, and cut at clean sentence/thought boundaries. \
@@ -226,7 +442,10 @@ Ensure the 'start' and 'end' values correspond to actual timestamps in the trans
return Err(anyhow!("Local Ollama request failed ({status}): {body}"));
}
- let res_body: OllamaResponse = response.json().await.context("parsing local Ollama response")?;
+ let res_body: OllamaResponse = response
+ .json()
+ .await
+ .context("parsing local Ollama response")?;
let min_duration = if transcript.duration < 60.0 {
(transcript.duration * 0.5).max(5.0)
} else {
@@ -235,42 +454,6 @@ Ensure the 'start' and 'end' values correspond to actual timestamps in the trans
parse_candidate_json(&res_body.message.content, min_duration)
}
-pub fn demo_candidates(transcript: &NormalizedTranscript) -> Vec<CandidateDraft> {
- transcript
- .segments
- .chunks(8)
- .take(10)
- .enumerate()
- .filter_map(|(index, chunk)| {
- let first = chunk.first()?;
- let last = chunk.last()?;
- let duration = last.end - first.start;
- if duration < 12.0 {
- return None;
- }
-
- let end = if duration > 90.0 {
- first.start + 90.0
- } else {
- last.end
- };
-
- Some(CandidateDraft {
- start: first.start,
- end,
- score: (0.86 - (index as f64 * 0.035)).max(0.55),
- hook: first
- .text
- .split_whitespace()
- .take(12)
- .collect::<Vec<_>>()
- .join(" "),
- rationale: "Demo ranking generated without Claude. Use ANTHROPIC_API_KEY for production-quality moment detection.".to_string(),
- })
- })
- .collect()
-}
-
fn compact_segments(segments: &[TranscriptSegment]) -> String {
segments
.iter()
@@ -294,12 +477,19 @@ fn parse_candidate_json(text: &str, min_duration: f64) -> Result<Vec<CandidateDr
.trim();
let val: serde_json::Value = serde_json::from_str(trimmed).context("parsing candidate JSON")?;
-
+
let candidates_arr = if val.is_array() {
val.as_array().cloned()
} else if val.is_object() {
let mut found_arr = None;
- for key in &["candidates", "Candidates", "moments", "clips", "segments", "results"] {
+ for key in &[
+ "candidates",
+ "Candidates",
+ "moments",
+ "clips",
+ "segments",
+ "results",
+ ] {
if let Some(arr) = val.get(*key).and_then(|v| v.as_array()) {
found_arr = Some(arr.clone());
break;
@@ -390,12 +580,14 @@ fn parse_candidate_json(text: &str, min_duration: f64) -> Result<Vec<CandidateDr
score = 0.0;
}
- let hook = item.get("hook")
+ let hook = item
+ .get("hook")
.and_then(|v| v.as_str())
.unwrap_or("")
.to_string();
- let rationale = item.get("rationale")
+ let rationale = item
+ .get("rationale")
.and_then(|v| v.as_str())
.unwrap_or("")
.to_string();
@@ -413,8 +605,7 @@ fn parse_candidate_json(text: &str, min_duration: f64) -> Result<Vec<CandidateDr
.clone()
.into_iter()
.filter(|candidate| {
- (candidate.end - candidate.start) >= min_duration
- && !candidate.hook.trim().is_empty()
+ (candidate.end - candidate.start) >= min_duration && !candidate.hook.trim().is_empty()
})
.collect::<Vec<_>>();
@@ -422,8 +613,7 @@ fn parse_candidate_json(text: &str, min_duration: f64) -> Result<Vec<CandidateDr
candidates = drafts
.into_iter()
.filter(|candidate| {
- (candidate.end - candidate.start) >= 5.0
- && !candidate.hook.trim().is_empty()
+ (candidate.end - candidate.start) >= 5.0 && !candidate.hook.trim().is_empty()
})
.collect::<Vec<_>>();
}
diff --git a/src-tauri/src/models.rs b/src-tauri/src/models.rs
index c6c1e46..87d8ddc 100644
--- a/src-tauri/src/models.rs
+++ b/src-tauri/src/models.rs
@@ -9,6 +9,9 @@ pub struct EnvironmentStatus {
pub has_deepgram_key: bool,
pub has_anthropic_key: bool,
pub has_deepseek_key: bool,
+ pub has_gemini_key: bool,
+ pub has_openai_key: bool,
+ pub has_openrouter_key: bool,
pub llm_provider: String,
pub has_local_whisper_model: bool,
pub has_ollama: bool,
diff --git a/src/main.tsx b/src/main.tsx
index 4e25abe..13f561f 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -32,6 +32,9 @@ type EnvironmentStatus = {
hasDeepgramKey: boolean;
hasAnthropicKey: boolean;
hasDeepseekKey: boolean;
+ hasGeminiKey: boolean;
+ hasOpenaiKey: boolean;
+ hasOpenrouterKey: boolean;
llmProvider: string;
hasLocalWhisperModel: boolean;
hasOllama: boolean;
@@ -125,8 +128,8 @@ function App() {
const [transcriptionEngine, setTranscriptionEngine] = useState<"deepgram" | "local">(() => {
return (localStorage.getItem("autoshorts_transcription_engine") as "deepgram" | "local") || "local";
});
- const [llmEngine, setLlmEngine] = useState<"claude" | "deepseek" | "local">(() => {
- return (localStorage.getItem("autoshorts_llm_engine") as "claude" | "deepseek" | "local") || "local";
+ const [llmEngine, setLlmEngine] = useState<"claude" | "deepseek" | "local" | "gemini" | "openai" | "openrouter">(() => {
+ return (localStorage.getItem("autoshorts_llm_engine") as "claude" | "deepseek" | "local" | "gemini" | "openai" | "openrouter") || "local";
});
const [localLlmModel, setLocalLlmModel] = useState(() => {
return localStorage.getItem("autoshorts_local_llm_model") || "llama3.2";
@@ -140,6 +143,15 @@ function App() {
const [deepseekKey, setDeepseekKey] = useState(() => {
return localStorage.getItem("autoshorts_deepseek_key") || "";
});
+ const [geminiKey, setGeminiKey] = useState(() => {
+ return localStorage.getItem("autoshorts_gemini_key") || "";
+ });
+ const [openaiKey, setOpenaiKey] = useState(() => {
+ return localStorage.getItem("autoshorts_openai_key") || "";
+ });
+ const [openrouterKey, setOpenrouterKey] = useState(() => {
+ return localStorage.getItem("autoshorts_openrouter_key") || "";
+ });
const [downloadingModelName, setDownloadingModelName] = useState<string | null>(null);
const [modelDownloadStatus, setModelDownloadStatus] = useState("");
@@ -170,6 +182,9 @@ function App() {
const canUseCloudKey = environment?.hasDeepgramKey || deepgramKey.trim().length > 0;
const canUseClaude = environment?.hasAnthropicKey || anthropicKey.trim().length > 0;
const canUseDeepseek = environment?.hasDeepseekKey || deepseekKey.trim().length > 0;
+ const canUseGemini = environment?.hasGeminiKey || geminiKey.trim().length > 0;
+ const canUseOpenai = environment?.hasOpenaiKey || openaiKey.trim().length > 0;
+ const canUseOpenrouter = environment?.hasOpenrouterKey || openrouterKey.trim().length > 0;
const canTranscribe = transcriptionEngine === "local"
? Boolean(environment?.hasLocalWhisperModel)
@@ -177,7 +192,15 @@ function App() {
const canUseActiveLlm = llmEngine === "local"
? Boolean(environment?.hasOllama)
- : (llmEngine === "claude" ? canUseClaude : canUseDeepseek);
+ : llmEngine === "claude"
+ ? canUseClaude
+ : llmEngine === "deepseek"
+ ? canUseDeepseek
+ : llmEngine === "gemini"
+ ? canUseGemini
+ : llmEngine === "openai"
+ ? canUseOpenai
+ : canUseOpenrouter;
useEffect(() => {
void refresh();
@@ -213,6 +236,18 @@ function App() {
localStorage.setItem("autoshorts_deepseek_key", deepseekKey);
}, [deepseekKey]);
+ useEffect(() => {
+ localStorage.setItem("autoshorts_gemini_key", geminiKey);
+ }, [geminiKey]);
+
+ useEffect(() => {
+ localStorage.setItem("autoshorts_openai_key", openaiKey);
+ }, [openaiKey]);
+
+ useEffect(() => {
+ localStorage.setItem("autoshorts_openrouter_key", openrouterKey);
+ }, [openrouterKey]);
+
const pullModelDirectly = async (modelName: string) => {
setDownloadingModelName(modelName);
setModelDownloadProgress(0);
@@ -311,7 +346,7 @@ function App() {
async function runAutoPipeline(projectId: string) {
setError(null);
const env = await invoke<EnvironmentStatus>("environment_status");
-
+
if (transcriptionEngine === "local") {
if (!env.hasLocalWhisperModel) {
setError("Import successful. Local Whisper GGML model (ggml-base.bin) is missing in your models directory. Please add it to start transcription.");
@@ -331,12 +366,26 @@ function App() {
return;
}
} else {
- const activeKey = llmEngine === "claude" ? anthropicKey : deepseekKey;
- const hasActiveKey = llmEngine === "claude"
- ? (env.hasAnthropicKey || activeKey.trim().length > 0)
- : (env.hasDeepseekKey || activeKey.trim().length > 0);
+ const activeKey =
+ llmEngine === "claude" ? anthropicKey :
+ llmEngine === "deepseek" ? deepseekKey :
+ llmEngine === "gemini" ? geminiKey :
+ llmEngine === "openai" ? openaiKey :
+ llmEngine === "openrouter" ? openrouterKey : "";
+ const hasActiveKey =
+ llmEngine === "claude" ? (env.hasAnthropicKey || activeKey.trim().length > 0) :
+ llmEngine === "deepseek" ? (env.hasDeepseekKey || activeKey.trim().length > 0) :
+ llmEngine === "gemini" ? (env.hasGeminiKey || activeKey.trim().length > 0) :
+ llmEngine === "openai" ? (env.hasOpenaiKey || activeKey.trim().length > 0) :
+ llmEngine === "openrouter" ? (env.hasOpenrouterKey || activeKey.trim().length > 0) : false;
if (!hasActiveKey) {
- setError(`Transcription complete. ${llmEngine === "claude" ? "Claude" : "DeepSeek"} API Key is missing. Please add it in settings to analyze viral moments.`);
+ const engineName =
+ llmEngine === "claude" ? "Claude" :
+ llmEngine === "deepseek" ? "DeepSeek" :
+ llmEngine === "gemini" ? "Gemini" :
+ llmEngine === "openai" ? "OpenAI" :
+ llmEngine === "openrouter" ? "OpenRouter" : "LLM";
+ setError(`Transcription complete. ${engineName} API Key is missing. Please add it in settings to analyze viral moments.`);
return;
}
}
@@ -543,10 +592,10 @@ function App() {
<div className="app-shell-container">
<main className="app-shell">
<aside className="sidebar">
- <div
- className="brand-row"
- onClick={() => setDetail(null)}
- style={{ cursor: "pointer" }}
+ <div
+ className="brand-row"
+ onClick={() => setDetail(null)}
+ style={{ cursor: "pointer" }}
title="Go to Home Dashboard"
>
<div className="brand-mark">
@@ -596,7 +645,7 @@ function App() {
<h2>{detail.project.name || fileName(detail.project.sourcePath)}</h2>
</div>
<div className="topbar-actions">
- <button
+ <button
className={`icon-button settings-toggle ${showSettings ? "active" : ""}`}
onClick={() => setShowSettings(!showSettings)}
title="API Settings"
@@ -622,16 +671,17 @@ function App() {
<option value="local">Local Whisper (Offline)</option>
<option value="deepgram">Deepgram (Cloud)</option>
</select>
- </label>
- <label>
<span>LLM Engine</span>
<select
value={llmEngine}
- onChange={(event) => setLlmEngine(event.target.value as "claude" | "deepseek" | "local")}
+ onChange={(event) => setLlmEngine(event.target.value as any)}
>
<option value="local">Ollama (Offline Local)</option>
<option value="claude">Claude (Cloud)</option>
<option value="deepseek">DeepSeek (Cloud)</option>
+ <option value="gemini">Google Gemini (Cloud)</option>
+ <option value="openai">OpenAI (Cloud)</option>
+ <option value="openrouter">OpenRouter (Cloud)</option>
</select>
</label>
{transcriptionEngine === "deepgram" && (
@@ -667,6 +717,40 @@ function App() {
/>
</label>
)}
+ {llmEngine === "gemini" && (
+ <label>
+ <span>Gemini API Key</span>
+ <input
+ value={geminiKey}
+ onChange={(event) => setGeminiKey(event.target.value)}
+ placeholder={environment?.hasGeminiKey ? "Loaded from env" : "Optional (Gemini API Key)"}
+ type="password"
+ />
+ </label>
+ )}
+ {llmEngine === "openai" && (
+ <label>
+ <span>OpenAI API Key</span>
+ <input
+ value={openaiKey}
+ onChange={(event) => setOpenaiKey(event.target.value)}
+ placeholder={environment?.hasOpenaiKey ? "Loaded from env" : "Optional (OpenAI API Key)"}
+ type="password"
+ />
+ </label>
+ )}
+ {llmEngine === "openrouter" && (
+ <label>
+ <span>OpenRouter API Key</span>
+ <input
+ value={openrouterKey}
+ onChange={(event) => setOpenrouterKey(event.target.value)}
+ placeholder={environment?.hasOpenrouterKey ? "Loaded from env" : "Optional (OpenRouter API Key)"}
+ type="password"
+ />
+ </label>
+ )}
+
{llmEngine === "local" && (
<label>
<span>Ollama Model Name</span>
@@ -677,9 +761,9 @@ function App() {
placeholder="e.g. llama3.2, qwen2.5:7b"
type="text"
/>
- <button
- type="button"
- className="icon-button"
+ <button
+ type="button"
+ className="icon-button"
style={{ minHeight: '36px', height: '36px' }}
onClick={() => pullModelDirectly(localLlmModel)}
>
@@ -690,9 +774,9 @@ function App() {
)}
</div>
<div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '16px', borderTop: '1px solid var(--border-color)', paddingTop: '16px' }}>
- <button
- type="button"
- className="icon-button"
+ <button
+ type="button"
+ className="icon-button"
style={{ background: 'rgba(239, 68, 68, 0.08)', borderColor: 'rgba(239, 68, 68, 0.2)', color: '#f87171' }}
onClick={() => {
if (window.confirm("Are you sure you want to reset your configuration and restart onboarding from scratch?")) {
@@ -772,7 +856,12 @@ function App() {
<div className="api-warning">
{llmEngine === "local"
? "⚠️ Ollama local server is not running at http://localhost:11434. Moment detection will not work."
- : `⚠️ ${llmEngine === "claude" ? "Claude" : "DeepSeek"} API Key is missing. Viral moment identification will not work. Please add your key in API Settings.`}
+ : `⚠️ ${llmEngine === "claude" ? "Claude" :
+ llmEngine === "deepseek" ? "DeepSeek" :
+ llmEngine === "gemini" ? "Gemini" :
+ llmEngine === "openai" ? "OpenAI" :
+ llmEngine === "openrouter" ? "OpenRouter" : "LLM"
+ } API Key is missing. Viral moment identification will not work. Please add your key in API Settings.`}
</div>
)}
@@ -814,7 +903,7 @@ function App() {
{candidate.selected && <Check size={14} />}
</div>
</div>
-
+
<div className="candidate-body">
<div className="candidate-meta">
<span>{formatTime(candidate.startSec)} - {formatTime(candidate.endSec)}</span>
@@ -822,7 +911,7 @@ function App() {
</div>
<h4>{candidate.hook}</h4>
<p className="candidate-rationale">{candidate.rationale}</p>
-
+
<div className="candidate-actions">
<span className={`clip-status ${isCut ? "ready" : clip?.status === "error" ? "error" : ""}`}>
{isCut ? "Cut ready" : clip?.status === "error" ? "Cut failed" : clip?.status ?? "Pending"}
@@ -935,9 +1024,9 @@ function App() {
<h3>Choose Caption Style</h3>
<p>Select how your automated captions should look on the portrait short-form video clips.</p>
</div>
-
+
<div className="style-grid">
- <div
+ <div
className={`style-card ${selectedStyle === "modern-box" ? "selected" : ""}`}
onClick={() => setSelectedStyle("modern-box")}
>
@@ -948,7 +1037,7 @@ function App() {
<div className="style-card-desc">Sleek white text inside a semi-transparent black background padding box. Highly readable.</div>
</div>
- <div
+ <div
className={`style-card ${selectedStyle === "classic-outline" ? "selected" : ""}`}
onClick={() => setSelectedStyle("classic-outline")}
>
@@ -959,7 +1048,7 @@ function App() {
<div className="style-card-desc">Vibrant bold yellow text with a clean black outline. High-energy CapCut formatting.</div>
</div>
- <div
+ <div
className={`style-card ${selectedStyle === "minimal-shadow" ? "selected" : ""}`}
onClick={() => setSelectedStyle("minimal-shadow")}
>
@@ -970,7 +1059,7 @@ function App() {
<div className="style-card-desc">Pure white text with a soft, elegant drop shadow. Unobtrusive and modern.</div>
</div>
- <div
+ <div
className={`style-card ${selectedStyle === "vibrant-cyan" ? "selected" : ""}`}
onClick={() => setSelectedStyle("vibrant-cyan")}
>
@@ -981,7 +1070,7 @@ function App() {
<div className="style-card-desc">Vibrant tech cyan text with a black drop shadow for a clean look.</div>
</div>
- <div
+ <div
className={`style-card ${selectedStyle === "vibrant-yellow-box" ? "selected" : ""}`}
onClick={() => setSelectedStyle("vibrant-yellow-box")}
>
@@ -992,7 +1081,7 @@ function App() {
<div className="style-card-desc">Bold black text inside a solid yellow padding box. Punchy and high visibility.</div>
</div>
- <div
+ <div
className={`style-card ${selectedStyle === "vibrant-green" ? "selected" : ""}`}
onClick={() => setSelectedStyle("vibrant-green")}
>
@@ -1003,7 +1092,7 @@ function App() {
<div className="style-card-desc">High-energy neon green text with black borders and a drop shadow (Hormozi style).</div>
</div>
- <div
+ <div
className={`style-card ${selectedStyle === "vibrant-red" ? "selected" : ""}`}
onClick={() => setSelectedStyle("vibrant-red")}
>
@@ -1038,11 +1127,11 @@ function App() {
<div className="download-loader">
<Loader2 className="spin" size={48} />
</div>
-
+
<div className="progress-bar-container">
<div className="progress-bar-fill" style={{ width: `${modelDownloadProgress}%` }}></div>
</div>
-
+
<div className="download-stats">
<span className="download-status">{modelDownloadStatus}</span>
<span className="download-percentage">{modelDownloadProgress}%</span>
@@ -1123,11 +1212,11 @@ function Onboarding({
}: OnboardingProps) {
const [setupMode, setSetupMode] = useState<"choose" | "local" | "cloud" | "downloading">("choose");
const [selectedModel, setSelectedModel] = useState<string>("llama3.2");
-
+
const [dgKey, setDgKey] = useState(initialDeepgramKey);
const [antKey, setAntKey] = useState(initialAnthropicKey);
const [dsKey, setDsKey] = useState(initialDeepseekKey);
-
+
const [downloadStatus, setDownloadStatus] = useState("Initializing download...");
const [downloadProgress, setDownloadProgress] = useState(0);
const [error, setError] = useState<string | null>(null);
@@ -1150,12 +1239,12 @@ function Onboarding({
setError("Please provide at least one LLM Key (Claude or DeepSeek).");
return;
}
-
+
setTranscriptionEngine("deepgram");
setDeepgramKey(dgKey.trim());
localStorage.setItem("autoshorts_deepgram_key", dgKey.trim());
localStorage.setItem("autoshorts_transcription_engine", "deepgram");
-
+
if (antKey.trim()) {
setLlmEngine("claude");
setAnthropicKey(antKey.trim());
@@ -1167,7 +1256,7 @@ function Onboarding({
localStorage.setItem("autoshorts_deepseek_key", dsKey.trim());
localStorage.setItem("autoshorts_llm_engine", "deepseek");
}
-
+
localStorage.setItem("autoshorts_onboarded", "true");
onComplete();
};
@@ -1176,9 +1265,9 @@ function Onboarding({
setError(null);
setCheckingOllama(true);
setDownloadProgress(0);
-
+
await refreshEnv();
-
+
let isOllamaRunning = false;
try {
const currentEnv = await invoke<EnvironmentStatus>("environment_status");
@@ -1186,13 +1275,13 @@ function Onboarding({
} catch (e) {
// ignore
}
-
+
setCheckingOllama(false);
if (!isOllamaRunning) {
setSetupMode("downloading");
setDownloadStatus("Ollama not found. Starting automatic installer...");
-
+
try {
const unlistenInstall = await listen<string>("ollama-install-status", (event) => {
setDownloadStatus(event.payload);
@@ -1225,18 +1314,18 @@ function Onboarding({
});
await invoke("pull_ollama_model", { modelName: selectedModel });
-
+
unlisten();
setTranscriptionEngine("local");
setLlmEngine("local");
setLocalLlmModel(selectedModel);
-
+
localStorage.setItem("autoshorts_transcription_engine", "local");
localStorage.setItem("autoshorts_llm_engine", "local");
localStorage.setItem("autoshorts_local_llm_model", selectedModel);
localStorage.setItem("autoshorts_onboarded", "true");
-
+
onComplete();
} catch (err) {
setError(err instanceof Error ? err.message : String(err));
@@ -1314,13 +1403,13 @@ function Onboarding({
<div className="step-body">
<h4>Set up local LLM (Ollama)</h4>
<p>
- Ollama must be installed and running on your machine.
+ Ollama must be installed and running on your machine.
If you don't have it installed, you can download it from <a href="https://ollama.com" target="_blank" rel="noreferrer" style={{ color: 'var(--accent-primary)', textDecoration: 'underline' }}>ollama.com</a>.
</p>
<p>Select a model to download:</p>
-
+
<div className="model-cards">
- <div
+ <div
className={`model-card ${selectedModel === "llama3.2" ? "active" : ""}`}
onClick={() => setSelectedModel("llama3.2")}
>
@@ -1331,7 +1420,7 @@ function Onboarding({
<p>Requires 8GB+ RAM. Recommended for standard setups. Fast and efficient.</p>
</div>
- <div
+ <div
className={`model-card ${selectedModel === "qwen2.5:3b" ? "active" : ""}`}
onClick={() => setSelectedModel("qwen2.5:3b")}
>
@@ -1342,7 +1431,7 @@ function Onboarding({
<p>Requires 8GB+ RAM. Excellent coding and logical reasoning abilities.</p>
</div>
- <div
+ <div
className={`model-card ${selectedModel === "qwen2.5:7b" ? "active" : ""}`}
onClick={() => setSelectedModel("qwen2.5:7b")}
>
@@ -1359,9 +1448,9 @@ function Onboarding({
<div className="onboarding-actions">
<button type="button" className="icon-button" onClick={() => setSetupMode("choose")}>Back</button>
- <button
+ <button
type="button"
- className="primary-action compact"
+ className="primary-action compact"
onClick={startLocalSetup}
disabled={checkingOllama}
>
@@ -1384,9 +1473,9 @@ function Onboarding({
<div className="form-stack">
<div className="input-group">
<label>Deepgram API Key *</label>
- <input
- type="password"
- value={dgKey}
+ <input
+ type="password"
+ value={dgKey}
onChange={(e) => setDgKey(e.target.value)}
placeholder="Insert your Deepgram API Key (for transcription)"
/>
@@ -1394,9 +1483,9 @@ function Onboarding({
<div className="input-group">
<label>Claude API Key</label>
- <input
- type="password"
- value={antKey}
+ <input
+ type="password"
+ value={antKey}
onChange={(e) => setAntKey(e.target.value)}
placeholder="Insert your Anthropic API Key (moment detection)"
/>
@@ -1404,9 +1493,9 @@ function Onboarding({
<div className="input-group">
<label>DeepSeek API Key</label>
- <input
- type="password"
- value={dsKey}
+ <input
+ type="password"
+ value={dsKey}
onChange={(e) => setDsKey(e.target.value)}
placeholder="Insert your DeepSeek API Key (alternative moment detection)"
/>
@@ -1432,11 +1521,11 @@ function Onboarding({
<div className="download-loader">
<Loader2 className="spin" size={48} />
</div>
-
+
<div className="progress-bar-container">
<div className="progress-bar-fill" style={{ width: `${downloadProgress}%` }}></div>
</div>
-
+
<div className="download-stats">
<span className="download-status">{downloadStatus}</span>
<span className="download-percentage">{downloadProgress}%</span>