In this video we will create a chatbot that uses Nextjs and Langchain #ai #chatgpt #langchain - 👉Looking for a Hosted AI Chatbot 👉 chatterdocs.ai/?via=tyler
hi everyone! there will likely be an update video where I try to do this with Route Handlers and Edge Functions in Vercel. in the interim here is the repo so you can try the current implementation. REPO 👉 github.com/linuxandchill/langchat
@@tylerwhatsgood thanks for the video tyler! I'm using typescript and req.json() throws an error 'property 'json' does not exist on type 'NextApiRequest'.' Do you know a workaround? (:
@@ivanezquerra8902 hmmm what is your nextjs version? it might something to do with bodyParser but not really sure. can you please throw your api route in a gist so i can take a look? thanks Ivan!
thanks for your reply@@tylerwhatsgood ! Yes, it was to do with bodyParser and running an edge function. the solution was simple in the end, this is how the code looks: const handler = async (req: any) => { const body = await req.json() .... thanks again for the video! Based on it, I've made a harm reduction bot with a specialised database on psychoactive substances for health workers
hey! sorry for late reply. check this out and lmk if this work js.langchain.com/docs/integrations/llms/ollama I have some python examples in this video that would use Ollama or HF ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-U_Sg3Odf1vk.html at 05:06 It is in python but if you search the `javascript langchain` docs u should be able to find a way to do the same in js! lmk if u cant figure out i will try to help. thank u!!
How do you know how many openai tokens have been used per session or interaction? I would love to keep track of that in case we need to charge users for a paid app.
Hey Reynaldo, I have not tried it but what about this pkg npx @ai-assist/openai-apilyzer community.openai.com/t/use-cli-to-batch-download-the-usage-data-of-openai-api/127734
sorry for late response! this video is a bit older and i didn't really need the new folder structure for anything special (i think it was still under heavy dev also) but i will probably start all new Nextjs projects with it just to get used to it. how are you liking it?
hey ! did you save the key from OpenAI in the .env.local file? make sure you restart the server once you add that file or it won't get picked up. let me know if youre still having issues after trying that, thanks!!
@@tylerwhatsgood Thanks, so in theory it would be something like create .env.local file then inside put a export const OPEN_AI_KEY = 'personal ai key here'?
@@PmartN if you are following the video and did it in a NextJS project then it would just be OPEN_AI_KEY=examplekey123 (export cons const). if it is not a Nextjs project might be a bit different, can you tell me a bit more about the project?
@@PmartN ok gotcha, in that case it's just OPEN_AI_KEY=examplekey123, no export const as it's not a js or ts file. hope u got it worked out! lmk if still need help