zebra12341/Final_Assignment
0
1import os2from huggingface_hub import HfAgent, HfAgentConfig3 4# — configure your agent model and token here —5MODEL_ID = "your-username/your-agent-final-template"6HF_TOKEN = os.getenv("HF_TOKEN")7 8agent = HfAgent.from_pretrained(9 MODEL_ID,10 token=HF_TOKEN,11 config=HfAgentConfig(12 verbose=False, # no log output13 return_full_text=False, # only generated text14 stop_sequences=["\n\n"] # cut off at double newline15 )16)17 18def answer_only(prompt: str) -> str:19 out = agent.run(prompt)20 return out.strip()21 22if __name__ == "__main__":23 # read questions from a file, one per line24 import sys25 path = sys.argv[1] # e.g. python final.py questions.txt26 with open(path) as f:27 questions = [q.strip() for q in f if q.strip()]28 29 for q in questions:30 print(answer_only(q))31 