3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Pythonで、ChatGptとBardに同時に質問

Last updated at Posted at 2023-07-18

画面

上部は質問。中段がChatGPT、下段がBard.
image.png

Pythonのコード

不要コードがあるが

ライブラリのインストール

chat gpt

pip install openai
pip install Pillow

Bard

pip install bardapi

ChatGptのAPI取得し設定

https://platform.openai.com/account/api-keys
OPEN AIにログインし画面右上のPersonalをクリックし「View API Keys」をクリックする。
「+Create new secret key」>「Create secret key」クリックしAPIキーを作成しコピーする。

14行目に設定

api_key = 'sk-.....'

BardのTokenの取得

https://bard.google.com/
にchromeブラウザでアクセスしF12 お押す。
Session: Application → Cookies → __Secure-1PSID のValue
__Secure-1PSIDのValueをコピー

image.png

46行目に設定

    token = 'xxxxxx-xxxxx.' #os.environ['COOKIE_TOKEN']

感想

どっちが優秀か分からない。
トークンは課金の従量制だとパケ死する可能性があるため注意。

参考

https://fuji-pocketbook.net/chatgpt-api-python/
https://zenn.dev/00/articles/de99d0f10c5493

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?