diff --git a/src/app/api/imageInput/route.ts b/src/app/api/imageInput/route.ts index 80d38012..14c833d3 100644 --- a/src/app/api/imageInput/route.ts +++ b/src/app/api/imageInput/route.ts @@ -10,6 +10,7 @@ import { NextApiResponse } from "next"; import { StreamingTextResponse, LangChainStream } from "ai"; import { systemPrompt, ellaPrompt } from "@/utils/prompts"; import { chattype } from "@/lib/types"; +// import { ChatAnthropic } from "langchain/chat_models/anthropic"; export const maxDuration = 60; // This function can run for a maximum of 5 seconds export const dynamic = "force-dynamic"; @@ -153,6 +154,13 @@ export async function POST(request: Request, response: NextApiResponse) { }, ], }); + // const anthropic = new ChatAnthropic({ + // anthropicApiKey: env.ANTHROPIC_API_KEY, + // streaming: true, + // modelName: "claude-3-sonnet-20240229", + // callbacks: [handlers] + // }); + // const str = anthropic.call([...msg, message], {}, [handlers]) const str = chat .call([...msg, message], {}, [handlers]) .catch(console.error); diff --git a/src/app/env.mjs b/src/app/env.mjs index 8a64a8fd..2ec4d7ca 100644 --- a/src/app/env.mjs +++ b/src/app/env.mjs @@ -3,6 +3,8 @@ import { z } from "zod"; export const env = createEnv({ server: { + // Anthropic + ANTHROPIC_API_KEY: z.string().min(10), // OpenAI OPEN_AI_API_KEY: z.string().min(10), // LLaMA-2-7B-32K-Instruct (7B) from https://api.together.xyz @@ -62,6 +64,8 @@ export const env = createEnv({ }, runtimeEnv: { + // Anthropic + ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY, // Clerk (Auth) NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY, diff --git a/src/components/chat.tsx b/src/components/chat.tsx index 79d8f81b..4a425a20 100644 --- a/src/components/chat.tsx +++ b/src/components/chat.tsx @@ -166,6 +166,7 @@ export default function Chat(props: ChatProps) { }); console.log("messages", messages); + //TODO: handle user incoming from dashboard when invoked a chat useEffect(() => { if (isNewChat === "true" && incomingInput) { //TODO: use types for useQueryState @@ -323,6 +324,9 @@ export default function Chat(props: ChatProps) { )} void; + getRootProps: any; } const InputBar = (props: InputBarProps) => { @@ -478,24 +481,41 @@ const InputBar = (props: InputBarProps) => { return () => clearInterval(interval); }, [isBlinking]); + + useEffect(() => { + if (!isBlinking) { + const resetTimer = setTimeout(() => { + setTranscriptHashTable({}); + }, 5000); // Reset after 5 seconds + + return () => clearTimeout(resetTimer); + } + }, [isBlinking]); + return (
{ + console.log("being dropped", acceptedFiles); + props.onDrop(acceptedFiles); + }} > + - { } chattype={props.chattype} setChatType={props.setChattype} - /> - {/* */} + /> */} + { value={ props.value + (isBlinking ? ".".repeat(displayNumber) : "") } - onChange={handleInputChange} + onChange={(e) => { + handleInputChange(e); + }} onKeyDown={(e) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); @@ -605,13 +627,12 @@ const InputBar = (props: InputBarProps) => { const newAudioId = audioId + 1; setAudioId(newAudioId); setTranscriptHashTable((prev) => ({ - ...prev, [newAudioId]: props.value, })); }} onStopListening={() => { setIsBlinking(false); - setTranscriptHashTable({}); + // setTranscriptHashTable({}); setIsAudioWaveVisible(false); }} // disabled={isRecording || isTranscribing || disableInputs}