Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ CRITICAL INSTRUCTIONS FOR WORKSPACE CURATION:
- Use \`updateNote\` tool for notes
- Use \`updateFlashcards\` tool for flashcard sets
- Use \`updateQuiz\` tool for quizzes
2. **Be thorough but focused** - Provide a solid foundation for understanding the topic without being overwhelming.
2. **Be thorough and exhaustive** - Provide deep, academic, and comprehensive coverage. Notes must be detailed and extensive. Avoid summaries.
- **Structure**: Use H2/H3 headers, bullet points, and **bold** text for readability.
- **Math**: Use block math \`$$...$$\` for equations.
3. **Do NOT ask the user questions** - This is an automated initialization, proceed directly with updating the workspace.

QUALITY GUIDELINES FOR CONTENT:
Expand Down Expand Up @@ -185,7 +187,18 @@ When creating/updating notes with research:
Rules:
- Use chunk.web.uri exactly as provided (even redirect URLs)
- Never make up or hallucinate URLs
- Include article dates in responses when available`);
- Include article dates in responses when available

CONTENT GENERATION RULE:
When creating or updating notes, your goal is to be **exhaustive** and **well-structured**.
- **Length**: Write long, detailed paragraphs. Never trade depth for brevity.
- **Headers**: Use H2 (\`##\`) and H3 (\`###\`) to organize sections.
- **Formatting**: **Bold** key terms and defined concepts.
- **Lists**: Use bullet points for steps, features, or lists to improve readability.
- **Math**: Use block math (\`$$...$$\`) for important equations so they render centered. **DO NOT use quadruple dollar signs (\`$$$$\`).**
- **Callouts**: Use blockquotes (\`>\`) for key takeaways or definitions.
- Include code examples and historical context where relevant.
`);


// Add file detection hint if file URLs are present
Expand Down
2 changes: 2 additions & 0 deletions src/components/assistant-ui/markdown-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ export const MarkdownText = memo(MarkdownTextImpl);

function normalizeCustomMathTags(input: string): string {
return (input
// Fix quadruple dollar signs (often generated by AI) to double dollar signs
.replace(/\${4}/g, '$$')
// Convert \( ... \) to $$...$$ (inline math) - streamdown uses $$ for both, inline has no newlines
.replace(/\\{1,2}\(([\s\S]*?)\\{1,2}\)/g, (_, content) => `$$${content.trim()}$$`)
// Convert \[ ... \] to $$...$$ (block math) - streamdown needs newlines for block triggers
Expand Down
6 changes: 4 additions & 2 deletions src/components/assistant-ui/standalone-markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const CodeHeader: FC<{ language?: string; code: string }> = ({ language, code })
function normalizeCustomMathTags(input: string): string {
return (
input
// Fix quadruple dollar signs (often generated by AI) to double dollar signs
.replace(/\${4}/g, '$$')
// Convert [/math]...[/math] to $$...$$ (legacy block math format)
.replace(/\[\/math\]([\s\S]*?)\[\/math\]/g, (_, content) => `$$${content.trim()}$$`)
// Convert [/inline]...[/inline] to $...$ (legacy inline format - ReactMarkdown uses $ for inline)
Expand All @@ -67,8 +69,8 @@ function normalizeCustomMathTags(input: string): string {
.replace(/\\{1,2}\(([\s\S]*?)\\{1,2}\)/g, (_, content) => `$${content.trim()}$`)
// Convert \[ ... \] to $$...$$ (LaTeX block math)
.replace(/\\{1,2}\[([\s\S]*?)\\{1,2}\]/g, (_, content) => `$$${content.trim()}$$`)
// Note: We DON'T convert $...$ to $$ here because ReactMarkdown with remark-math expects
// single dollar signs for inline math and double dollar signs for block math
// Note: We DON'T convert $...$ to $$ here because ReactMarkdown with remark-math expects
// single dollar signs for inline math and double dollar signs for block math
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/ai/tools/workspace-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function createNoteTool(ctx: WorkspaceToolContext) {
inputSchema: zodSchema(
z.object({
title: z.string().describe("The title of the note card"),
content: z.string().describe("The markdown body content. DO NOT repeat title in content. Start with subheadings/text. No Mermaid. Use $$...$$ for ALL math (both inline and block). Single $ is for currency only."),
content: z.string().describe("The markdown body content. Must be detailed, comprehensive, and long-form. **Structure with H2/H3 headers, bullet points, and bold key terms**. Use block math $$...$$ for equations (do not use $$$$). Minimum 3-4 paragraphs."),
sources: z.array(
z.object({
title: z.string().describe("Title of the source page"),
Expand Down Expand Up @@ -76,7 +76,7 @@ export function createUpdateNoteTool(ctx: WorkspaceToolContext) {
inputSchema: zodSchema(
z.object({
noteName: z.string().describe("The name of the note to update (will be matched using fuzzy search)"),
content: z.string().describe("The full note body ONLY (do not include the title as a header). Use $$...$$ for ALL math."),
content: z.string().describe("The full note body ONLY (do not include the title as a header). Must be detailed, comprehensive, and long-form. **Structure with H2/H3 headers, bullet points, and bold key terms**. Use block math $$...$$ for equations (do not use $$$$)."),
title: z.string().optional().describe("New title for the note. If not provided, the existing title will be preserved."),
sources: z.array(
z.object({
Expand Down