Skip to content

.env not loaded automatically #1456

@jonathanlastmileai

Description

@jonathanlastmileai

I don't know if this is expected behavior, but I have to call load_dotenv() otherwise I get this:

result.result.UnwrapError: Called Result.unwrap()on anErr value: "Missing API key 'OPENAI_API_KEY' in environment"

Repro:

Follow the pydata demo steps.

  • Put .env in working directory
  • run this
from aiconfig import AIConfigRuntime, InferenceOptions
import asyncio

config = AIConfigRuntime.load("pydata.aiconfig.yaml")

inference_options = InferenceOptions(stream=True)

async def main():
  query_question = input()
  print("thinking...")
  await config.run("sql-generator", params = {"function" : query_question}, options=inference_options)
  print("done")

if __name__=="__main__":
  asyncio.run(main())

cc @saqadri , @Ankush-lastmile , @rossdanlm

Metadata

Metadata

Assignees

Labels

type: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions