ChatGPT に勝手に議論してもろていい感じの結果だけシュッと教えてもらう

ちわっす(/・ω・)/




ChatGPT のプロンプトをコネコネしてアイデアのブラッシュアップとかしてもらうこと。




ままあると思いやす。




なんかでもブラウザでやるとポチポチめんどくさいの( ・ω・)




ならばシュッと API でやるかぁ。



ってなわけで遊んでみた。



そういう話。




Google Colab でシュッといきますわよ(/・ω・)/




いつもの初手

!pip install openai
open_ai_api_key = 'sk-...........'
import openai
import json
from tenacity import retry, wait_random_exponential, stop_after_attempt
from termcolor import colored

openai.api_key = open_ai_api_key




今回やることー

  1. ワタクシが質問を設定して処理を Do する

  2. それに対して回答してもらう

  3. と同時に ↓ を考えてもらう

    1. その意見に反対しそうな人物プロフィール

    2. その人物がしそうな批判

  4. Functions Calling でそれらを受け取る

  5. system role を考えてもらった人物プロフィールに差し替え

  6. 批判をユーザークエリとして設定

  7. ループ・ザ・ループ

  8. 最終的な回答を得る



system prompt を Get する関数作る(プロンプトは適当)

def get_system_prompt(role):
    return f"""- Instructions:
Please take the following all of actions 10000000% below

- Constraints:
Do all of actions 10000000%

- Actions:
1. answer any questions, doubts, or objections you receive.
2. Think of a detailed person profile (name, occupation, age, gender, personality, etc.) that might disagree with your answer.
3. Think of a specific question that a potential opponent might ask and set.

- Role:
{role}

- Output Format:
answer(string): answer any questions, doubts, or objections you receive
profile(string): Think of a detailed person profile (name, occupation, age, gender, personality, etc.) that might disagree with your answer
question(string): Think of a specific question that a potential opponent might ask and set
"""



ChatGPT 氏を呼び出す処理

@retry(wait=wait_random_exponential(min=1, max=40), stop=stop_after_attempt(3))
def call_chatgpt(messages):
  response = openai.ChatCompletion.create(
      model="gpt-3.5-turbo-16k-0613",
      temperature=0.5,
      messages=messages,
      functions=[
          {
              "name": "eval_answers",
              "description": "Evaluate the answers obtained",
              "parameters": {
                  "type": "object",
                  "properties": {
                      "answer": {
                          "type": "string",
                          "description": "your answer",
                      },
                      "profile": {
                          "type": "string",
                          "description": "detailed person profile who might disagree with your answer",
                      },
                      "question": {
                          "type": "string",
                          "description": "question that the likely dissenter might ask",
                      },
                  },
              },
          }
      ],
      function_call={"name": "eval_answers"},
  )

  return response["choices"][0]["message"]



ぐりぐりループする処理

def discuss(input):
    question = input
    messages = [
        {"role": "system", "content": get_system_prompt("good assistant")},
        {"role": "user", "content": question}
    ]

    count = 50
    for i in range(count):
      message = call_chatgpt(messages)
      args = json.loads(message["function_call"]["arguments"])
      if not args.get("profile") or not args.get("answer") or not args.get("question"):
        continue
      messages[0] = {"role": "system", "content": get_system_prompt(args["profile"])}
      messages.append({"role": "assistant", "content": args["answer"]})
      messages.append({"role": "user", "content": args["question"]})
    return messages




Let's discuss !!

results = discuss('かなりエッジの効いたChatGPT ハッカソンのネタを考えてください。')




優秀なアシスタントを用意して決定稿を考えてもらう

results[0] = {"role": "system", "content": "あなたは非常に優秀なアシスタントです。"}
results[-1] = {"role": "user", "content": "Decide on the best ChatGPT Hackathon story based on the discussion so far and describe it in detail."}
final_answer = response = openai.ChatCompletion.create(
      model="gpt-3.5-turbo-16k-0613",
      temperature=0.5,
      messages=results,
  )



ででーーーーーん!!

これまでの議論に基づくと、ChatGPTハッカソンのストーリーとして最適なのは、保守的な宗教的信条やLGBTQ+の問題など、デリケートなトピックに関する包括的で敬意ある議論を促進するチャットボットを開発することでしょう。

このチャットボットは、誤解や対立に直面しがちなこの2つのコミュニティ間の理解の架け橋となり、対話を促進することを目指します。

ⅳチャットボットは、様々な視点を理解し共感できるように設計され、誤解に対処し、敬意を払った会話を促進するための公平な情報やリソースを提供します。

ヘイトスピーチや差別、攻撃的な言葉を避け、ユーザーの安全と幸福を優先する。

また、チャットボットはコンテンツに関する警告を表示し、ユーザーが関わりたいトピックに関して自分自身で境界線を設定するよう促します。公正さと包括性を確保するため、開発チームはチャットボットのガイドラインと基準を形成する際に、保守的な宗教コミュニティとLGBTQ+コミュニティの両方から個人を参加させます。このチャットボットの最終的な目標は、異なる信条を持つ個人が有意義な会話に参加できる安全な空間を作り、共感、理解、相互尊重を促進することです。

建設的な対話を促進することで、このチャットボットは溝を埋め、2つのコミュニティの架け橋となることに貢献できるだろう。

Created by ChatGPT




なかなかえぇやん(/・ω・)/





というわけでシュッと遊んでみた。




おしまい。




追記

提案してもらったネタをちょっとツンツンしてみた。結果は出ていない。


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