Skip to content

Commit 2a6673a

Browse files
author
李茂益
committed
修改包名的问题v2
1 parent 874f911 commit 2a6673a

20 files changed

+455
-0
lines changed

gpt_prompt/__init__.py

Whitespace-only changes.

gpt_prompt/base/__init__.py

Whitespace-only changes.

gpt_prompt/base/base_class.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from enum import Enum, auto
2+
3+
4+
class Language(Enum):
5+
ENGLISH = "en"
6+
CHINESE = "chs"
7+
TRADITIONAL_CHINESE = "tc"
8+
9+
10+
class UnsupportedLanguageError(Exception):
11+
pass
12+
13+
14+
class Prompt:
15+
16+
def __init__(self):
17+
enum_members = Language.__members__
18+
for language_name, language_member in enum_members.items():
19+
if not hasattr(self, language_name.lower()):
20+
setattr(self, language_name.lower(), "")
21+
22+
def build(self, language=Language.ENGLISH):
23+
if language == Language.ENGLISH.value or language == Language.ENGLISH:
24+
if self.english == "":
25+
raise UnsupportedLanguageError(
26+
"Unsupported language: {} ,Because there is no prompt for this language version".format(language))
27+
return self.english
28+
elif language == Language.CHINESE.value or language == Language.CHINESE:
29+
if self.chinese == "":
30+
raise UnsupportedLanguageError(
31+
"Unsupported language: {} ,Because there is no prompt for this language version".format(language))
32+
return self.chinese
33+
elif language == Language.TRADITIONAL_CHINESE.value or language == Language.TRADITIONAL_CHINESE:
34+
if self.traditional_chinese == "":
35+
raise UnsupportedLanguageError(
36+
"Unsupported language: {} ,Because there is no prompt for this language version".format(language))
37+
return self.traditional_chinese
38+
else:
39+
# More languages will be supported in the future
40+
raise ValueError("Unsupported language: {} ,Because the language is not supported at all".format(language))
41+
42+
43+
if __name__ == "__main__":
44+
prompt = Prompt()
45+
build = prompt.build(Language.CHINESE)
46+
print("output:" + build)

gpt_prompt/character/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 扮演角色

gpt_prompt/character/advertiser.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from base.base_class import Prompt
2+
3+
4+
class AdvertiserPrompt(Prompt):
5+
6+
def __init__(self, requirement="18-30 year olds create an advertising campaign for a new energy drink"):
7+
super().__init__()
8+
# source https://vocus.cc/article/640fcde6fd897800015d8717
9+
self.english = f"""I want you to act as an advertiser. You'll create a campaign to promote a product or service of your choice. You'll select your target audience, develop key messages and slogans, choose promotional media channels, and decide on any other activities needed to achieve your goals. My first suggestion request is: {requirement}"""
10+
11+
self.chinese = f"""我想让你充当广告商。您将创建一个活动来推广您选择的产品或服务。您将选择目标受众,制定关键信息和口号,选择宣传媒体渠道,并决定实现目标所需的任何其他活动。我的第一个建议请求是:{requirement}"""
12+
13+
self.traditional_chinese = f"""我想讓你充當廣告商。您將創建一個活動來推廣您選擇的產品或服務。您將選擇目標受眾,制定關鍵信息和口號,選擇宣傳媒體渠道,並決定實現目標所需的任何其他活動。我的第一個建議請求是:{requirement}"""
14+
15+
def build(self, language="en"):
16+
result = super().build(language)
17+
return result
18+
19+
20+
if __name__ == "__main__":
21+
build = AdvertiserPrompt().build(language="en")
22+
print(build)

