From the course: Advanced Python Projects: Build AI Applications
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Setup FastAPI app, CORS, S3 session, and obtain a chat response - Python Tutorial
From the course: Advanced Python Projects: Build AI Applications
Setup FastAPI app, CORS, S3 session, and obtain a chat response
- [Instructor] Here we are initializing a FastAPI application named app. Next in this block of code, we're adding the CORS middleware to the FastAPI application. This is allowing requests from any origin, credential, HTTP methods or headers. Here we are creating AWS S3 session using boto3 with the provided AWS access credentials. The AWS S3 variable holds a session configured with AWS access key, secret key, and region. Next, we're defining a FastAPI endpoint /chat using the HTTP post method. The create_chat_message function is an asynchronous function that handles the /chat endpoint. Next, what we're going to do is we are going to create a chat message and obtain a response based on the user input and the session ID. If it's a new session, we create a new session ID. If it's an existing session, then we add onto the conversation history using the session ID. Let's check out how they do that. So we're going to check…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Setting up MongoDB4m 24s
-
(Locked)
Generate chat responses using GPT-3.5 and Langchain2m 46s
-
(Locked)
Load conversation history for a given session ID1m 16s
-
(Locked)
Create new sessions and add chat history to existing sessions1m 11s
-
(Locked)
Setup FastAPI app, CORS, S3 session, and obtain a chat response3m 43s
-
(Locked)
Upload files to Amazon S3 storage bucket2m 39s
-
(Locked)
Deploy and run the chatbot4m 2s
-
(Locked)
Challenge: Complete the backend code for file upload2m 13s
-
(Locked)
Solution: Complete the backend code for file upload9m 52s
-
(Locked)
-
-