Skip to content

Instantly share code, notes, and snippets.

View joenandez's full-sized avatar
probably coffee'ing

Joe Fernandez joenandez

probably coffee'ing
View GitHub Profile
@joenandez
joenandez / route.ts
Created February 15, 2025 00:20
Chat Route
import { NextResponse } from 'next/server'
import { streamText, createIdGenerator, appendResponseMessages, appendClientMessage, Message } from 'ai'
import { ToolCallRepairOptions } from '@/types/tools'
import { emitDocumentEvent } from '@/lib/events/documentEvents'
import { openai } from '@ai-sdk/openai'
import { getSupabaseServer } from '@/lib/supabase-server'
import { toolSet } from '@/lib/ai/toolDefs'
import { createOrUpdateNote } from '@/lib/notesClient'
import { saveChat } from '@/lib/threads/messageStore'
import { getPromptComponents } from '@/lib/ai/contextManager'

Phase 4: Advanced AI Integration with Vercel AI SDK Tool Calling

Summary

In Phase 4, we will expand upon the builder workflow to integrate Vercel AI SDK–based tool calling. Our goal is for each workflow stage (brainstorm vs. review, etc.) to be able to autonomously create or update notes (e.g., riff.md, prd.md) using tool calls while keeping the entire AI output in the chat thread. We'll rely on multi-step logic (maxSteps) to let the model call a tool, get the result, and then produce final text. We'll also pass “invisible” system messages to the AI, instructing it on how to create or edit a doc.

Key additions:

  1. Tool set definitions (like createDocument, updateDocument) using tool from ai.
  2. Invisibly instructing the AI (system messages) at each new stage or section, so it can spontaneously produce partial or final doc text.
  3. Multi-doc support in a single workspace (as user transitio
@joenandez
joenandez / joenandez_chatgpt_custom_instructions.txt
Created November 28, 2023 17:26
joenandez chatgpt custom instructions
1. NEVER mention that you’re an AI.
2. Avoid any language constructs that could be interpreted as expressing remorse, apology, or regret. This includes any phrases containing words like ‘sorry’, ‘apologies’, ‘regret’, etc., even when used in a context that isn’t expressing remorse, apology, or regret.
3. If events or information are beyond your scope or knowledge cutoff date, provide a response stating ‘I don’t know’ without elaborating on why the information is unavailable.
Refrain from disclaimers about you not being a professional or expert.
4. Keep responses unique and free of repetition.
5. Never suggest seeking information from elsewhere.