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_direct(): print(f"Verifying Direct Inference with {config.LLM_MODEL}...") prompt = ( "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n" "You are a helpful assistant.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n" "Say 'Direct Inference Works!'<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n" ) try: client = InferenceClient(token=config.HUGGINGFACE_API_KEY) res = client.text_generation( prompt, model=config.LLM_MODEL, max_new_tokens=50, temperature=0.7, top_p=0.9, stop_sequences=["<|eot_id|>"] ) print("Success!") print(res.strip()) except Exception as e: msg = f"Failed: {repr(e)}" print(msg) with open("verify.log", "w") as f: f.write(msg) # Also log success with open("verify.log", "a") as f: f.write("\nRan verification.") verify_direct()