From 2f62afca606c396d2b4f91751fac2d8b5fc24f70 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Wed, 26 Jul 2023 22:44:12 -0300 Subject: [PATCH] Added GPT-4! --- chatgpt_helper.py | 10 ++++++---- htmls.py | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/chatgpt_helper.py b/chatgpt_helper.py index ec04750..db965bf 100644 --- a/chatgpt_helper.py +++ b/chatgpt_helper.py @@ -10,6 +10,8 @@ from htmls import prompt_html_template logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") +DEFAULT_MODEL = "gpt-4" + def format_message(message: str, role: str) -> list: """ @@ -74,7 +76,7 @@ async def get_random_topic() -> str: """ try: completion = openai.ChatCompletion.create( - model="gpt-3.5-turbo", + model=DEFAULT_MODEL, messages=format_message( "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 " @@ -113,7 +115,7 @@ async def generate_topic_image(topic: str) -> str: """ try: completion = openai.ChatCompletion.create( - model="gpt-3.5-turbo", + model=DEFAULT_MODEL, messages=format_message( f"Generate a prompt for dall-e about {topic}. Use less than 10 words and only return the prompt", "You are a dall-e expert", @@ -157,11 +159,11 @@ async def get_chatgpt_html_response(topic: str = None, count: int = 0) -> str: try: completion = openai.ChatCompletion.create( - model="gpt-3.5-turbo", + model=DEFAULT_MODEL, messages=format_message( f""" You are going to add information to this: {html}. - - Add 5 parragraphs talking about {topic} in the "information-container" div. + - Add 5 parragraphs talking about {topic} in the "information-container" div Add only the information. - Add 5 links for related topics in the "related-topics-container" div. The href should be "/infinite?topic=(slugified_related_topic_name)" and the text should be "(related_topic_name). - Add 5 links for new random topics not related to {topic} in the "new-topics-container" div. The href diff --git a/htmls.py b/htmls.py index f81e311..6e58b51 100644 --- a/htmls.py +++ b/htmls.py @@ -14,6 +14,7 @@ index_html = """