diff --git a/www/app/Chat.tsx b/www/app/Chat.tsx index 5654708..529bc8c 100644 --- a/www/app/Chat.tsx +++ b/www/app/Chat.tsx @@ -6,7 +6,7 @@ import dynamic from 'next/dynamic'; import { FaLightbulb, FaPaperPlane } from 'react-icons/fa'; import Swal from 'sweetalert2'; -import { useRef, useEffect, useState, ElementRef } from 'react'; +import { useRef, useEffect, useState, ElementRef, useMemo } from 'react'; import { useRouter } from 'next/navigation'; import { usePostHog } from 'posthog-js/react'; @@ -392,7 +392,7 @@ export default function Chat({ } } - const canUseApp = isSubscribed || freeMessages > 0; + const canUseApp = useMemo(() => isSubscribed || freeMessages > 0, [isSubscribed, freeMessages]); return (
diff --git a/www/app/api/chat/route.ts b/www/app/api/chat/route.ts index 9fe2eee..471545f 100644 --- a/www/app/api/chat/route.ts +++ b/www/app/api/chat/route.ts @@ -3,8 +3,7 @@ import { NextRequest, NextResponse } from 'next/server'; import { thinkCall, respondCall } from './actions'; import { honcho, getHonchoApp, getHonchoUser } from '@/utils/honcho'; import { streamText } from 'ai'; -// import { createOpenAI } from '@ai-sdk/openai'; -import { createOpenRouter } from '@openrouter/ai-sdk-provider' +import { createOpenRouter } from '@openrouter/ai-sdk-provider'; import * as Sentry from '@sentry/nextjs'; @@ -158,9 +157,13 @@ export async function POST(req: NextRequest) { const { type, message, conversationId, thought, honchoThought } = data; + console.log("Starting Stream") + const honchoApp = await getHonchoApp(); const honchoUser = await getHonchoUser(user.id); + console.log("Got the Honcho User") + const honchoPayload = { appId: honchoApp.id, userId: honchoUser.id, @@ -179,7 +182,6 @@ export async function POST(req: NextRequest) { sessionId: conversationId, }); } else if (type === 'honcho') { - console.log("Dialectic Query"); const dialecticQuery = await honcho.apps.users.sessions.chat( honchoApp.id, honchoUser.id, @@ -202,6 +204,8 @@ export async function POST(req: NextRequest) { }); } + console.log("Getting the Stream") + const stream = await fetchOpenRouter(type, messages, honchoPayload); if (!stream) { diff --git a/www/middleware.ts b/www/middleware.ts index 36942e1..46f3c4d 100644 --- a/www/middleware.ts +++ b/www/middleware.ts @@ -2,7 +2,8 @@ import { type NextRequest } from "next/server"; import { updateSession } from "@/utils/supabase/middleware"; export async function middleware(request: NextRequest) { - return await updateSession(request); + const response = await updateSession(request); + return response; } export const config = {