rlancemartin / auto-evaluator

Evaluation tool for LLM QA chains
https://autoevaluator.langchain.com/
1.05k stars 94 forks source link

I've passed in the openai_api_key but still getting this validation error #1

Closed douyujie closed 1 year ago

douyujie commented 1 year ago

ValidationError: 1 validation error for ChatOpenAI root Did not find openai_api_key, please add an environment variable OPENAI_API_KEY which contains it, or pass openai_api_key as a named parameter. (type=value_error)

Traceback: File "/Users/yujiedou/Desktop/auto-evaluator-main/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script exec(code, module.dict) File "/Users/yujiedou/Desktop/auto-evaluator-main/auto-evaluator.py", line 302, in eval_set = generate_eval(text, num_eval_questions, 3000) File "/Users/yujiedou/Desktop/auto-evaluator-main/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 194, in wrapper return cached_func(*args, *kwargs) File "/Users/yujiedou/Desktop/auto-evaluator-main/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 223, in call return self._get_or_create_cached_value(args, kwargs) File "/Users/yujiedou/Desktop/auto-evaluator-main/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 248, in _get_or_create_cached_value return self._handle_cache_miss(cache, value_key, func_args, func_kwargs) File "/Users/yujiedou/Desktop/auto-evaluator-main/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 302, in _handle_cache_miss computed_value = self._info.func(func_args, func_kwargs) File "/Users/yujiedou/Desktop/auto-evaluator-main/auto-evaluator.py", line 81, in generate_eval chain = QAGenerationChain.from_llm(ChatOpenAI(temperature=0, openai_api_key=OPENAI_API_KEY**)) File "pydantic/main.py", line 341, in pydantic.main.BaseModel.init

rlancemartin commented 1 year ago

export OPENAI_API_KEY then simply kick off streamlit and ensure you have credits.

also, some features (GPT4) may not be accessible w/ your key. (working on a hosted version for this.)