from langchain_community.llms import HuggingFaceHub def llm_node(question): # Initialize the Hugging Face model llm = HuggingFaceHub( repo_id="HuggingFaceH4/zephyr-7b-beta", # You can replace with e.g., mistralai/Mistral-7B-Instruct-v0.2 model_kwargs={ "temperature": 0.1, # Keep responses deterministic "max_new_tokens": 500 # Allow for longer outputs if needed } ) # Craft the prompt carefully for exact-match outputs prompt = f"""You are solving a GAIA benchmark evaluation question. ⚠️ VERY IMPORTANT: - ONLY return the final answer, exactly as required. - DO NOT include explanations, prefixes, or notes. - Format the answer exactly as asked (e.g., comma-separated, plural, in requested order). - If the question asks for a list, give only the list, no intro. Here’s the question: {question} Your direct answer:""" # Run the model response = llm.invoke(prompt) # Clean up whitespace or stray characters return response.strip()