How to use the below codes? – Watch the video below to learn prompt engineering and how to use the codes below with ChatGPT and Python to get the best results in your work.
Download Module:
#for windows users pip install OpenAI # for mac users pip3 install OpenAI
LLM Script:
import openai # Set your OpenAI API key openai.api_key = "sk-proj-bgRif9c8hw7AjVCnokmMBUgq" def llm_generate_text(prompt, model): return openai_generate(prompt, model) def openai_generate(user_prompt, selected_model): completion = openai.chat.completions.create( model=selected_model, messages=[ {"role": "user", "content": user_prompt} ] ) return completion.choices[0].message.content