Find answers from the community

Home
Members
Ziggy McDougal
Z
Ziggy McDougal
Offline, last seen 3 months ago
Joined September 25, 2024
Hi all. I've been trying to perform some queries on ECG data I get from pdfs and i'm going through the starting tutorial in the docs and I keep getting this error
Plain Text
line 186, in default_api_key
    raise openai.error.AuthenticationError(
openai.error.AuthenticationError: No API key provided. You can set your API key in code using 'openai.api_key = <API-KEY>', or you can set the environment variable OPENAI_API_KEY=<API-KEY>). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = <PATH>'. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details.


and here's my code

Plain Text
from dotenv import load_dotenv
from llama_index import VectorStoreIndex, SimpleDirectoryReader


load_dotenv()

message = "What is the patient's date of birth?"

def pdfQuery():
    documents = SimpleDirectoryReader('reports').load_data()
    index = VectorStoreIndex.from_documents(documents)
    query_engine = index.as_query_engine()
    response = query_engine.query(message)
    print(response)


pdfQuery()


I generated the api key and set up the dotenv file already

Plain Text
OPENAI_API_KEY={my key}


any help is appreciated
3 comments
m
L