cannot import name 'Secret' from 'haystack.utils

53 views Asked by At

I keep getting the error "cannot import name 'Secret' from 'haystack.utils", even when trying just 'haystack.util' it still cannot import 'Secret'

I checked through haystack.ai documentation and it should work im not sure why it doesn't work for me.

1

There are 1 answers

0
Project 01 On

This worked for me I'm using Haystack 2.0

import os
from haystack.utils import Secret
os.environ["OPENAI_API_KEY"] = "Your OpenAI API Key"
llm = OpenAIGenerator(api_key=Secret.from_env_var("OPENAI_API_KEY"))