Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OPENAI_API_KEY=''
"use client";
import {
FC,
FormEvent,
useState,
useCallback,
useRef,
useEffect,
useMemo,
} from "react";
"use client";
import { FC } from "react";
import type { MessageType } from "langchain/schema";
interface ChatMessageProps {
text: string;
type: MessageType;
}
import Chat from "./components/Chat";
export const metadata = {
title: "Chat with short-term memory",
};
export default function Home() {
return (
<main>
<Chat />
import { ChatOpenAI } from "langchain/chat_models/openai";
import { CallbackManager } from "langchain/callbacks";
import {
ChatPromptTemplate,
HumanMessagePromptTemplate,
SystemMessagePromptTemplate,
MessagesPlaceholder,
} from "langchain/prompts";
import { ConversationChain } from "langchain/chains";
npx create-next-app@latest --ts --tailwind --experimental-app chat

cd chat

# https://github.com/debug-js/debug/issues/912
npm install -S langchain debug supports-color@^8.1.1

# Don't forget to set your API_KEY!
# .env  https://gist.github.com/shibanovp/2178a3e80d92d0ff2a9ce983b3c512ee
{
"name": "setup-chat",
"description": "the gist to setup Build your own AI-Powered chat app with Next.js and LangChain from blog.experienced.dev",
"version": "0.3.0",
"engines": {
"node": ">=18"
},
"bin": "./setup.js"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.