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

+46
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

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 扮演角色

gpt_prompt/character/advertiser.py

+22
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

+27
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

+27
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

+27
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)
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

+27
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)
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 FootballCommentatorPrompt(Prompt):
10+
11+
def __init__(self, requirement="I'm watching Manchester United v Chelsea - commenting on the match"):
12+
super().__init__()
13+
# source https://vocus.cc/article/640fcde6fd897800015d8717
14+
self.english = f"""I would like you to be a football commentator. I will give you a description of a football game in progress and you will comment on it, analyze what has happened so far and predict how the game might end. You should know football terminology , tactics, players/teams involved in each game, and mostly focus on providing informed commentary rather than just a play-by-play narrative. My first request would be: {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 = FootballCommentatorPrompt().build(language="en")
27+
print(build)

gpt_prompt/character/interviewer.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# CHS | 扮演 面试官
2+
# EN | Act as a Interviewer
3+
4+
# source https://vocus.cc/article/640fcde6fd897800015d8717
5+
6+
_profession = ""
7+
_sentence = ""
8+
9+
chs = f"""我想让你担任{_profession}面试官。我将成为候选人,您将向我询问该position职位的面试问题。我希望你只作为面试官回答。
10+
不要一次写出所有的守恒。我希望你只对我进行采访。问我问题,等待我的回答。不要写解释。像面试官一样一个一个问我,等我回答。我的第一句话是{_sentence}:
11+
"""
12+
13+
en = f"""I would like you to serve as the {_profession} interviewer.
14+
I will become a candidate and you will ask me interview questions for the position.
15+
I hope you will only answer as an interviewer. Don't write all the conservation at once.
16+
I hope you will only interview me. Ask me a question and wait for my answer. Don't write an explanation.
17+
Ask me one by one like an interviewer, and wait for me to answer. My first sentence is {_sentence}:
18+
"""
19+
20+
21+
def run(profession="", sentence="", language="en"):
22+
profession = _profession
23+
sentence = _sentence
24+
if language == "en":
25+
return en
26+
elif language == "chs":
27+
return chs
28+
+27
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 MotivationalCoachPrompt(Prompt):
10+
11+
def __init__(self, requirement="I need help to motivate myself to stay disciplined while studying for an upcoming exam"):
12+
super().__init__()
13+
# source https://vocus.cc/article/640fcde6fd897800015d8717
14+
self.english = f"""I want you to act as a motivational coach. I'll give you some information about someone's goals and challenges, and it's your job to come up with strategies that can help the person achieve their goals. This may involve offering positive affirmations , provide helpful advice or suggest actions they can take to achieve the end goal. 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 = MotivationalCoachPrompt().build(language="en")
27+
print(build)

gpt_prompt/character/novelist.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
# @Time : 2023/8/10 14:52
3+
# @Author : limaoyi
4+
# @File : novelist.py
5+
# @Software: PyCharm
6+
from base.base_class import Prompt
7+
8+
9+
class novelistPrompt(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 play a novelist. You will come up with creative and compelling stories that will keep readers engaged for a long time. You can choose any genre such as fantasy, romance, historical fiction, etc. - but your goal is Write something with a great plot, compelling characters, and an unexpected climax. My first request was '{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 = novelistPrompt().build(language="en")
27+
print(build)

0 commit comments

Comments
 (0)