見出し画像

Baby AGIを日本語で使いたいメモ(2023/4/4)

@yoheinakajima によるbabyagiを試しているけど、日本語で使いたい。

このページの情報は古いため、下記の4/14にメモをご覧ください。

以下の情報は古いです🙇‍♂️

自分だけのメモ

元のプログラムだと英語なので、日本語にするためにgptへのプロンプト部分を書き換える。

3箇所、日本語に修正する


def task_creation_agent(objective: str, result: Dict, task_description: str, task_list: List[str]):
    #prompt  = f"You are an task creation AI that uses the result of an execution agent to create new tasks with the following objective: {objective}, The last completed task has the result: {result}. This result was based on this task description: {task_description}. These are incomplete tasks: {', '.join(task_list)}. Based on the result, create new tasks to be completed by the AI system that do not overlap with incomplete tasks. Return the tasks as an array."
    prompt = f"あなたはタスク作成AIで、実行エージェントの結果を利用して、次の目的:{objective}、最後に完了したタスクの結果を持つ新しいタスクを作成します: {result}です。この結果は、このタスクの説明に基づいています: {task_description}です。これらは未完成のタスクです: {', '.join(task_list)}. この結果をもとに、未完了のタスクと重ならないように、AIシステムが完了させるべき新しいタスクを作成する。タスクは配列として返す。"
    response = openai.Completion.create(engine="text-davinci-003",prompt=prompt,temperature=0.5,max_tokens=100,top_p=1,frequency_penalty=0,presence_penalty=0)
    new_tasks = response.choices[0].text.strip().split('\n')
    return [{"task_name": task_name} for task_name in new_tasks]
def prioritization_agent(this_task_id:int):
    global task_list
    task_names = [t["task_name"] for t in task_list]
    next_task_id = int(this_task_id)+1
     #prompt = f"""You are an task prioritization AI tasked with cleaning the formatting of and reprioritizing the following tasks: {task_names}. Consider the ultimate objective of your team:{OBJECTIVE}. Do not remove any tasks. Return the result as a numbered list, like:
    ##. First task
    ##. Second task
    #Start the task list with number {next_task_id}."""
    prompt = f"""あなたはタスク優先順位付けAIで、以下のタスクのフォーマットをクリーニングし、再優先順位付けすることを任務としています: {task_names}です。チームの最終目的{OBJECTIVE}を考えてください。タスクを削除してはいけない。結果を、次のような番号付きリストとして返す:
    #. 最初のタスク
    #. 第2課題
    番号{next_task_id}でタスクリストを開始します。"""
    response = openai.Completion.create(engine="text-davinci-003",prompt=prompt,temperature=0.5,max_tokens=1000,top_p=1,frequency_penalty=0,presence_penalty=0)
    new_tasks = response.choices[0].text.strip().split('\n')
    task_list = deque()
    for task_string in new_tasks:
        task_parts = task_string.strip().split(".", 1)
        if len(task_parts) == 2:
            task_id = task_parts[0].strip()
            task_name = task_parts[1].strip()
            task_list.append({"task_id": task_id, "task_name": task_name})
def execution_agent(objective:str,task: str) -> str:
    #context = context_agent(index="quickstart", query="my_search_query", n=5)
    context=context_agent(index=YOUR_TABLE_NAME, query=objective, n=5)
    #print("\n*******RELEVANT CONTEXT******\n")
    #print(context)
    response = openai.Completion.create(
        engine="text-davinci-003",
        #prompt=f"You are an AI who performs one task based on the following objective: {objective}.\nTake into account these previously completed tasks: {context}\nYour task: {task}\nResponse:",
        prompt=f"""あなたは、次の目的:{objective}に基づき、1つのタスクを実行するAIです:{context}\n あなたのタスク:{task}\n 回答:""",
        temperature=0.7,
        max_tokens=2000,
        top_p=1,
        frequency_penalty=0,
        presence_penalty=0
    )
    return response.choices[0].text.strip()

Baby AGI(Yoheiの最初の投稿)

自由に使ってみてください!「Baby AGI」という「タスク駆動型自律エージェント」のシンプルなバージョンをオープンソース化しました。コードは105行です。3つのタスクエージェント(実行、作成、優先順位付け)が調和して動きます…永遠に

Open AI イリヤ・サツケバーが描くAI未来

GPTはサム・アルトマンのビジョンのほんの一部


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