File size: 777 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

import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
from huggingface_hub import InferenceClient
from backend.app.config import config

def verify_phi():
    model = "microsoft/Phi-3-mini-4k-instruct"
    print(f"Verifying {model}...")
    try:
        client = InferenceClient(token=config.HUGGINGFACE_API_KEY)
        res = client.text_generation(
            "User: Hi\nAssistant:", 
            model=model, 
            max_new_tokens=10
        )
        print("Success!")
        print(res)
    except Exception as e:
        with open("verify.log", "w") as f:
            f.write(f"Failed: {repr(e)}")
        print(f"Failed. See verify.log")

if __name__ == "__main__":
    verify_phi()