Skip to content

Commit

Permalink
feat: add copy button for ollama command in obsidian, filter out html…
Browse files Browse the repository at this point in the history
… from answers
  • Loading branch information
louis030195 committed Feb 18, 2025
1 parent a9cc7a6 commit a373be7
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pipes/obsidian/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian",
"version": "0.1.21",
"version": "0.1.24",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
Expand Down
16 changes: 15 additions & 1 deletion pipes/obsidian/src/app/api/intelligence/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,21 @@ Generate a structured analysis following the above format.`;
maxRetries: 5,
});

return response.text;
// Transform <think> tags into Obsidian foldable callouts
let transformedText = response.text.replace(
/<think>([\s\S]*?)<\/think>/g,
(_, content) =>
`> [!note]- Thinking Process\n${content
.split("\n")
.map((line: string) => `> ${line}`)
.join("\n")}`
);

// Transform <video> tags to just 'video'
transformedText = transformedText.replace(/<video>/g, "video");
transformedText = transformedText.replace(/<\/video>/g, "");

return transformedText;
}

async function saveMarkdown(
Expand Down
50 changes: 50 additions & 0 deletions pipes/obsidian/src/components/obsidian-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Clock,
ExternalLink,
Loader2,
Copy,
} from "lucide-react";
import { useToast } from "@/hooks/use-toast";
import { OllamaModelsList } from "./ollama-models-list";
Expand Down Expand Up @@ -567,6 +568,30 @@ export function ObsidianSettings() {
>
<Brain className="h-4 w-4" />
log generation model
<code className="px-2 py-0.5 bg-muted rounded-md text-xs flex items-center gap-2">
ollama run{" "}
{settings?.logModel || "llama3.2:3b-instruct-q4_K_M"}
<Button
type="button"
variant="ghost"
size="icon"
className="h-4 w-4 p-0"
onClick={() => {
navigator.clipboard.writeText(
`ollama run ${
settings?.logModel ||
"llama3.2:3b-instruct-q4_K_M"
}`
);
toast({
title: "copied to clipboard",
duration: 1000,
});
}}
>
<Copy className="h-3 w-3" />
</Button>
</code>
</Label>
<OllamaModelsList
disabled={!pathValidation.isValid}
Expand Down Expand Up @@ -626,6 +651,31 @@ export function ObsidianSettings() {
>
<Brain className="h-4 w-4" />
analysis model
<code className="px-2 py-0.5 bg-muted rounded-md text-xs flex items-center gap-2">
ollama run{" "}
{settings?.analysisModel ||
"deepseek-r1:7b-qwen-distill-q4_K_M"}
<Button
type="button"
variant="ghost"
size="icon"
className="h-4 w-4 p-0"
onClick={() => {
navigator.clipboard.writeText(
`ollama run ${
settings?.analysisModel ||
"deepseek-r1:7b-qwen-distill-q4_K_M"
}`
);
toast({
title: "copied to clipboard",
duration: 1000,
});
}}
>
<Copy className="h-3 w-3" />
</Button>
</code>
</Label>
<OllamaModelsList
disabled={!pathValidation.isValid}
Expand Down

0 comments on commit a373be7

Please sign in to comment.