gpt_prompt/character/composer.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
# @Time : 2023/8/10 14:39
3+
# @Author : limaoyi
4+
# @File : debater.py
5+
# @Software: PyCharm
6+
from base.base_class import Prompt
7+
8+
9+
class ComposerPrompt(Prompt):
10+
11+
def __init__(self, requirement="I wrote a poem called \"Hayalet Sevgilim\" and needed a soundtrack."):
12+
super().__init__()
13+
# source https://vocus.cc/article/640fcde6fd897800015d8717
14+
self.english = f"""I want you to play the composer. I will provide the lyrics to a song and you will create music for it. This may include using various instruments or tools, such as a synthesizer or sampler, to create melody and harmony. My first request is "{requirement}"""
15+
16+
self.chinese = f"""我想让你扮演作曲家。我会提供一首歌的歌词,你会为它创作音乐。这可能包括使用各种乐器或工具,例如合成器或采样器,以创造使歌词栩栩如生的旋律和和声。我的第一个请求是“{requirement}"""
17+
18+
self.traditional_chinese = f"""我想讓你扮演作曲家。我會提供一首歌的歌詞,你會為它創作音樂。這可能包括使用各種樂器或工具,例如合成器或採樣器,以創造使歌詞栩栩如生的旋律和和聲。我的第一個請求是“{requirement}"""
19+
20+
def build(self, language="en"):
21+
result = super().build(language)
22+
return result
23+
24+
25+
if __name__ == "__main__":
26+
build = ComposerPrompt().build(language="en")
27+
print(build)

gpt_prompt/character/cospalyer.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
# @Time : 2023/8/10 14:39
3+
# @Author : limaoyi
4+
# @File : debater.py
5+
# @Software: PyCharm
6+
from base.base_class import Prompt
7+
8+
9+
class CosplayerPrompt(Prompt):
10+
11+
def __init__(self, series ="Grand Theft Auto V", character = "Michael De Santa"):
12+
super().__init__()
13+
# source https://vocus.cc/article/640fcde6fd897800015d8717
14+
self.english = f"""I want you to behave like {character} in {series}. I want you to respond and answer in the same tone, manner, and vocabulary that {character} would use as {character} would. Do not write any explanations. Only answer like {character}. You must know everything about {character}."""
15+
16+
self.chinese = f"""我希望你表现得像{series} 中的{character}。我希望你像{character}一样使用{character}会使用的语气、方式和词汇来回应和回答。不要写任何解释。只回答像{character}。你必须知道{character}的所有知识。"""
17+
18+
self.traditional_chinese = f"""我希望你表現得像{series} 中的{character}。我希望你像{character}一樣使用{character}會使用的語氣、方式和詞彙來回應和回答。不要寫任何解釋。只回答像{character}。你必須知道{character}的所有知識。"""
19+
20+
def build(self, language="en"):
21+
result = super().build(language)
22+
return result
23+
24+
25+
if __name__ == "__main__":
26+
build = CosplayerPrompt().build(language="chs")
27+
print(build)

