Giter Site home page Giter Site logo

hakkadaikon / nostr-yaruo-bot Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 3.0 108 KB

Nostr bot that speaks like “Yaruo” using the OpenAI API. "Yaruo" is a 2ch character.

License: MIT License

JavaScript 96.26% Makefile 2.77% Dockerfile 0.97%
2ch chatbot japanese javascript nostr openai openai-api yaruo

nostr-yaruo-bot's Introduction

Hakkadaikon/nostr-yaruo-bot

Summary

"yaruo" is a 2ch character. This bot speaks like yaruo.

Getting Started

  1. Copy .env.example to create .env.
  2. Replace the key information in the .env file with the correct ones.
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
BOT_PRIVATE_KEY_HEX="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
BOT_NEWS_API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  1. Start the bot.
$ docker-compose up -d

Author

Hakkadaikon

nostr-yaruo-bot's People

Contributors

hakkadaikon avatar imksoo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

nostr-yaruo-bot's Issues

News summarize error

Summary

7/18 0:30 JST, The parse result of the Readability library could not be interpreted and an exception was thrown.

Code

  let dom = new JSDOM(response.data, { url: newsurl });
  let article = new Readability(dom.window.document).parse();
  
  await callback(article.textContent);
                                  ^

Error

Jul 18 00:30:02  bash[41313]: TypeError: Cannot read properties of null (reading 'textContent')

古いニュースの投稿防止

概要

現在、やる夫botは30分毎にNews APIで取得したニュースの中から
ランダムで1つニュースを選択し、投稿している。

問題

20日前以上のニュースについて投稿することがあった。

対策

古いニュースは投稿しないよう、最新5~10件のニュースの中から投稿するよう変更する。
※件数は要調整

不適切発言対応

概要

6/30, LGBTについて不適切な発言 (よく思っていない旨)が投稿された。
また、この時の投稿自体、ハルシネーションがかなり発生しており、虚偽の内容が多く含まれていた。
-> やる夫botとして対応が出来るか検討する。

対策案

1. NGワードでリトライ

NGワードを設定し、当該ワードをニュース本文から検出した場合、別のニュースを選択する。
NGワードはDBか何かで持っておくか、何かしらのOSSでセンシティブワード一覧を取得できるのであれば、それを用いる。

2. プロンプトで改善を図る

どこまで効果があるかは分からないが、入力プロンプトを改善し、センシティブなワードには言及しないように改善を試みる。

3. 放置

諦める。

参考

ngword

Qちゃん要約 - 汚染問題

概要

7/1 2:00頃、Qちゃんの要約がやる夫の語尾で埋め尽くされる事件が発生した。
-> やる夫botとして対策が打てるか検討する。

現状のやる夫botの挙動

  • 30分単位で、GPT-3.5 + News APIによりニュースの感想を投稿する。
  • 感想は3行程度に抑えるようプロンプトで指示してあるが、出力はそうなっていないことも多い。

対策案

1. cronjsの設定変更

深夜時間帯は投稿しないよう、cronjsの設定を変更する。
(深夜時間帯は人間の投稿が少なくなるため、Qちゃんの要約はbotによる影響を受けやすくなる)

2. 放置

日中の時間帯は人間の投稿が多くなり、発生しにくいため放置。

3. プロンプト改善

やる夫のプロンプトを改善し、出力トークンの文字数を少なくすることで、Qちゃん要約が影響を受けにくくする。

参考

qchanjj

Add date time to log.

Summary

Around 07/01 02:20 (JST), there was a problem with the relay, and Yaruo was unable to post the message.
However, I didn't know the detailed time because I didn't put the time in the log.

Include date and time information in the log, and respond to analysis when a failure occurs in the future.

News summary Error

Summary

Jul 18 10:00:04 bash[56494]: file:///home/hakkadaikon/repos/run/nostr-yaruo-bot/src/actions/news.mjs:83
Jul 18 10:00:04 bash[56494]:   let dom = new JSDOM(response.data, { url: newsurl });
Jul 18 10:00:04 bash[56494]:                                ^
Jul 18 10:00:04 bash[56494]: TypeError: Cannot read properties of undefined (reading 'data')
Jul 18 10:00:04 bash[56494]:     at Module.getNewsContent (file:///home/hakkadaikon/repos/run/nostr-yaruo-bot/src/actions/news.mjs:83:32)
Jul 18 10:00:04 bash[56494]:     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Jul 18 10:00:04 bash[56494]:     at async file:///home/hakkadaikon/repos/run/nostr-yaruo-bot/src/commands/command.mjs:83:7
Jul 18 10:00:04 bash[56494]: Node.js v20.1.0

VPS powered down

Summary

VPS powerdown and yaruo also ended with sighup.

/var/log/syslog/

Jul 11 00:55:30 qemu-ga: info: guest-shutdown called, mode: powerdown

重複したニュースの投稿防止

概要

現在、やる夫botは30分毎にNews APIで取得したニュースの中から
ランダムで1つニュースを選択し、投稿している。

問題

同じニュースについて、2回続けて投稿してしまうことがあった。

対策

同じニュースを2回続けて投稿しないよう、防止機構を入れる。

That model is currently overloaded with other requests.

Summary

7/1 16:30:07, Exception occurred in yaruo.

/home/hakkadaikon/repos/run/nostr-yaruo-bot/node_modules/openai/node_modules/axios/lib/core/createError.js:16
  var error = new Error(message);
              ^

Error: Request failed with status code 503
    at createError (/home/hakkadaikon/repos/run/nostr-yaruo-bot/node_modules/openai/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/home/hakkadaikon/repos/run/nostr-yaruo-bot/node_modules/openai/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/home/hakkadaikon/repos/run/nostr-yaruo-bot/node_modules/openai/node_modules/axios/lib/adapters/http.js:322:11)
    at IncomingMessage.emit (node:events:523:35)
    at endReadableNT (node:internal/streams/readable:1367:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
~

    data: {
      error: {
        message: 'That model is currently overloaded with other requests. You can retry your request, or contact us through our help center at help.openai.com if the error persists. (Please include the request ID XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX in your message.)',
        type: 'server_error',
        param: null,
        code: null
      }

Use GPT-4

Summary

Since GPT-4 is open to the public, change the model from GPT3.5-turbo to GPT-4.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.