pagezyhf's picture
pagezyhf HF Staff
t
5073271
raw
history blame
1.58 kB
import gradio as gr
import requests
import json
import logging
import os
# Set up logging
logging.basicConfig(level=logging.INFO)
def get_model_info(model_id="Qwen/Qwen2-7B-Instruct", hf_token=os.getenv('HF_TOKEN')):
url = f"https://huggingface.co/api/integrations/aws/v1/lookup/{model_id}"
headers = {
"Authorization": f"Bearer {hf_token}",
"Content-Type": "application/json",
"User-Agent": "Mozilla/5.0", # Add a standard user agent
"Accept": "application/json"
}
logging.info(f"Requesting model info for model ID: {model_id}")
logging.info(f"URL: {url}")
response = requests.get(url, headers=headers)
logging.info(f"Response Status: {response.status_code}")
logging.info(f"Response Headers: {response.headers}")
logging.info(f"Response Text: {response.text}")
if response.status_code != 200:
logging.error(f"Error: {response.status_code} - {response.text}")
return f"Error: {response.status_code}\\nResponse: {response.text}"
data = response.json()
logging.info("Successfully retrieved model info.")
return json.dumps(data, indent=4)
iface = gr.Interface(
fn=lambda model_id: get_model_info(model_id, hf_token=os.getenv('HF_TOKEN')),
inputs=gr.Textbox(label="Model ID", placeholder="HuggingFaceH4/zephyr-7b-beta"),
outputs=gr.Textbox(label="API Response", lines=20),
title="Hugging Face Model Lookup",
description="Enter a model ID to retrieve its AWS integration details from Hugging Face."
)
if __name__ == "__main__":
iface.launch()