I’m professional user for ChatGPT & Python coding as well due to my Data science study. now I want to creat a quick online app or software or anything that I can give it the input then it uses ChatGPT API integrating to response on my input. how can I do that ?
Literally I want to tell it the story brief, then just click a button so and it respond with the full story.
so any tips ?
#7 on ChatBot gives you some hint. Many people construct system using JavaScript. You may like to google search for such examples.
I would imagine something like this?
import openai
import os
from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv()) # read local .env file
openai.api_key = os.getenv(‘OPENAI_API_KEY’)
[{“metadata”:{“trusted”:false,“height”:183},“id”:“66de8ca6”,“cell_type”:“code”,“source”:“def get_completion(prompt, model="gpt-3.5-turbo"): # Andrew mentioned that the prompt/ completion paradigm is preferable for this class\n messages = [{"role": "user", "content": prompt}]\n response = openai.ChatCompletion.create(\n model=model,\n messages=messages,\n temperature=0, # this is the degree of randomness of the model’s output\n )\n return response.choices[0].message["content"]\n”,“execution_count”:null,“outputs”:}]
your_story = “”“whatever is your story idea”“”
prompt = f"“”
Your task is to continue writing a full, highly detailed story
relevant to your_story.
Continue writing a full, highly detailed story, delimited by triple
backticks, in at most 250 words.
story: {your_story}
“”"
response = get_completion(prompt)
print(response)