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
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Chat from "./components/Chat"; | |
export const metadata = { | |
title: "Chat with short-term memory", | |
}; | |
export default function Home() { | |
return ( | |
<main> | |
<Chat /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use client"; | |
import { FC } from "react"; | |
import type { MessageType } from "langchain/schema"; | |
interface ChatMessageProps { | |
text: string; | |
type: MessageType; | |
} |
NewerOlder