File size: 945 Bytes
1f7ead8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

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()