Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.env not loaded automatically #1456

Open
jonathanlastmileai opened this issue Mar 13, 2024 · 2 comments
Open

.env not loaded automatically #1456

jonathanlastmileai opened this issue Mar 13, 2024 · 2 comments
Assignees
Labels
type: bug Something isn't working

Comments

@jonathanlastmileai
Copy link
Contributor

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

@jonathanlastmileai jonathanlastmileai added the type: bug Something isn't working label Mar 13, 2024
@rossdanlm
Copy link
Contributor

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants