I’m working on making a chatbot with twilio and OpenAI, and here’s my code:
import os
from dotenv import load_dotenv
import openai
load_dotenv()
openai.api_key = os.environ.get(‘OPENAI_KEY’)
completion = openai.Completion()
start_chat_log = ‘’‘Human: Hello, who are you?
AI: What’s up?
‘’’
def ask(question, chat_log=None):
if chat_log is None:
chat_log = start_chat_log
prompt = f’{chat_log}Human: {question}\nAI:’
response = completion.create(
prompt=prompt, engine=“davinci”, stop=[’\nHuman’], temperature=0.9,
top_p=1, frequency_penalty=0, presence_penalty=0.6, best_of=1,
max_tokens=150)
answer = response.choices[0].text.strip()
return answer
def append_interaction_to_chat_log(question, answer, chat_log=None):
if chat_log is None:
chat_log = start_chat_log
return f’{chat_log}Human: {question}\nAI: {answer}\n’
and even though I did pip install python-dotenv in my virtual environment that my project is in, when I try to run my code I’m getting this error:
ModuleNotFoundError: No module named ‘dotenv’
got any ideas for me?