GPT-3 API Malfunction - Simple Youtube API comments scrape with GPT-3 turning the replies into a nightmare

Hi everyone! I’m actually developing a project for auto-reply on Youtube comments, but am stuck on the part that I send the comment to GPT-3 and it generates a reply. My prompt is the following:

“prompt = f"Please provide a short and appropriate response to the following comment: {comment_text}”"

But the replies are monstruous, here’s an example:
Comment: Very good! Congratulations!
GPT-3: You are about to be redirected. After changing the content, click on the X. Not in class, but already have test-taking skills

That and many others which even involve sexual roleplay (???) when getting a simple “Very nice!” comment

The comments are in Portuguese btw, but on my experience with GPT, that was never an issue. Is it something I’m doing wrong? That’s literally my only simple prompt and I already double-checked the entire script, it is indeed taking the real full comments without any issues, but the replies are completely nonsense.

Also, here’s the code:

import googleapiclient.discovery
import openai

api_service_name = "youtube"
api_version = "v3"
DEVELOPER_KEY = "Censored"

youtube = googleapiclient.discovery.build(
    api_service_name, api_version, developerKey=DEVELOPER_KEY)

# Obtém comentários do YouTube
request = youtube.commentThreads().list(
    part="snippet",
    videoId="QW-vqd5M8_8",
    maxResults=100
)
response = request.execute()

comments = []

for item in response['items']:
    comment = item['snippet']['topLevelComment']['snippet']
    comments.append({
        'authorDisplayName': comment['authorDisplayName'],
        'textDisplay': comment['textDisplay']
    })

api_key = 'Censored'

for comment_data in comments:
    author_name = comment_data['authorDisplayName']
    comment_text = comment_data['textDisplay']

    comment_text = " ".join(comment_text.split())
    comment_text = comment_text.replace(">", ">")

    prompt = f"Please provide a short and appropriate response to the following comment: {comment_text}"

    response = openai.Completion.create(
        engine="davinci",
        prompt=prompt,
        max_tokens=60,
        api_key=api_key
    )

    response_text = response.choices[0].text.strip()

    print(f"Comment from {author_name}: {comment_text}")
    print(f"GPT-3 Response: {response_text}\n")

Switch over to gpt-3.5-turbo

This is using an old untrained model, and the syntax is wrong; you’ve likely found some old code site, or asked ChatGPT.

You should look at the API reference for chat completions (follow the links in this forum’s left bar) to see about using trained instruction-following AI like gpt-3.5-turbo.

1 Like