# test_llm.py - Create this as a separate file to test your LLM setup | |
import os | |
from dotenv import load_dotenv | |
print("=== Testing LLM Setup ===") | |
# Load environment variables | |
load_dotenv() | |
print(f"β Environment loaded") | |
print(f"π GROQ_API_KEY exists: {'GROQ_API_KEY' in os.environ}") | |
if 'GROQ_API_KEY' in os.environ: | |
key = os.environ['GROQ_API_KEY'] | |
print(f"π API Key starts with: {key[:10]}...") | |
# Test LLM import | |
try: | |
from ourllm import llm | |
print("β Successfully imported LLM") | |
# Test LLM call | |
test_message = "Hello, please respond with 'LLM is working correctly'" | |
print(f"π§ͺ Testing with message: {test_message}") | |
response = llm.invoke(test_message) | |
print(f"β LLM Response: {response.content}") | |
except ImportError as e: | |
print(f"β Import error: {e}") | |
except Exception as e: | |
print(f"β LLM call error: {e}") | |
print("=== Test Complete ===") |