Add support for picking up variables from .env file
abhagsain opened this issue · comments
It would be great to have support for picking up environment variables from the .env
file (I tried it's not working).
Also, I sourced the env variables in my terminal session but they are also not getting picked. I'm not sure what am I doing wrong.
I don't want to add env variables in the yaml
file to avoid committing it to git
![image](https://private-user-images.githubusercontent.com/36589645/318295744-9c459761-b4b9-448f-9333-7f20cb4bbdcd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAxOTE5NDcsIm5iZiI6MTcyMDE5MTY0NywicGF0aCI6Ii8zNjU4OTY0NS8zMTgyOTU3NDQtOWM0NTk3NjEtYjRiOS00NDhmLTkzMzMtN2YyMGNiNGJiZGNkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA1VDE1MDA0N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJkNTJmM2FkOWU2NjI4MmZlYjRkMjQwZWZhOWY1MzNmMDY1YmVjM2ZiOGYzYWYyYjQ5MGJmYmQ1MzUxMmU0ZjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.vKzZS9Jq2sJlJvfZFcPSKK8SGt-YeJt7d71AyCNgBBM)
This is my yaml
description: "My first eval"
prompts:
- "Write a tweet about {{topic}}"
- "Write a very concise, funny tweet about {{topic}}"
providers:
- id: azureopenai:chat:gpt-35-16k
config:
apiHost: https://<endpoint>.openai.azure.com
temperature: 0.4
apiVersion: 2024-02-15-preview
- id: openai:gpt-4
config:
temperature: 0.4
tests:
- vars:
topic: bananas
- vars:
topic: avocado toast
assert:
# For more information on assertions, see https://promptfoo.dev/docs/configuration/expected-outputs
- type: icontains
value: avocado
- type: javascript
value: 1 / (output.length + 1) # prefer shorter outputs
- vars:
topic: new york city
assert:
# For more information on model-graded evals, see https://promptfoo.dev/docs/configuration/expected-outputs/model-graded
- type: llm-rubric
value: ensure that the output is funny
I have seen mentions of export OPENAI_API_KEY=your_api_key_here
in the docs, so it should work.
I'm using Turbo repo and this is my path /Documents/projects/cool-ai-project/packages/prompts
. If it helps investigating the issue.
For now, I'll hardcode API keys in yaml
but not commit anything.
This was actually just added in #602! It'll be in the next published release (probably published within the next 12 hours)
This change is released in 0.50.0. Thanks!
Hello, thanks for adding this. Is it possible to pass a non-standard path to an .env
file to the CLI? While our npm scripts are run from the repo root, we prefer not to have any number of .env
files cluttering it up, so they tend to go in package-specific sub-directories along with config files (such as promptfooconfig.yaml
).
@alexclaydon Made a PR here that allows you to override the .env
path: #615