Spaces:
Sleeping
Sleeping
File size: 664 Bytes
289e125 f5dcbeb 289e125 |
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 |
from fastmcp import FastMCP
from huggingface_hub import ModelCard
from dotenv import load_dotenv
load_dotenv()
import os,json
HF_TOKEN=os.getenv("HF_TOKEN")
mcp=FastMCP("model_card-chatbot")
@mcp.tool()
def read_model_card(repo_id:str)->str:
"""Tool to read and return the full model card from hugging face."""
try:
card=ModelCard.load(repo_id)
return json.dumps({"status":"success","readme": card.text})
except FileNotFoundError:
return json.dumps({"status":"error","message":"This model does not have a model card"})
except Exception as e:
return json.dumps({"status":"error","message":str(e)})
|