diff --git a/app.py b/app.py index d1bcd08..7116383 100644 --- a/app.py +++ b/app.py @@ -90,8 +90,9 @@ def get_random_topic() -> str: completion = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=format_message( - "Give me a random list of 30 topics to talk about in a comma separated list. Each " - "topic should be less than 5 words long and should not contain commas" + "Give me a random list of 10 topics to talk about in a comma separated list. Each topic should be less " + "than 5 words long and should not contain commas. Be as creative as possible and choose topics from " + "multiple genres and industries." ), ) @@ -168,7 +169,11 @@ def topic(): topic = request.args.get("topic", None) if not topic: return redirect("/start") - if len(topic.split("_")) > 5: + + unslugified_topic = topic.replace("-", " ").replace("_", " ").replace("%20", " ").replace("\n", " ") + + if len(unslugified_topic.split()) > 5: + logging.info(f"The topic is too long: {unslugified_topic}") return "Error! Your topic should be < 5 words" - return get_chatgpt_html_response(topic) + return get_chatgpt_html_response(unslugified_topic)