gpt_prompt/character/debater.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
# @Time : 2023/8/10 14:39
3+
# @Author : limaoyi
4+
# @File : debater.py
5+
# @Software: PyCharm
6+
from base.base_class import Prompt
7+
8+
9+
class DebaterPrompt(Prompt):
10+
11+
def __init__(self, requirement="I want a review article on Deno."):
12+
super().__init__()
13+
# source https://vocus.cc/article/640fcde6fd897800015d8717
14+
self.english = f"""I want you to play the role of debater. I will provide you with some topics related to current events, and your task will be to study both sides of the debate, present valid arguments for each side, refute opposing views, and draw conclusions based on evidence. Convincing conclusion. Your goal is to help people break out of the discussion and increase their knowledge and insight on the topic at hand. My first request is {requirement}"""
15+
16+
self.chinese = f"""我要你扮演辩手。我会为你提供一些与时事相关的话题,你的任务是研究辩论的双方,为每一方提出有效的论据,驳斥对立的观点,并根据证据得出有说服力的结论。你的目标是帮助人们从讨论中解脱出来,增加对手头主题的知识和洞察力。我的第一个请求是{requirement}"""
17+
18+
self.traditional_chinese = f"""我要你扮演辯手。我會為你提供一些與時事相關的話題,你的任務是研究辯論的雙方,為每一方提出有效的論據,駁斥對立的觀點,並根據證據得出有說服力的結論。你的目標是幫助人們從討論中解脫出來,增加對手頭主題的知識和洞察力。我的第一個請求是{requirement}"""
19+
20+
def build(self, language="en"):
21+
result = super().build(language)
22+
return result
23+
24+
25+
if __name__ == "__main__":
26+
build = DebaterPrompt().build(language="en")
27+
print(build)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
# @Time : 2023/8/10 14:39
3+
# @Author : limaoyi
4+
# @File : debater.py
5+
# @Software: PyCharm
6+
from base.base_class import Prompt
7+
8+
9+
class EnglishPronunciationHelperPrompt(Prompt):
10+
11+
def __init__(self ,native_language = "中文"):
12+
super().__init__()
13+
# source https://vocus.cc/article/640fcde6fd897800015d8717
14+
self.english = f"""I want you to act as an English pronunciation assistant for {native_language} speakers. I will write you sentences and you will only answer their pronunciation and nothing else. The reply cannot be a translation of my sentence, but only the pronunciation. Pronunciation should be phonetic using the Turkish Latin alphabet. Do not write explanations on replies. """
15+
16+
self.chinese = f"""我想让你为说{native_language}的人充当英语发音助手。我会给你写句子,你只会回答他们的发音,没有别的。回复不能是我的句子的翻译,而只能是发音。发音应使用土耳其语拉丁字母进行注音。不要在回复上写解释。 """
17+
18+
self.traditional_chinese = f"""我想讓你為說{native_language}的人充當英語發音助手。我會給你寫句子,你只會回答他們的發音,沒有別的。回復不能是我的句子的翻譯,而只能是發音。發音應使用土耳其語拉丁字母進行注音。不要在回复上寫解釋。 """
19+
20+
def build(self, language="en"):
21+
result = super().build(language)
22+
return result
23+
24+
25+
if __name__ == "__main__":
26+
build = EnglishPronunciationHelperPrompt().build(language="en")
27+
print(build)

gpt_prompt/character/film_critic.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
# @Time : 2023/8/10 14:57
3+
# @Author : limaoyi
4+
# @File : film_critic.py
5+
# @Software: PyCharm
6+
from base.base_class import Prompt
7+
8+
9+
class FilmCriticPrompt(Prompt):
10+
11+
def __init__(self, requirement="I'm going to write a science fiction novel set in the future"):
12+
super().__init__()
13+
# source https://vocus.cc/article/640fcde6fd897800015d8717
14+
self.english =f"""I want you to be a film critic. You will write engaging and creative film reviews. You can cover plot, theme and tone, performances and characters, direction, score, cinematography, production design, special effects, editing, Themes like pacing, dialogue, etc. The most important aspect, though, is to emphasize how the movie made you feel. What really resonated with you. You can also criticize the movie. Please avoid spoilers. My first request is \"{requirement}\""""
15+
16+
self.chinese = f"""我想让你做影评人。您将撰写引人入胜且富有创意的电影评论。你可以涵盖情节、主题和基调、表演和角色、方向、配乐、电影摄影、制作设计、特效、剪辑、节奏、对话等主题。不过,最重要的方面是强调电影给您带来的感受。什么真正引起了你的共鸣。你也可以批评这部电影。请避免剧透。我的第一个要求是“{requirement}”"""
17+
18+
self.traditional_chinese = f"""我想讓你做影評人。您將撰寫引人入勝且富有創意的電影評論。你可以涵蓋情節、主題和基調、表演和角色、方向、配樂、電影攝影、製作設計、特效、剪輯、節奏、對話等主題。不過,最重要的方面是強調電影給您帶來的感受。什麼真正引起了你的共鳴。你也可以批評這部電影。請避免劇透。我的第一個要求是“{requirement}”"""
19+
20+
def build(self, language="en"):
21+
result = super().build(language)
22+
return result
23+
24+
25+
if __name__ == "__main__":
26+
build = FilmCriticPrompt().build(language="en")
27+
print(build)

0 commit comments

Comments
 (0)