lastmile-ai / aiconfig

AIConfig is a config-based framework to build generative AI applications.
https://aiconfig.lastmileai.dev
MIT License
963 stars 79 forks source link

.env not loaded automatically #1456

Open jonathanlastmileai opened 8 months ago

jonathanlastmileai commented 8 months ago

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

result.result.UnwrapError: CalledResult.unwrap()on anErrvalue: "Missing API key 'OPENAI_API_KEY' in environment"

Repro:

Follow the pydata demo steps.

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 
rossdanlm commented 8 months ago

Yea this is expected behaviour. load_dotenv moves key-value pairs from .env files --> os value, so you can also do .zshrc file if you want to permanently add it there forever. We just need to ensure that the api keys are uploaded to the os environment

jonathanlastmileai commented 8 months ago

OK, just need to point out that at least some of our demos don't have the loading code, e.g. pydata. cc @andrew-lastmile