Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -51,8 +51,8 @@ async def ask(ctx, *, question: str):
|
|
51 |
"""
|
52 |
Command to ask a question to the Hugging Face model with an instructive prompt.
|
53 |
"""
|
54 |
-
# Create a structured prompt
|
55 |
-
prompt = f"
|
56 |
response = query_huggingface(prompt)
|
57 |
|
58 |
generated_text = None
|
@@ -62,8 +62,10 @@ async def ask(ctx, *, question: str):
|
|
62 |
generated_text = response[0]['generated_text']
|
63 |
|
64 |
if generated_text:
|
65 |
-
#
|
66 |
-
|
|
|
|
|
67 |
if contains_forbidden_content(generated_text):
|
68 |
await ctx.send("Sorry, the response contains inappropriate content and cannot be displayed.")
|
69 |
else:
|
@@ -73,3 +75,4 @@ async def ask(ctx, *, question: str):
|
|
73 |
|
74 |
# Run the bot
|
75 |
bot.run(DISCORD_TOKEN)
|
|
|
|
51 |
"""
|
52 |
Command to ask a question to the Hugging Face model with an instructive prompt.
|
53 |
"""
|
54 |
+
# Create a structured prompt with a unique separator
|
55 |
+
prompt = f"Please provide a detailed and appropriate response to the following question: {question} ###"
|
56 |
response = query_huggingface(prompt)
|
57 |
|
58 |
generated_text = None
|
|
|
62 |
generated_text = response[0]['generated_text']
|
63 |
|
64 |
if generated_text:
|
65 |
+
# Remove the prompt part, using the separator to ensure we only get the response
|
66 |
+
if "###" in generated_text:
|
67 |
+
generated_text = generated_text.split("###")[1].strip()
|
68 |
+
|
69 |
if contains_forbidden_content(generated_text):
|
70 |
await ctx.send("Sorry, the response contains inappropriate content and cannot be displayed.")
|
71 |
else:
|
|
|
75 |
|
76 |
# Run the bot
|
77 |
bot.run(DISCORD_TOKEN)
|
78 |
+
|