ed-roh / chat-app Goto Github PK
View Code? Open in Web Editor NEWBuild a Chat App with ChatGPT
Build a Chat App with ChatGPT
i am recieving a 404 error when i signup
index.jsx:16
POST http://localhost:5185/auth/signup 404 (Not Found)
while index.jsx :16 is const handleRegister = () => {
triggerSignUp( {username, password });
};
Hi, i am a new react devloper so i am facing a small issue . I have copied your code word to word till 01:06:01 mins in your youtube video but when i type a message in it ,it doesn't get saved in the chat
the error i am getting is
POST https://api.chatengine.io/chats/149632/messages/ 500
at createError (createError.js:16:15)
at settle (settle.js:17:12)
at XMLHttpRequest.onloadend (xhr.js:66:7)
but in the video you are not facing this type of issue rn,
so please help if you can.
Thanks!
Tried to swap out node.js for FastAPI as there are some additional business logic thats currently only in Python:
server-fastapi/routers/auth.py
import logging
from fastapi import APIRouter, Request
from pydantic import BaseModel
from typing import Union
import requests
router = APIRouter(prefix="/auth",
tags=["auth"],
responses={404: {"description": "Not found"}}
)
class User(BaseModel):
username: str
secret: str
email: Union[str, None] = None
first_name: Union[str, None] = None
last_name: Union[str, None] = None
@router.post("/login")
async def login(user: User):
payload={}
response = requests.get('https://api.chatengine.io/users/me',
headers={
"Content-Type": "application/json",
"Project-ID": <MY_PROJECT_ID>,
"User-Name": user.username,
"User-Secret": user.secret
},
data=payload
)
logging.info("response: {}".format(response))
logging.info("type(response): {}".format(type(response)))
return response.json()
@router.post("/signup")
async def signup(user: User):
response = requests.post('https://api.chatengine.io/users/',
data={
"username": user.username,
"secret": user.secret,
"email": user.email,
"first_name": user.first_name,
"last_name": user.last_name,
},
headers={ "Private-Key": PRIVATE_KEY }
)
return {"response": response.json()}
server-fastapi/main.py
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
# pip install "uvicorn[standard]"
from pydantic import BaseModel
from typing import Union
import requests
from routers import auth, openai
app = FastAPI()
origins = [
"http://localhost:5173",
]
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(auth.router)
app.include_router(openai.router)
cd server-fastapi
uvicorn main:app --reload --port 1337
Status code 422:
But
FastAPI Swagger /auth/login works
as well as standalone test_login.py as well as in Isomnia
import requests
url = "https://api.chatengine.io/users/me/"
payload={}
headers = {
'Project-ID': '<MY_PROJECT>',
'User-Name': 'testUser',
'User-Secret': 'testUser'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.json())
So not sure why 422 when trying to authenticate with FastAPI fails:
Failed to load resource: the server responded with a status of 422 (Unprocessable Entity) and No resource with given URL found.
Is this related to how payload must be altered in the client/src/state/api.js payload?
I am a new developer and I am seeing an error which states that "import { Configuration, OpenAIApi } from "openai"; SyntaxError: The requested module 'openai' does not provide an export named 'Configuration' "
This import is done in ./server/index.js
Can you please help me out with this error? Why is it showing? I have checked each line of code and there's no mistake in the code.
Hi ) I am not nodejs-developer but I watched your great learning video with big interest :)
Ed-Roh, I want to express "thank you for the great chat-app example" :)
After "movie watch" I tried to redevelop your chatgpt project onto c# mini-project but I catched epic fail (chatgpt not available at my country, some geo-blocking, etc.). I tried to use the sk-key from your video: sk-zkk2S....yOMn
but I noticed that Api-key you temporary generated was blocked (obsolete) , heh.
So sad/too bad :)
Cheers up,
[m][e]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.