karwanjiru commited on
Commit
339e3fb
1 Parent(s): 656a88a
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -19,18 +19,14 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
19
 
20
  messages.append({"role": "user", "content": message})
21
 
22
- response = ""
23
-
24
- for message in client.chat_completion(
25
  messages,
26
  max_tokens=max_tokens,
27
- stream=True,
28
  temperature=temperature,
29
  top_p=top_p,
30
- ):
31
- token = message.choices[0].delta.content
32
- response += token
33
- yield response
34
 
35
  # Define the function to generate posts
36
  def generate_post(prompt, max_tokens, temperature, top_p):
@@ -44,7 +40,7 @@ def generate_post(prompt, max_tokens, temperature, top_p):
44
 
45
  # Define the function to moderate posts
46
  def moderate_post(post):
47
- # Placeholder for actual moderation logic
48
  if "inappropriate" in post:
49
  return "Post does not adhere to community guidelines."
50
  return "Post adheres to community guidelines."
@@ -63,7 +59,7 @@ def moderate_image(image):
63
  image.save(buffered, format="JPEG")
64
  image_bytes = buffered.getvalue()
65
 
66
- # Placeholder URL for an image moderation API
67
  moderation_api_url = "https://example.com/moderation/api"
68
 
69
  # Send the image to the moderation API
 
19
 
20
  messages.append({"role": "user", "content": message})
21
 
22
+ response = client.chat_completion(
 
 
23
  messages,
24
  max_tokens=max_tokens,
 
25
  temperature=temperature,
26
  top_p=top_p,
27
+ )
28
+
29
+ return response.choices[0].message['content']
 
30
 
31
  # Define the function to generate posts
32
  def generate_post(prompt, max_tokens, temperature, top_p):
 
40
 
41
  # Define the function to moderate posts
42
  def moderate_post(post):
43
+ # Implement your post moderation logic here
44
  if "inappropriate" in post:
45
  return "Post does not adhere to community guidelines."
46
  return "Post adheres to community guidelines."
 
59
  image.save(buffered, format="JPEG")
60
  image_bytes = buffered.getvalue()
61
 
62
+ # Replace with your actual image moderation API endpoint
63
  moderation_api_url = "https://example.com/moderation/api"
64
 
65
  # Send the image to the moderation API