krishnaacharyaa / wanderlust

WanderLust is a MERN travel blog website 🚀 This project is aimed to help people to contribute in open source, upskill in react and master git.
https://wanderlust-beta.vercel.app/
MIT License
220 stars 1.24k forks source link

[BUG] User Can type anything in title, authorname and description #119

Open krishnaacharyaa opened 7 months ago

krishnaacharyaa commented 7 months ago

Is there an existing issue for this?

Current Behavior

image

Right now there is no checks to validate nor number of chars constraint, people post crazy invalid things.

Expected Behavior

We have to validate these things, and make sure it is proper valid words, may be use AI or regex or any other thing to validate and also restrict the user to use offensive words.

Reproduction steps

1. Create any post with random values
2. It gets created

Screenshots

image

Logs

No response

Browsers

No response

OS

No response

devsharmagit commented 7 months ago

@krishnaacharyaa react hook forms with yup validator can be used

krishnaacharyaa commented 7 months ago

@kami-codes, I just wonder how can we achieve the rightness of the title, description, agreed that you can set constraints, but how can you validate it is a valid title and not just some random title which has no meaning.

devsharmagit commented 7 months ago

@krishnaacharyaa Yes that can't be validated with those. we can only validate like no. of characters, and alphabets only. but cant tell if its meaning full or not.

krishnaacharyaa commented 7 months ago

@kami-codes Can you see if there is any library that will support our use case...

devsharmagit commented 7 months ago

@krishnaacharyaa Sure If i find something I will let you know

jjinendra3 commented 7 months ago

Hey, we can use the yup validator and if it passes that we can use the chatgpt api with step api method, and ask it if the given title and description makes sense, we can ask gpt to provide answers with {success:0/1, message:[feedback if success->0]}. Do LMK your thoughts on this @krishnaacharyaa @kami-codes :)

bajajcodes commented 7 months ago

Hey, we can use the yup validator and if it passes that we can use the chatgpt api with step api method, and ask it if the given title and description makes sense, we can ask gpt to provide answers with {success:0/1, message:[feedback if success->0]}. Do LMK your thoughts on this @krishnaacharyaa @kami-codes :)

@krishnaacharyaa this works. For better use regex only. Do not go into ai/llm mode simply it will be paid, and this product is not in production.

bajajcodes commented 7 months ago

@krishnaacharyaa let's make it challenging do it without using ai/llm.

krishnaacharyaa commented 7 months ago

@jjinendra3, if somehow we can see if the word is there in oxford dictionary, that would be more easy than this regex. What will be the constraint of regex? Can you try on this direction....

jjinendra3 commented 7 months ago

Hey, we can use the yup validator and if it passes that we can use the chatgpt api with step api method, and ask it if the given title and description makes sense, we can ask gpt to provide answers with {success:0/1, message:[feedback if success->0]}. Do LMK your thoughts on this @krishnaacharyaa @kami-codes :)

@krishnaacharyaa this works. For better use regex only. Do not go into ai/llm mode simply it will be paid, and this product is not in production.

Yeah, that's why I suggested the step API method to manage multiple API keys, automatically rotating them once the limit is reached. Acquiring around 5-6 API keys would be good. Regarding the creation of an AI/LLM model, I believe it is beyond the current scope of the project. Additionally, training such a model on Kaggle datasets have its own challenges, as these datasets are not always uptodate. Also, this issue seems temporary, as the project is open-source and still in development. Users are likely testing the website's functionality, and once development is completed, this issue will be resolved automatically. Therefore, relying on the API method for now seems appropriate until the project is fully developed. Do LMK your thoughts on this @bajajcodes :)

krishnaacharyaa commented 7 months ago

@jjinendra3, if somehow we can see if the word is there in oxford dictionary, that would be more easy than this regex. What will be the constraint of regex? Can you try on this direction....

Any leads here?

adititapariya commented 6 months ago

@krishnaacharyaa, can you assign this task to me?

krishnaacharyaa commented 6 months ago

@adititapariya this will be challenging and it can mostly be handled by the react-hook-from issue, which srusti is working on Can you tell me your approach!? and ETA

I just wonder how can we achieve the rightness of the title, description, agreed that you can set constraints, but how can you validate it is a valid title and not just some random title which has no meaning.

if somehow we can see if the word is there in oxford dictionary, that would be more easy than this regex. What will be the constraint of regex? Can you try on this direction....

Around this will be the acceptance criteria

adititapariya commented 6 months ago

@krishnaacharyaa I am currently working on finding a solution for validating posts and restricting offensive content.

I have come across the Perspective API by Google, which offers a free tier for a certain amount of usage before transitioning to a paid model. This API can help detect and filter out offensive content using advanced machine learning models. Additionally, I am exploring completely free options, such as open-source libraries. These libraries can be integrated to provide similar functionality without incurring any costs. Some examples include the bad-words library and leo-profanity for filtering offensive words. Another approach I am considering is using React Hook Form to handle form validation within our React application. React Hook Form provides a flexible and efficient way to manage forms and validate inputs. This approach would involve utilizing React Hook Form to manage the form state and efficiently handle validation rules. I would set up validation rules to ensure content length does not exceed the specified limit (e.g., 500 characters). Additionally, I would integrate a library like bad-words to filter out offensive words from the user input. This combination of tools and techniques will help ensure that user posts are validated for length, character constraints, and filtered for offensive content before submission. I estimate that implementing this solution will take approximately 6-7 days.

krishnaacharyaa commented 6 months ago

@adititapariya thats a good research, much appreciated. But the thing is

  1. we don't have to filter bad words tbh, I'm fine if people curse I am least bothered
  2. The react-hook-from we already have a PR raised, you can see.

The main objective to tell it very very naive and simple is "dfsjdfkjsd askdjfkasjlf" "dkfjskdf" "sdf" These types of words needs to be not valid. Meaning the words which doesn't mean anything shouldn't be allowed Something like a dictionary searching for the title maybe would be effective but yeah you can research. Or openAi wala thing something we have to do

And to take it further, we can remove the posts which contains "simple" "sample test" "demo" kinda title This can be taken in later stages, no problem

adititapariya commented 6 months ago

@krishnaacharyaa Thank you for the feedback. I'll work on other issues as well.

krishnaacharyaa commented 6 months ago

@adititapariya please don't use the AI to this extent, you'll never learn anything, you'll forget typing even. Personal suggestion. Rest is your choice

rushil-b-patel commented 5 months ago

what we can do is create a dictionary of our own or have to find an existing one from where we can validate the inputs. Or the other options goes like this as mentioned above that we need to apply an ai model/ or we can hit an API there to get the response where input is allowed or not...

what way are you suggesting..! @krishnaacharyaa