Skrip Python untuk memfilter umpan RSS dengan meminta skor relevansi dari GPT-4 dan hanya termasuk entri yang memenuhi ambang batas yang ditentukan pengguna. Mencoba & terbukti dengan twitter2rss.
python filter_rss.py <rss_feed_path> <rss_dest_path> <system_prompt_path> [--threshold THRESHOLD]
rss_feed_path : Path ke file feed RSS sumber.rss_dest_path : Path ke file feed RSS tujuan.system_prompt_path : Path ke file teks yang berisi prompt sistem.--threshold : (Opsional) Ambang batas untuk penyaringan entri berdasarkan skor GPT-4. Default adalah 0,5. Sebelum menggunakan skrip ini, pastikan Anda telah mengatur variabel lingkungan OPENAI_API_KEY dengan kunci API openai Anda.
File teks yang dirujuk oleh System_Prompt_Path menginstruksikan GPT-4 untuk berfungsi sebagai sistem moderasi konten. Ini adalah sampel (juga direproduksi dalam sampel-prompt.txt, siap digunakan):
You are a content moderation system. Rate the relevance of the input on a scale of 0 to 1. Only numbers are permitted replies. prioritize tweets that contain insightful, informative, or thought-provoking content. Avoid: overly promotional, political issues, platitudes, languages other than English or German.
Untuk membuat prompt sistem untuk GPT-4, Anda dapat menggunakan GPT-4 sendiri untuk belajar dari beberapa contoh, dengan prompt sistem seperti ini:
You are given multiple user inputs which represent tweets to learn from. These are prefixed with either [WANTED] or [UNWANTED] for you, but these prefixes are not in the real data. From these inputs, create one System instruction for you, GPT-4, to use for future content ranking. This instruction only needs to be understandable by you. Tweets will be submitted individually to you, so while repetitive content is unwanted, you will not be able to infer it from the individual tweets.
dan permintaan pengguna seperti ini:
[UNWANTED]Insightful_User Retweeted Boring_User
Trying out @bluesky for the past couple of days.
Simpan prompt yang dihasilkan dalam file teks dan berikan jalur ke file saat menjalankan skrip.
Instal dependensi menggunakan PIP:
pip install feedparser beautifulsoup4 openai
Proyek ini dilisensikan di bawah GNU Affero General Public License v3.0 (AGPLV3). Untuk detail lebih lanjut, lihat file lisensi.