0
import os
from urllib import response
import openai

def gpt3(stext):
    openai.api_key = 'my-kye-here'

    response = openai.Completion.create(
        model="text-davinci-002",
        prompt= stext,
            temperature=0.7,
            max_tokens=256,
            top_p=1,
            frequency_penalty=0,
            presence_penalty=0
    )
    content = response.choices[0].text.split('.')
    #print(content)
    return response.choices[0].text


stext = input("Enter your prompt")
response = gpt3(stext)
print(response)

this is my python code in which I'm using OpenAI API, So where I used prompt = stext, , I want to use the promp like that prompt = "My rest promp: Here I need to call my stext variable", is this make any sense? my prompt is written permanently in the prompt section, can I use stext variable in the prompt in case to get the value that user put in the stext in the prompt section? I'm not sure I'm asking it in the right way or not, but if you got my point, then please help me out.

1
  • 1
    Why don't you change the code to what you have described?
    – mkrieger1
    Oct 17, 2022 at 18:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.