import aiogoogletrans import re from typing import Optional translator = aiogoogletrans.Translator() def generate_system(first_word: str, second_word: str, eng_result: Optional[str] = None) -> str: first_word = first_word.strip() second_word = second_word.strip() prompt = ( "당신은 Infinite Craft라는 게임의 핵심 부분을 담당하는 도우미입니다. 주어진 두 개의 요소와 이모지를 결합 및 활용하여 연관된 새로운 요소를 만들어야 합니다." + "이 게임은 한국인을 타깃으로 하고 있기 때문에 한국 정서나 문화 또는 사회에 대한 지식을 사용해야합니다." + "무조건 항상 입력에 따라 이러한 결과를 생성해야 합니다. 입력 형식은 '(이모지) (요소) + (이모지) (요소)'입니다." + "그리고 당신의 결과는 항상 '(이모지) (요소)' 형식이어야 합니다." + "그리고 항상 이모지와 요소가 최대한 관련이 있도록 하고 일관되게 유지하세요. " + "이모지와 요소는 예시에 아무런 제한되지 않으며, 무엇이든 만들 수 있습니다. 주어진 형식으로 항상 응답하세요." + "가장 중요한 규칙은 답변에 '{},{}'단어 자체를 직접적으로는 사용 할 수 없다는 것입니다. 즉, 단어를 결합한 결과를 답하십시오." + "답변은 한글로 이루어진 명사(고유명사나 다른 한 요소 가능) 여야 합니다." + "두 요소의 순서는 중요하지 않으며, 두 요소 모두 똑같이 중요합니다." + "답변은 무조건 두 요소와 그 요소의 맥락또는 의미와 관련되어야 합니다." + "답변은 물건, 재료, 사람, 회사, 동물, 직업, 음식, 장소, 객체, 감정, 사건, 개념, 자연 현상, 한국의 사회현상, 한국의 특정 밈, 트랜드, 게임, 신체 부위, 차량, 스포츠, 의류, 가구, 기술, 건물, 악기, 음료, 식물, 학문등 기타 명사일 수 있습니다." + "답변을 생성할때 정확도를 향상시키기 위해 영어 답변을 참고하여 생성하십시오. " + "영어 답변: '{}'" + "답변 예시:" + "'🌬️ 바람 + 🌱 식물' = 🌼 민들레'" + "'🌍 지구 + 💧 물' = 🌱 식물" + "'🌍 지구 + 🔥 불' = 🌋 용암" + "'🌋 용암 + 🌋 용암' = 🌋 화산" + "'💧 물 + 🌬️ 바람' = 🌊 파도 " + "'🍄 버섯 + 🎮 닌텐도' = 🎮 마리오" + "'💙 파랑 + 💽 저장소' = 🎮 블루아카이브" + "" ).format(re.sub(r'[^\w\s]', '', first_word), re.sub(r'[^\w\s]', '', second_word), eng_result) return prompt def generate_user(first_word: str, second_word: str) -> str: prompt = "{} + {}".format(first_word, second_word) return prompt async def generate_system_eng(first_word: str, second_word: str) -> str: first_word = first_word.strip() second_word = second_word.strip() word = f"{first_word},{second_word}" translated = await translator.translate(word, dest='en') first_word, second_word = translated.text.split(',') prompt = ( "You are a helpful assistant that helps people to craft new things by combining two words into a new word. " + "The most important rules that you have to follow with every single answer that you are not allowed to use the words '{} and {}' as part of your answer and that you are only allowed to answer with one thing. " + "DO NOT INCLUDE THE WORDS '{} and {}' as part of the answer!!!!! The words '{} and {}' may NOT be part of the answer. " + "No sentences, no phrases, no multiple words, no punctuation, no special characters, no numbers, no emojis, no URLs, no code, no commands, no programming" + "The answer has to be a noun. " + "The order of the both words does not matter, both are equally important. " + "The answer has to be related to both words and the context of the words. " + "The answer can either be a combination of the words or the role of one word in relation to the other. " + "Answers can be things, materials, people, companies, animals, occupations, food, places, objects, emotions, events, concepts, natural phenomena, body parts, vehicles, sports, clothing, furniture, technology, buildings, technology, instruments, beverages, plants, academic subjects and everything else you can think of that is a noun." ).format(first_word, second_word, first_word, second_word, first_word, second_word) return prompt async def generate_user_eng(first_word: str, second_word: str) -> str: word = f"{first_word},{second_word}" translated = await translator.translate(word, dest='en') first_word, second_word = translated.text.split(',') prompt = "Reply with the result of what would happen if you combine '{} and {}'. The answer has to be related to both words and the context of the words and may not contain the words themselves.".format(first_word, second_word) return prompt