Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
thatbeautifuldream committed May 3, 2024
2 parents f67dff9 + 4fc9485 commit 43d5cd6
Showing 1 changed file with 71 additions and 1 deletion.
72 changes: 71 additions & 1 deletion src/components/flow-components/generator-controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from "@/components/ui/select";
import { Visibility } from "@prisma/client";
import { UseMutateFunction } from "@tanstack/react-query";
import { AxiosError } from "axios";
import axios, { AxiosError } from "axios";
import { Save, Trash } from "lucide-react";
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
Expand Down Expand Up @@ -111,6 +111,76 @@ export const GeneratorControls = (props: Props) => {
});
}

const profanityQuery = `Checking for profanity in ${query}`;

const { data, status } = await axios.post(
"https://vector.profanity.dev",
{
message: profanityQuery,
},
);

console.log("res from profanity api", data.isProfanity);

if (
data.isProfanity === true ||
query.includes(
"bomb" ||
"bombing" ||
"explosive" ||
"terrorist" ||
"terrorism" ||
"assassin" ||
"assassination" ||
"hate" ||
"hatecrime" ||
"murder" ||
"killing" ||
"violence" ||
"weapon" ||
"gun" ||
"firearm" ||
"drug" ||
"illegal" ||
"porn" ||
"pornography" ||
"hack" ||
"hacking" ||
"virus" ||
"malware" ||
"spam" ||
"scam" ||
"fraud" ||
"cheat" ||
"threat" ||
"offensive" ||
"inappropriate" ||
"obscene" ||
"explicit" ||
"unethical" ||
"unlawful" ||
"corruption" ||
"bribery" ||
"discrimination" ||
"harassment" ||
"bullying" ||
"intimidation" ||
"stalking" ||
"privacy" ||
"confidentiality" ||
"security" ||
"fraudulent" ||
"deceptive" ||
"misleading",
)
) {
return toast.error("Error", {
description:
"Cannot generate a roadmap for this query. Please try again with a different query.",
duration: 4000,
});
}

const userCredits = await userHasCredits();
if (!userCredits && modelApiKey === "") {
return toast.error("You don't have enough credits", {
Expand Down

0 comments on commit 43d5cd6

Please sign in to comment.