Download test_langchain_key.py from d-e-e-k-11/amazon_product: direct link, hf CLI and curl.
- Browser
- Download file 452 Bytes
-
https://huggingface.co/d-e-e-k-11/amazon_product/resolve/main/test_langchain_key.py
- Command line
-
hf download hf://d-e-e-k-11/amazon_product/test_langchain_key.py
-
curl -L -o test_langchain_key.py https://huggingface.co/d-e-e-k-11/amazon_product/resolve/main/test_langchain_key.py
452 Bytes
| import os | |
| from dotenv import load_dotenv | |
| from langchain_google_genai import ChatGoogleGenerativeAI | |
| load_dotenv(override=True) | |
| api_key = os.getenv("GOOGLE_API_KEY") | |
| print(f"Testing LangChain with Key: {api_key}") | |
| try: | |
| llm = ChatGoogleGenerativeAI(model="gemini-flash-latest", google_api_key=api_key) | |
| res = llm.invoke("Hello") | |
| print("LangChain Success:", res.content) | |
| except Exception as e: | |
| print("LangChain ERROR:", e) | |