ChatGPT API¸¦ È£ÃâÇÏ´Â ·ÎÁ÷À» ¾Æ·¡¿Í °°ÀÌ ÇÔ¼ö·Î ¸¸µé°í
def runChatGPT003(prompt, mt): openai.api_key = AccessKey.chatgpt_key
response = openai.Completion.create( model="text-davinci-003", prompt=prompt, temperature=0.7, max_tokens=mt, n=1, stop=None, )
return response.choices[0].text.strip()
Topic¿¡ ´ëÇÑ Category ¸¸µé¾îÁà´Â ´ÙÀ½ ÇÁ·ÒÇÁÆ® »ç¿ëÇß½À´Ï´Ù.
def genCategory(topic_name, num, db_name):
if fetchTopicExistToGen(topic_name, db_name): prompt_temp = f"Select {num} categories for a blog in CSV format without numbering. The topic of blog is" prompt = prompt_temp + " " + topic_name
±×¸®°í °¢ Ä«Å×°í¸®¿¡ ´ëÇÑ ±Û Á¦¸ñ ¸¸µé¾îÁà´Â ´ÙÀ½ ÇÁ·ÒÇÁÆ® »ç¿ëÇÏ°í¿ä
def genArticle(topic_name, cate_name, num, db_name): if fetchCateExistToGen(topic_name, cate_name, db_name): prompt_temp = \ f"Generate {num} articles titles for a blog" \ "Titles are seperated by comma. " \ "The topic of the blog is" prompt = prompt_temp + " " + topic_name + " of " + cate_name + "."
¸¶Áö¸·À¸·Î ±ÛÀ» ½áÁà´Â ´ÙÀ½ ÇÁ·ÒÇÁÆ®¸¦ »ç¿ëÇß½À´Ï´Ù.
±¸Ã¼ÀûÀ¸·Î Àû¾î¾ß ±æ°Ô ÀÛ¼ºÇØÁÖ´õ¶ó±¸¿ä
def fillArticleDB(dbname): # Filling Article Text rows = fetchArticleNoText(dbname)
count = len(rows) index = 0 for article in rows: (topic_name, category_name, article_name) = article
prompt = f"I am going to write a blog post. The post is consist of 12 to 15 paragraph. " \ f"The first is introduction paragraph. The last is conclusion paragraph. " \ f"The middle is body paragraph. Each paragraph is consist of 10 to 15 sentences. " \ f"The topic of the blog post is \"{article_name}\". " \ f"Write the blog post in markdown format in detail as possible."
ÀÌ °á°ú¸¦ DB¿¡ ½×°í WordPress API¸¦ ÀÌ¿ëÇؼ ÀÚµ¿ Æ÷½ºÆÃÇÑ °á°úÀÔ´Ï´Ù.
|