| import sys | |
| import os | |
| from openai import OpenAI | |
| sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) | |
| from backend.app.config import config | |
| def test_fallback_model(): | |
| print("Testing Fallback Model (llama-3.1-8b-instant)...") | |
| if not config.GROQ_API_KEY: | |
| print("ERROR: GROQ_API_KEY missing") | |
| return | |
| client = OpenAI( | |
| base_url="https://api.groq.com/openai/v1", | |
| api_key=config.GROQ_API_KEY | |
| ) | |
| try: | |
| response = client.chat.completions.create( | |
| model="llama-3.1-8b-instant", | |
| messages=[ | |
| {"role": "user", "content": "Say 'Fallback works' if you can read this."} | |
| ] | |
| ) | |
| print("Success! Response:") | |
| print(response.choices[0].message.content) | |
| except Exception as e: | |
| print(f"FAILED: {e}") | |
| if __name__ == "__main__": | |
| test_fallback_model() | |