Skip to content

Commit 92c3e45

Browse files
committed
Fixes for o1 models, and other updates
1 parent e00b2be commit 92c3e45

File tree

8 files changed

+40
-32
lines changed

8 files changed

+40
-32
lines changed

client/src/components/ChatNode.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { Textarea } from "@/components/ui/textarea";
1111
import { Send, Trash2, Loader2, Maximize2, X } from "lucide-react";
1212
import { useToast } from "@/hooks/use-toast";
1313
import ReactMarkdown from "react-markdown";
14-
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
1514
import {
1615
Select,
1716
SelectContent,
@@ -23,18 +22,13 @@ import { AIModel, APIResponseMetrics, CustomModel, Message, availableModels } fr
2322
import { cn, sanitizeChatMessages } from "@/lib/utils";
2423
import { useStore } from "@/lib/store";
2524
import { Copy, Check } from "lucide-react";
26-
import { oneDark } from "react-syntax-highlighter/dist/esm/styles/prism";
2725
import { NodeResizer } from 'reactflow';
2826
import Anthropic from '@anthropic-ai/sdk';
2927
import { DEFAULT_AI_SETTINGS, AISettings, PRESET_ENDPOINTS } from '@/lib/constants';
3028
import { ImageUpload } from "./ImageUpload";
3129
import logo from "@/assets/logo.svg";
3230
import { RAGService } from "@/lib/rag";
33-
import { FileUpload } from "./FileUpload";
34-
import { encode } from "gpt-tokenizer";
35-
import { defaultLocalModels } from "@/lib/localmodels";
36-
import { modelService } from "@/lib/localmodels";
37-
import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "./ui/context-menu";
31+
// import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "./ui/context-menu";
3832
import { RAGSelector } from "./RAGSelector";
3933
import { CodeBlock } from "./CodeBlock";
4034
import remarkGfm from 'remark-gfm';
@@ -308,6 +302,7 @@ export function ChatNode({ id, data: initialData }: NodeProps) {
308302

309303
const assistantMessage: Message = {
310304
role: "assistant",
305+
// @ts-ignore anthropic returns content as an array
311306
content: response.content[0].text,
312307
metrics: {
313308
tokensPerSecond: metrics.completion_tokens ? metrics.completion_tokens / totalTime : undefined,
@@ -320,12 +315,22 @@ export function ChatNode({ id, data: initialData }: NodeProps) {
320315

321316

322317
} else {
318+
323319
const messageContent = imageData
324320
? [
325321
{ type: "text", text: input },
326322
{ type: "image_url", image_url: { url: imageData } }
327323
]
328324
: input;
325+
326+
// Check if using O1 models
327+
const isO1Model = model.includes('o1-mini') || model.includes('o1') || model.includes('o1-preview');
328+
const messagesToSend = sanitizeChatMessages([
329+
...((!isO1Model && enhancedSystemPrompt) ? [{ role: 'system', content: enhancedSystemPrompt }] : []),
330+
...allMessages.slice(0, -1),
331+
{ role: "user", content: messageContent }
332+
]).filter(m => m.content);
333+
329334
response = await fetch(`${baseUrl}/chat/completions`, {
330335
method: "POST",
331336
headers: {
@@ -334,11 +339,7 @@ export function ChatNode({ id, data: initialData }: NodeProps) {
334339
},
335340
body: JSON.stringify({
336341
model,
337-
messages: sanitizeChatMessages([
338-
{ role: 'system', content: enhancedSystemPrompt },
339-
...allMessages.slice(0, -1),
340-
{ role: "user", content: messageContent }
341-
]).filter(m => m.content),
342+
messages: messagesToSend,
342343
// we shouldnt pass any of these unless they are changed from the defaults
343344
...filterAISettings(settings),
344345
}),
@@ -502,8 +503,8 @@ export function ChatNode({ id, data: initialData }: NodeProps) {
502503
key={i}
503504
className={`${
504505
msg.role === "user"
505-
? "bg-primary text-primary-foreground ml-4"
506-
: "bg-muted text-muted-foreground mr-4"
506+
? "bg-primary text-primary-foreground"
507+
: "bg-muted text-muted-foreground"
507508
} p-3 rounded-lg relative group`}
508509
>
509510
<div className="absolute right-2 top-2 opacity-0 group-hover:opacity-100 transition-opacity">
@@ -535,10 +536,10 @@ export function ChatNode({ id, data: initialData }: NodeProps) {
535536
h2: ({ children }) => <h2 className="text-xl font-bold mb-2">{children}</h2>,
536537
h3: ({ children }) => <h3 className="text-lg font-bold mb-2">{children}</h3>,
537538
h4: ({ children }) => <h4 className="text-base font-bold mb-2">{children}</h4>,
538-
p: ({ children }) => <p className="mb-4">{children}</p>,
539+
p: ({ children }) => <p className="mt-1 mb-2">{children}</p>,
539540
ul: ({ children }) => <ul className="list-disc list-inside mb-4">{children}</ul>,
540541
ol: ({ children }) => <ol className="list-decimal list-inside mb-4">{children}</ol>,
541-
li: ({ children }) => <li className="mb-1">{children}</li>,
542+
li: ({ children }) => <li className="mb-2">{children}</li>,
542543
a: ({ href, children }) => (
543544
<a href={href} className="text-primary hover:underline" target="_blank" rel="noopener noreferrer">
544545
{children}

client/src/components/CodeBlock.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@ import { Button } from './ui/button';
33
import { Copy, Check } from 'lucide-react';
44
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
55
import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism';
6-
import type { CodeProps } from 'react-markdown/lib/ast-to-react';
6+
7+
interface CodeBlockProps {
8+
inline?: boolean;
9+
className?: string;
10+
children: React.ReactNode;
11+
}
712

813
export const CodeBlock = memo(({
914
inline,
1015
className,
1116
children,
1217
...props
13-
}: CodeProps) => {
18+
}: CodeBlockProps) => {
1419
const [isCopied, setIsCopied] = useState(false);
1520
const match = /language-(\w+)/.exec(className || '');
1621

17-
const handleCopy = useCallback((e: React.MouseEvent) => {
22+
const handleCopy = (e: React.MouseEvent) => {
1823
e.preventDefault();
1924
e.stopPropagation();
20-
25+
console.log('Copying code block');
2126
if (!children) return;
2227

2328
const code = String(children).replace(/\n$/, '');
@@ -27,17 +32,19 @@ export const CodeBlock = memo(({
2732
}).catch(err => {
2833
console.error('Failed to copy:', err);
2934
});
30-
}, [children]);
35+
};
3136

3237
if (!inline && match) {
3338
return (
34-
<div className="relative group" onMouseDown={e => e.stopPropagation()}>
39+
<div className="relative group">
3540
{/* <Button
3641
type="button"
3742
variant="ghost"
3843
size="icon"
3944
className="absolute right-2 top-2 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity hover:bg-muted/50"
40-
onMouseDown={handleCopy}
45+
onClick={(e) => {
46+
handleCopy(e);
47+
}}
4148
>
4249
{isCopied ? (
4350
<Check className="h-3 w-3 text-green-500" />

client/src/components/SettingsDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export function SettingsDialog({ open, onOpenChange }: SettingsDialogProps) {
7979

8080
<div className="flex justify-center">
8181
<img src={logo} alt="Curiso.ai" title="Curiso.ai" className="w-12 h-12" /></div>
82-
<div className="flex justify-center"><p className="text-sm text-muted-foreground justify-center mb-2">Version v1.1.2 by <a
82+
<div className="flex justify-center"><p className="text-sm text-muted-foreground justify-center mb-2">Version v1.1.3 by <a
8383
href="https://github.com/metaspartan/curiso"
8484
onClick={(e) => {
8585
e.preventDefault();

client/src/lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Node as ReactFlowNode } from 'reactflow';
33
import googleLogo from '@/assets/google-logo.svg'
44

55
export interface Message {
6-
role: 'user' | 'assistant';
6+
role: 'user' | 'assistant' | 'system';
77
content: string;
88
image_url?: string;
99
metrics?: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "curiso.ai",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"author": "Carsen Klock",
55
"type": "module",
66
"license": "MIT",

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "curiso-ai"
3-
version = "1.1.2"
3+
version = "1.1.3"
44
description = "Curiso AI Desktop"
55
authors = ["Carsen Klock"]
66
license = "MIT"

src-tauri/tauri.conf.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"identifier": "com.curiso.ai",
33
"productName": "Curiso AI",
4-
"version": "1.1.2",
4+
"version": "1.1.3",
55
"build": {
6-
"beforeBuildCommand": "npm run build",
7-
"beforeDevCommand": "npm run dev",
6+
"beforeBuildCommand": "bun run build",
7+
"beforeDevCommand": "bun run dev",
88
"devUrl": "http://localhost:5173",
99
"frontendDist": "../dist"
1010
},
1111
"app": {
1212
"withGlobalTauri": true,
1313
"security": {
14-
"csp": "default-src 'self' 'unsafe-inline' 'wasm-unsafe-eval' http://localhost:* https://*; script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net blob:; img-src 'self' data: https:; style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://* http://* http://127.0.0.1:* http://localhost:*; connect-src 'self' http://127.0.0.1:* http://localhost:* https://* http://* https://cdnjs.cloudflare.com https://cdn.jsdelivr.net; worker-src 'self' blob: data: https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://* http://* http://127.0.0.1:* http://localhost:*",
14+
"csp": "default-src 'self' 'unsafe-inline' 'wasm-unsafe-eval' http://localhost:* https://*; script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net blob:; img-src 'self' data: https:; style-src 'self' 'unsafe-inline' 'unsafe-hashes' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://* http://* http://127.0.0.1:* http://localhost:* data: blob:; connect-src 'self' http://127.0.0.1:* http://localhost:* https://* http://* https://cdnjs.cloudflare.com https://cdn.jsdelivr.net; worker-src 'self' blob: data: https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://* http://* http://127.0.0.1:* http://localhost:*",
1515
"capabilities": [
1616
{
1717
"identifier": "fetch",

0 commit comments

Comments
 (0)