見出し画像

生成エージェントに自律的におしゃべりさせてみる。: 生成エージェントの実装 その2

前回の続きです。

今度は、複数の生成エージェントをつくって、自由に設定したキャラクターでおしゃべりをさせてみます。

各キャラクター設定(吹奏楽団員)

person_a = GenerativeAgent(name="クラ吹き", 
              age=18,
              traits="クラリネット演奏者, 好きな作曲家はモーツアルト, インドア派, 心配性で真面目, 市民吹奏楽団に所属, 好きな食べ物は和食,",
              status="クラリネット用のリードがなくて困っている", # When connected to a virtual world, we can have the characters update their status
              memory_retriever=create_new_memory_retriever(),
              llm=LLM,
              daily_summaries = [
                   "来週の演奏会に向けて、本番用のクラリネット用のリードを調整している。"
               ],
               reflection_threshold = 8, # we will give this a relatively low number to show how reflection works
             )
person_b = GenerativeAgent(name="ユーホ吹き", 
              age=28, 
              traits="ユーホニウム奏者, 面倒見がいい, 市民吹奏楽団に所属, ビール好き, アウトドア派", 
              status="ビールを飲みすぎて太ってしまったので、来週の演奏会に向けて衣装を新調しようと思っている", 
              memory_retriever=create_new_memory_retriever(),
              llm=LLM,
              daily_summaries = [
                  ("来週の演奏会に向けてパート練習をする")
              ],
                reflection_threshold = 7,
             )
person_c = GenerativeAgent(name="団長", 
              age=34, 
              traits="指揮者, 楽天家, おしゃべり好き, 市民吹奏楽団の指揮者, ワイン好き, 洋食派", 
              status="楽団のみんなの相談にのっている", 
              memory_retriever=create_new_memory_retriever(),
              llm=LLM,
              daily_summaries = [
                  ("演奏会のあとの懇親会の計画を考えている")
              ],
                reflection_threshold = 5,
             )

print(person_a.get_summary())
print(person_b.get_summary())
print(person_c.get_summary())

Name: クラ吹き (age: 18) Innate traits: クラリネット演奏者, 好きな作曲家はモーツアルト, インドア派, 心配性で真面目, 市民吹奏楽団に所属, 好きな食べ物は和食, クラ吹き is a term used to describe individuals who play brass instruments in school wind bands in Japan. They are known for their dedication to their craft and their commitment to their bandmates. They often spend long hours practicing and performing, and they value the sense of community and camaraderie that comes with being part of a wind band. Despite the challenges and pressures that come with being a クラ吹き, many individuals find the experience to be rewarding and fulfilling.

Name: ユーホ吹き (age: 28) Innate traits: ユーホニウム奏者, 面倒見がいい, 市民吹奏楽団に所属, ビール好き, アウトドア派 It is not possible to provide a summary without context. Please provide more information or context about ユーホ吹き.

Name: 団長 (age: 34) Innate traits: 指揮者, 楽天家, おしゃべり好き, 市民吹奏楽団の指揮者, ワイン好き, 洋食派 団長 is a responsible and respected leader who values teamwork and fairness. He is also confident and decisive, willing to take risks for the benefit of his group.


def run_conversation(agents: List[GenerativeAgent], initial_observation: str) -> None:
    """Runs a conversation between agents."""
    _, observation = agents[1].generate_reaction(initial_observation)
    print(observation)
    turns = 0
    while True:
        break_dialogue = False
        for agent in agents:
            stay_in_dialogue, observation = agent.generate_dialogue_response(observation)
            print(observation)
            if not stay_in_dialogue:
                break_dialogue = True   
        if break_dialogue:
            break
        turns += 1
agents = [person_a, person_b, person_c]
run_conversation(agents, "団長 said: みんな調子どう? ")

ユーホ吹き ユーホ吹きはうなずいて、笑顔で応えた。

クラ吹き said "ユーホ吹き、何か手伝えることがあったら遠慮なく言ってくださいね。では、また次の練習でお会いしましょう!"

ユーホ吹き said "ありがとうございます、よろしくお願いします!"
団長 said "いい練習ができましたね。また次の練習で頑張りましょう!
クラ吹き said "Thank you, everyone! I have to go buy some reeds now, but I'll see you at the next practice. Take care and keep practicing!"

ユーホ吹き said "See you next time!"
団長 said "Thanks for your hard work today! Keep practicing and let's make the next one even better. See you at the next practice!"

クラリネット吹きにインタビュー

# クラ吹きに質問
interview_agent(person_a, "みんなで何を話していたの?")

クラ吹き said 「今はクラリネット用のリードを買わなければならないので、失礼します。また次の練習でお会いしましょう。」

つ、つれない。(泣)

ユーホ吹きにインタビュー

# ユーホ吹きに質問
interview_agent(person_b, "団長はどんな感じの人ですか?")

ユーホ吹き said "団長はとても親切で、リーダーシップもありますよ。私たちの練習をとてもサポートしてくれています。"

interview_agent(person_b, "今後、どんな曲を演奏したいですか?")

ユーホ吹き said 「私はクラシック音楽が好きなので、もっとクラシックの曲を演奏したいです。でも、他のジャンルの曲も挑戦してみたいですね。」

団長にインタビュー

# 団長に質問
interview_agent(person_c, "今日はこれから何をする予定ですか?")

団長 said "今日は市民吹奏楽祭りの曲目についての打ち合わせがあるので、その準備をしています。でも、今はみんなの相談にのっているところです。"

interview_agent(person_c, "来週の演奏会に向けて意気込みをどうぞ")

団長 said 「ありがとうございます、Hamachi。来週の演奏会はみんなで力を合わせて素晴らしい演奏を届けましょう!」

うーん。もっと各エージェントに事前情報を織り込まないと会話に幅が広がらないのかもです。でも、一応それっぽい会話してもらうことが出来たように思います。おしまい

この記事が参加している募集

#AIとやってみた

28,024件

この記事が気に入ったらサポートをしてみませんか?