สคริปต์ Python เพื่อกรองฟีด RSS โดยขอคะแนนความเกี่ยวข้องจาก GPT-4 และรวมถึงรายการที่ตรงตามเกณฑ์ที่ผู้ใช้กำหนด พยายามและพิสูจน์ด้วย Twitter2RSS
python filter_rss.py <rss_feed_path> <rss_dest_path> <system_prompt_path> [--threshold THRESHOLD]
rss_feed_path : เส้นทางไปยังไฟล์ฟีด RSS ต้นทางrss_dest_path : เส้นทางไปยังไฟล์ฟีด RSS ปลายทางsystem_prompt_path : พา ธ ไปยังไฟล์ข้อความที่มีพรอมต์ระบบ--threshold : (ไม่บังคับ) เกณฑ์สำหรับการกรองรายการตามคะแนน GPT-4 ค่าเริ่มต้นคือ 0.5 ก่อนที่จะใช้สคริปต์นี้ตรวจสอบให้แน่ใจว่าคุณได้ตั้งค่าตัวแปรสภาพแวดล้อม OPENAI_API_KEY ด้วยคีย์ OpenAI API ของคุณ
ไฟล์ข้อความที่อ้างถึงโดย system_prompt_path สั่งให้ GPT-4 ทำงานเป็นระบบการควบคุมเนื้อหา นี่คือตัวอย่าง (ยังทำซ้ำในตัวอย่าง prompt.txt พร้อมใช้งาน):
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.
ในการสร้างพรอมต์ระบบสำหรับ GPT-4 คุณสามารถใช้ GPT-4 ตัวเองเพื่อเรียนรู้จากตัวอย่างบางส่วนด้วยพรอมต์ระบบเช่นนี้:
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.
และผู้ใช้แจ้งเช่นนี้:
[UNWANTED]Insightful_User Retweeted Boring_User
Trying out @bluesky for the past couple of days.
บันทึกพรอมต์ที่สร้างขึ้นในไฟล์ข้อความและจัดเตรียมพา ธ ไปยังไฟล์เมื่อเรียกใช้สคริปต์
ติดตั้งการอ้างอิงโดยใช้ PIP:
pip install feedparser beautifulsoup4 openai
โครงการนี้ได้รับใบอนุญาตภายใต้ใบอนุญาตสาธารณะ GNU Affero ทั่วไป v3.0 (AGPLV3) สำหรับรายละเอียดเพิ่มเติมดูไฟล์ใบอนุญาต