CoolFace
Apppublic

WebashalarForML/scratch_chat

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
check_groq_models.py57 linesDownload Raw Back to root
1#!/usr/bin/env python3
2"""
3Check which Groq models are currently available.
4"""
5
6import os
7from dotenv import load_dotenv
8from groq import Groq
9
10load_dotenv()
11
12def test_models():
13    """Test different Groq models to find supported ones."""
14    api_key = os.getenv('GROQ_API_KEY')
15    if not api_key:
16        print("No API key found")
17        return
18    
19    client = Groq(api_key=api_key)
20    
21    # Common models to test
22    models_to_test = [
23        'llama-3.1-70b-versatile',
24        'llama-3.1-8b-instant',
25        'llama3-70b-8192',
26        'llama3-8b-8192',
27        'mixtral-8x7b-32768',
28        'gemma-7b-it',
29        'gemma2-9b-it'
30    ]
31    
32    working_models = []
33    
34    for model in models_to_test:
35        try:
36            print(f"Testing {model}...")
37            response = client.chat.completions.create(
38                messages=[{"role": "user", "content": "Hi"}],
39                model=model,
40                max_tokens=10
41            )
42            
43            if response.choices:
44                print(f"✅ {model} works!")
45                working_models.append(model)
46            else:
47                print(f"❌ {model} - no response")
48                
49        except Exception as e:
50            print(f"❌ {model} - {str(e)[:100]}...")
51    
52    print(f"\nWorking models: {working_models}")
53    if working_models:
54        print(f"Recommended: {working_models[0]}")
55
56if __name__ == "__main__":
57    test_models()