BONUS CONTENT FOR: GPT-4 codes ChatGPT chatbot with memory webapp with FastAPI and JavaScript YouTube video (Patreon)
Downloads
Content
this is a BONUS content for video: https://youtu.be/NxvhDPMF9SU
NOTE: from_scratch folder in the code files is an easier implementation of the main UI chatbot with memory
Miniconda: https://docs.conda.io/projects/miniconda/en/latest/
chat completions doc: https://platform.openai.com/docs/guides/chat/introduction
Prompt from the video:
Follow these instructions carefully: We will create python backend with fastapi and a javascript frontend for a chatbot. think step by step so you eliminate any possible errors. implement middleware with cors. outline any pip installs that needs to be done. Just use FastAPI, Uvicorn and openai. use a seperate js script file give instructions on how to run the server. we will make calls to gpt-3.5-turbo cals to openai api as: "# Note: you need to be using OpenAI Python v0.27.0 for the code below to work import openai openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who won the world series in 2020?"}, {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."}, {"role": "user", "content": "Where was it played?"} ] )" sample response from api is: "{ 'id': 'chatcmpl-6p9XYPYSTTRi0xEviKjjilqrWU2Ve', 'object': 'chat.completion', 'created': 1677649420, 'model': 'gpt-3.5-turbo', 'usage': {'prompt_tokens': 56, 'completion_tokens': 31, 'total_tokens': 87}, 'choices': [ { 'message': { 'role': 'assistant', 'content': 'The 2020 World Series was played in Arlington, Texas at the Globe Life Field, which was the new home stadium for the Texas Rangers.'}, 'finish_reason': 'stop', 'index': 0 } ] } User's message will be sent to the pyton backend and the response from api will return to the browser. write the html and css to make the website for the chatbot beautiful and elegant