jbilcke-hf HF staff commited on
Commit
7062da0
β€’
1 Parent(s): 1416ce3

fixing bug with the community engine

Browse files
Files changed (1) hide show
  1. src/app/engine/community.ts +6 -2
src/app/engine/community.ts CHANGED
@@ -3,6 +3,7 @@
3
  import { v4 as uuidv4 } from "uuid"
4
 
5
  import { CreatePostResponse, GetAppPostsResponse, Post, PostVisibility } from "@/types"
 
6
 
7
  const apiUrl = `${process.env.COMMUNITY_API_URL || ""}`
8
  const apiToken = `${process.env.COMMUNITY_API_TOKEN || ""}`
@@ -15,6 +16,9 @@ export async function postToCommunity({
15
  prompt: string
16
  assetUrl: string
17
  }): Promise<Post> {
 
 
 
18
  // if the community API is disabled,
19
  // we don't fail, we just mock
20
  if (!apiUrl) {
@@ -42,7 +46,7 @@ export async function postToCommunity({
42
  }
43
 
44
  try {
45
- console.log(`calling POST ${apiUrl}/post with prompt: ${prompt}`)
46
 
47
  const postId = uuidv4()
48
 
@@ -50,7 +54,7 @@ export async function postToCommunity({
50
 
51
  console.table(post)
52
 
53
- const res = await fetch(`${apiUrl}/post`, {
54
  method: "POST",
55
  headers: {
56
  Accept: "application/json",
 
3
  import { v4 as uuidv4 } from "uuid"
4
 
5
  import { CreatePostResponse, GetAppPostsResponse, Post, PostVisibility } from "@/types"
6
+ import { filterOutBadWords } from "./censorship"
7
 
8
  const apiUrl = `${process.env.COMMUNITY_API_URL || ""}`
9
  const apiToken = `${process.env.COMMUNITY_API_TOKEN || ""}`
 
16
  prompt: string
17
  assetUrl: string
18
  }): Promise<Post> {
19
+
20
+ prompt = filterOutBadWords(prompt)
21
+
22
  // if the community API is disabled,
23
  // we don't fail, we just mock
24
  if (!apiUrl) {
 
46
  }
47
 
48
  try {
49
+ console.log(`calling POST ${apiUrl}/posts/${appId} with prompt: ${prompt}`)
50
 
51
  const postId = uuidv4()
52
 
 
54
 
55
  console.table(post)
56
 
57
+ const res = await fetch(`${apiUrl}/posts/${appId}`, {
58
  method: "POST",
59
  headers: {
60
  Accept: "application/json",