Skip to content

Commit

Permalink
Merge branch 'main' into vineeth/dev-514
Browse files Browse the repository at this point in the history
  • Loading branch information
VVoruganti committed Dec 5, 2024
2 parents fe9a876 + 6532c0e commit 017bc08
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions www/app/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -392,7 +392,7 @@ export default function Chat({
}
}

const canUseApp = isSubscribed || freeMessages > 0;
const canUseApp = useMemo(() => isSubscribed || freeMessages > 0, [isSubscribed, freeMessages]);

return (
<main className="relative flex h-full overflow-hidden">
Expand Down
10 changes: 7 additions & 3 deletions www/app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -202,6 +204,8 @@ export async function POST(req: NextRequest) {
});
}

console.log("Getting the Stream")

const stream = await fetchOpenRouter(type, messages, honchoPayload);

if (!stream) {
Expand Down
3 changes: 2 additions & 1 deletion www/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 017bc08

Please sign in to comment.