Improved on topic generation and limiting topic sizes
This commit is contained in:
parent
aa4aeb8e21
commit
71f9d1989f
13
app.py
13
app.py
@ -90,8 +90,9 @@ def get_random_topic() -> str:
|
|||||||
completion = openai.ChatCompletion.create(
|
completion = openai.ChatCompletion.create(
|
||||||
model="gpt-3.5-turbo",
|
model="gpt-3.5-turbo",
|
||||||
messages=format_message(
|
messages=format_message(
|
||||||
"Give me a random list of 30 topics to talk about in a comma separated list. Each "
|
"Give me a random list of 10 topics to talk about in a comma separated list. Each topic should be less "
|
||||||
"topic should be less than 5 words long and should not contain commas"
|
"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)
|
topic = request.args.get("topic", None)
|
||||||
if not topic:
|
if not topic:
|
||||||
return redirect("/start")
|
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 "Error! Your topic should be < 5 words"
|
||||||
|
|
||||||
return get_chatgpt_html_response(topic)
|
return get_chatgpt_html_response(unslugified_topic)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user