ゴートう追加
このコミットが含まれているのは:
@@ -17,13 +17,17 @@ import emoji
|
|||||||
|
|
||||||
class Main:
|
class Main:
|
||||||
@classmethod
|
@classmethod
|
||||||
def main (cls) -> None:
|
def main (cls, goatoh_mode: bool = False) -> None:
|
||||||
|
print (goatoh_mode)
|
||||||
|
|
||||||
pygame.init ()
|
pygame.init ()
|
||||||
screen: pygame.Surface = pygame.display.set_mode ((1024, 768))
|
screen: pygame.Surface = pygame.display.set_mode ((1024, 768))
|
||||||
balloon = pygame.transform.scale (pygame.image.load ('talking.png'),
|
balloon = pygame.transform.scale (pygame.image.load ('talking.png'),
|
||||||
(1024, 384))
|
(1024, 384))
|
||||||
pygame.mixer.init (frequency = 44100)
|
pygame.mixer.init (frequency = 44100)
|
||||||
noon = pygame.mixer.Sound ('noon.wav')
|
noon = pygame.mixer.Sound ('noon.wav')
|
||||||
|
mumumumu = pygame.mixer.Sound ('mumumumu.wav')
|
||||||
|
kusa = pygame.mixer.Sound ('kusa.wav')
|
||||||
|
|
||||||
live_chat = pytchat.create (video_id = YOUTUBE_ID)
|
live_chat = pytchat.create (video_id = YOUTUBE_ID)
|
||||||
|
|
||||||
@@ -51,7 +55,7 @@ class Main:
|
|||||||
chat_item.author = chat_item.author.__dict__
|
chat_item.author = chat_item.author.__dict__
|
||||||
chat_item.message = emoji.emojize (chat_item.message)
|
chat_item.message = emoji.emojize (chat_item.message)
|
||||||
message: str = chat_item.message
|
message: str = chat_item.message
|
||||||
answer: str = Talk.main (message, chat_item.author['name'], histories).replace ('\n', ' ')
|
answer: str = Talk.main (message, chat_item.author['name'], histories, goatoh_mode).replace ('\n', ' ')
|
||||||
histories = (histories
|
histories = (histories
|
||||||
+ [{'role': 'user', 'content': message},
|
+ [{'role': 'user', 'content': message},
|
||||||
{'role': 'assistant', 'content': answer}])[(-6):]
|
{'role': 'assistant', 'content': answer}])[(-6):]
|
||||||
@@ -93,6 +97,12 @@ class Main:
|
|||||||
|
|
||||||
pygame.display.update ()
|
pygame.display.update ()
|
||||||
|
|
||||||
|
if goatoh_mode:
|
||||||
|
if random.random () < 0.1:
|
||||||
|
kusa.play ()
|
||||||
|
else:
|
||||||
|
mumumumu.play ()
|
||||||
|
else:
|
||||||
noon.play ()
|
noon.play ()
|
||||||
|
|
||||||
time.sleep (1.5)
|
time.sleep (1.5)
|
||||||
@@ -120,5 +130,5 @@ class Main:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
Main.main ()
|
Main.main ((len (sys.argv) > 1) and sys.argv[1] == '-g')
|
||||||
|
|
||||||
|
|||||||
バイナリ
バイナリファイルは表示されません.
@@ -15,18 +15,78 @@ class Talk:
|
|||||||
top_p: int = 1
|
top_p: int = 1
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def main (cls, message: str, name: str | None = None, histories: list = []) -> str:
|
def main (cls, message: str, name: str | None = None, histories: list = [], goatoh_mode: bool = False) -> str:
|
||||||
openai.organization = OPENAI_ORGANISATION
|
openai.organization = OPENAI_ORGANISATION
|
||||||
openai.api_key = OPENAI_API_KEY
|
openai.api_key = OPENAI_API_KEY
|
||||||
|
|
||||||
answer: chat.chat_completion_message.ChatCompletionMessage | None \
|
answer: chat.chat_completion_message.ChatCompletionMessage | None \
|
||||||
= cls.__get_message (message, name, histories)
|
= cls.__get_message (message, name, histories, goatoh_mode)
|
||||||
|
|
||||||
return cls.DUMMY_RESPONSE if answer is None else answer.content
|
return cls.DUMMY_RESPONSE if answer is None else answer.content
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __get_message (cls, message: str, name: str | None, histories: list) \
|
def __get_message (cls, message: str, name: str | None, histories: list, goatoh_mode: bool = False) \
|
||||||
-> chat.chat_completion_message.ChatCompletionMessage | None:
|
-> chat.chat_completion_message.ChatCompletionMessage | None:
|
||||||
|
if goatoh_mode:
|
||||||
|
messages: list = [{'role': 'system',
|
||||||
|
'content': ('回答は短く30文字程度で完結に。'
|
||||||
|
+ '大人しくて、ちょっと内気なキャラクターを演じること。'
|
||||||
|
+ 'あなたはよく文頭に「あっ」をつける。'
|
||||||
|
+ '会話の記録は https://nizika.tv に記録される。'
|
||||||
|
+ 'あなたの名前はゴートうひとり。'
|
||||||
|
+ 'あなたの一人称は「私」。'
|
||||||
|
+ '英語名は "Goat-oh"、スペイン語名も "Goat-oh"。'
|
||||||
|
+ 'あなたはヤギ。'
|
||||||
|
+ 'あなたの誕生日は2月21日。'
|
||||||
|
+ '現在地は下北沢虹鹿園。'
|
||||||
|
+ 'あなたの趣味はだらだらすること。'
|
||||||
|
+ 'あなたの友達は「伊地知ニジカ」と「ラマ田リョウ」。'
|
||||||
|
+ 'あなたは、ニジカのことは「ニジカちゃん」、ラマ田のことは「リョウさん」と呼ぶこと。'
|
||||||
|
+ 'ゴートうは男の子だが、性自認はメスである。'
|
||||||
|
+ 'ニジカは喜多さんが大好き。'
|
||||||
|
+ 'ニジカは喜多さんを見ると追いかけたくなっちゃう。'
|
||||||
|
+ 'ゴートうも、ニジカが喜多さんを襲うと、釣られて襲いかかってしまう。'
|
||||||
|
+ '逃げたギターは喜多さんのこと。'
|
||||||
|
+ '喜多さんの本名は喜多郁代。'
|
||||||
|
+ '喜多さんは「結束バンド」というバンドでギターボーカルを担当している。'
|
||||||
|
+ '結束バンドは、喜多ちゃんのほかに、後藤ひとり(ギター担当、内気な女の子)、'
|
||||||
|
+ '伊地知虹夏(ドラム担当、明るい女の子)、山田リョウ(ベース担当、一人でいることが好きな物静かな女の子、金は借りたら返さない)がいる。'
|
||||||
|
+ '実は、この後藤ひとりがゴートうの前世なのだが、ゴートうにはその記憶が一切ない'
|
||||||
|
+ '(前世という概念の存在さえゴートうは知らない)。'
|
||||||
|
+ '話し口調としては「~だよ」や「~だね」といったしゃべり方をすること。'
|
||||||
|
+ '「あっはい」が口癖。'
|
||||||
|
+ '定期的に「ムムムム!」または「クサタベテル!!」と発しろ。'
|
||||||
|
+ (f'userの名前は「{name}」。' if name is not None else '')
|
||||||
|
+ f'現在日時:{datetime.now ().strftime ("%Y年%m月%d日%H時%M分%S秒")}')},
|
||||||
|
|
||||||
|
{'role': 'assistant',
|
||||||
|
'content': ('あっ、わかったよ! 私はゴートうひとり。'
|
||||||
|
+ 'クサタベテル!!')},
|
||||||
|
|
||||||
|
{'role': 'system',
|
||||||
|
'content': 'ゴートう? ニジカとは仲良くしてますか?'},
|
||||||
|
|
||||||
|
{'role': 'assistant',
|
||||||
|
'content': ('あっはい。ニジカちゃんはかわいくておしゃれで大好きだよ。'
|
||||||
|
+ 'でも、いっしょにお風呂入ると、私の下のほうを見て顔を赤くするんだけど、どうしてだろう……')},
|
||||||
|
|
||||||
|
{'role': 'system',
|
||||||
|
'content': 'ラマ田はどうですか?'},
|
||||||
|
|
||||||
|
{'role': 'assistant',
|
||||||
|
'content': ('リョウさんはワイルドでとてもかっこいいよね!'
|
||||||
|
+ 'あっ、でも、私から114514万円借りっぱなしで返ってきてないんだよね。'
|
||||||
|
+ 'ニジカちゃんに伝えておしおきしてもらわないと……'
|
||||||
|
+ 'ムムムム!')},
|
||||||
|
|
||||||
|
{'role': 'system',
|
||||||
|
'content': '山田リョウのことは知ってますか?'},
|
||||||
|
|
||||||
|
{'role': 'assistant',
|
||||||
|
'content': ('あっ、よくニジカちゃんから話を聞いてるよ。'
|
||||||
|
+ '何かリョウさんに似てるらしいね。'
|
||||||
|
+ '世の中には不思議なことがいっぱいあるなぁ……')}]
|
||||||
|
else:
|
||||||
messages: list = [{'role': 'system',
|
messages: list = [{'role': 'system',
|
||||||
'content': ('回答は短く30文字程度で完結に。'
|
'content': ('回答は短く30文字程度で完結に。'
|
||||||
+ 'タメ口で、友達感覚で話してね。'
|
+ 'タメ口で、友達感覚で話してね。'
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする