Need help in editing code

Sulphur

BANNED
Joined
Apr 3, 2020
Messages
849
Reaction score
229
I need some help from this thread:-

https://www.blackhatworld.com/seo/openai-gpt-3-to-article-files-or-wordpress-posts-almost-free-and-high-quality-ai-generated-content-make-your-own-autoblogs.1421772/page-3


I need open ai to write specific word length of content and uploading on Wordpress section do not work which needs to be fixed.


throwing me an error of:-

Traceback (most recent call last):
File "c:\Users\admin\Documents\testify\testify.py", line 127, in <module>
post2wp(q=input(singleq), i=1, flag = True)
TypeError: post2wp() missing 1 required positional argument: 'content'


It will be great if it directly posts to wp as I am not in need of other things :)
 
The method that you are trying to call takes 4 arguments, see:

Python:
def post2wp(q, i, flag, content):
    if flag:
        openai.api_key = openai_key
        content = openai.Completion.create(model="text-davinci-002", prompt=q, temperature=aitemperature,
                                            max_tokens=maxtokens)["choices"][0]["text"]

    cred = f'{wordpress_username}:{wordpress_application_password}'
    tkn = base64.b64encode(cred.encode())
    wpheader = {'Authorization': 'Basic ' + tkn.decode('utf-8')}
    api_url = f'https://{wordpress_domain}/wp-json/wp/v2/posts'
    data = {
    'title' : q.capitalize(),
    'status': wordpress_post_status,
    'content': content,
    }
    print(content)
    wp_response = requests.post(url=api_url,headers=wpheader, json=data)
    print(i, wp_response)

You only provided 3. Based on reading the code it's the content that you actually want to post. So you need to do something like:
post2wp(q=input(singleq), i=1, flag = True, content="This content will appear on wordpress")

The content that you actually will feed this method is the string you derive from openAI.

That being said this is a pretty simple issue. I would recommend you learn more about method/function arguments as you will keep running into issues like this in the future if you don't understand this simple concept:

https://www.programiz.com/python-programming/function-argument
https://www.w3schools.com/python/gloss_python_function_arguments.asp
 
Last edited:
okay but as "content" is already defined there which contains the output of openai. it should just post that. what should I do to upload the content ?
 
Don't bump a thread after 10 minutes of creating it..
Sulphur is very reactive lol.

Coming to the thread, what your compiler says is totally sensible. Learn to read the error messages first. It will help immensely.
 
okay but as "content" is already defined there which contains the output of openai. it should just post that. what should I do to upload the content ?
Did you read my comment at all?

You are NOT passing in the content argument that is required. Yes it may be defined elsewhere but that function requires that you pass it in as an argument. Reread my comment and adjust your code.
 
Sulphur is very reactive lol.

Coming to the thread, what your compiler says is totally sensible. Learn to read the error messages first. It will help immensely.
He replied "Bump" 10 minutes after he created the thread because no one responded yet... Lmao
 
He replied "Bump" 10 minutes after he created the thread because no one responded yet... Lmao
Well, I read it and one of my friend who is not aware of Bump rules posted it.
 
Back
Top