expectedparrot / edsl

Design, conduct and analyze results of AI-powered surveys and experiments. Simulate social science and market research with large numbers of AI agents and LLMs.
https://docs.expectedparrot.com
MIT License
194 stars 19 forks source link

Token authentication doesn't work when running code from .py script. (Running from notebook works). #1253

Closed zer0dss closed 2 weeks ago

zer0dss commented 2 weeks ago

@onmyraedar can you replicate this?

https://github.com/user-attachments/assets/aeb0ad10-4de8-4031-bccd-0037948a3822

onmyraedar commented 2 weeks ago

Yes, I can replicate.

I've looked into this and it's because when using scripts, os.getenv can still read the model keys that you've commented out - so it thinks you have all the model keys needed to run the job. That's why it doesn't start the "To use remote inference..." workflow.

The workflow you're seeing is different (invalid API key). The issue happens because the script is making two calls to Coop.edsl_settings() (once for cache, once for inference). If you log in the second time, the script will finally stop, and tell you to rerun.

You can see the other flow (the one that runs your jobs remotely) by deleting your model api keys.

I should implement some kind of soft check mechanism on the EDSL settings call so that if you have all of your local keys, you are not trapped in the login flow.

zer0dss commented 2 weeks ago

Thanks @onmyraedar, I've removed the commented API keys and it worked.

onmyraedar commented 2 weeks ago

Fixed in https://github.com/expectedparrot/edsl/pull/1274 - if you have all of your keys, you no longer have to log in twice for EDSL settings