Improved prompt speed and added new topics to the response

This commit is contained in:
Roger Gonzalez 2023-05-13 23:21:17 -03:00
parent 55bcb6d41f
commit 512c0352b3
Signed by: rogs
GPG Key ID: C7ECE9C6C36EC2E6
2 changed files with 11 additions and 3 deletions

8
app.py
View File

@ -59,7 +59,7 @@ def extract_html_from_chatgpt_response(returned_string: str) -> Union[str, None]
validator = HTMLParser(strict=True)
try:
validator.parse(returned_string)
logging.info("Valid HTML Found")
logging.info(f"Valid HTML Found! {returned_string}")
return returned_string
except Exception:
match = returned_string.split("<html>")
@ -134,9 +134,11 @@ def get_chatgpt_html_response(message: str) -> str:
(
f"Give me information about {message}. Now, given this HTML: \n {prompt_html_template} \n replace "
"(topic) with the name of the selected topic and (topic_info) with 5 parragraphs talking about the "
"topic. Replace (related_links) with 10 links related to the topic. For these links, the href "
"topic. Replace (related_links) with 5 links related to the topic. For these links, the href "
"should be '/infinite?topic=(slugified_related_topic_name)' and the text should be the name of the "
"related topic. The name of these topics should not be more than 5 words. Respond only the code"
"related topic. The name of these topics should not be more than 5 words. Finally, replace "
"(new_topics) with a 5 links with completely new and random topics to talk about. These links "
"should follow the same rules as before. Respond only the code"
)
),
)

View File

@ -34,6 +34,12 @@ prompt_html_template = """
(related_links)
</ul>
</div>
<div class="new-topics-container">
<h2>New Topics:</h2>
<ul>
(new_links)
</ul>
</div>
</body>
</html>
"""