Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import openai
- openai.api_key = "API-KEY" # https://platform.openai.com/api-keys
- def chat_with_gpt(prompt):
- response = openai.completions.create( # Changed
- model="gpt-3.5-turbo-instruct", # Changed
- prompt=prompt,
- max_tokens=150
- )
- # Extracting the response
- answer = response.choices[0].text.strip()
- print("Chatbot:", answer)
- if __name__ == "__main__":
- while True:
- user_input = input("You: ")
- if user_input.lower() in ["quit", "exit", "bye"]:
- break
- chat_with_gpt(user_input)
- response = client.completions.create(
- model="gpt-3.5-turbo-instruct",
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement