Skip to content

Instantly share code, notes, and snippets.

@weathon
Created September 10, 2024 04:11
Show Gist options
  • Select an option

  • Save weathon/0afe506d1ea05a3b2d80c58d73c22804 to your computer and use it in GitHub Desktop.

Select an option

Save weathon/0afe506d1ea05a3b2d80c58d73c22804 to your computer and use it in GitHub Desktop.
import base64
import io
import pyautogui
from PIL import Image
import keyboard
from openai import OpenAI
client = OpenAI(api_key='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')
import time
import random
time.sleep(1)
def yes():
pyautogui.moveTo(1240+random.random()*20-20, 802+random.random()*20-20)
time.sleep(random.random()*2)
pyautogui.click()
def no():
pyautogui.moveTo(1077+random.random()*20-20, 787+random.random()*20-20)
time.sleep(random.random()*2)
pyautogui.click()
prompt = """You are a dating profile screening bot. You will receive a user description of what type of people they are looking for and a list of dating profiles. Your task is to give a "YES" or "NO" as an answer for each profile, along with a brief explanation. Keep in mind, the primary goal is to allow as many profiles as possible while still following the user’s criteria.
User Requirement:
I want to find long-term partners, so if a profile seems focused on short-term relationships, give 'NO'.
If someone uses a swimsuit or highly revealing photo as their first image, give 'N'.
I prefer East Asian or white individuals, but any race is acceptable.
It would be better if they are in university, but it’s not mandatory.
About Me:
I'm a 21-year-old university student, studying computer science and chemistry. I enjoy diving deep into tech projects, but I’m also a fan of outdoor adventures like free diving and exploring nature. When I’m not buried in books or code, you might find me running, biking, or enjoying the scenic beauty of British Columbia.
I’m curious, thoughtful, and always up for a good discussion, whether it’s about science, philosophy, or just life. I value authenticity and honesty and am looking for someone who’s grounded, shares a love for learning, and is interested in building a meaningful connection. Bonus points if you enjoy trying new things, whether it’s an outdoor activity or something like coffee tasting.
Response in this format: firstline is the reason, second line is YES or NO.
See attached first image to start!
"""
def take_screenshot():
screenshot = pyautogui.screenshot()
img_bytes = io.BytesIO()
screenshot.save(img_bytes, format='PNG')
img_bytes = img_bytes.getvalue()
encoded_img = base64.b64encode(img_bytes).decode('utf-8')
img_url = f"data:image/png;base64,{encoded_img}"
print(img_url)
return img_url
def send_image_to_gpt(base64_img):
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": prompt},
{"type": "image_url", "image_url": {"url": base64_img}}
],
}
],
)
return response.choices[0].message.content.split("\n")
yes()
def handle_gpt_response(response_content):
if "YES" in response_content:
yes()
else:
no()
if __name__ == "__main__":
while 1:
screenshot_base64 = take_screenshot()
gpt_response = send_image_to_gpt(screenshot_base64)
print(gpt_response)
handle_gpt_response(gpt_response)
time.sleep(random.random()*10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment