| import requests
|
|
|
| API_URL = "https://api-inference.huggingface.co/models/Tejash9/DataDetectiveAI"
|
| API_TOKEN = "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"
|
|
|
| headers = {
|
| "Authorization": f"Bearer {API_TOKEN}"
|
| }
|
|
|
| def query_huggingface(payload):
|
| try:
|
| response = requests.post(API_URL, headers=headers, json=payload, timeout=30)
|
| response.raise_for_status()
|
| return response.json()
|
| except requests.exceptions.Timeout:
|
| return "Error: Request timed out after 30 seconds."
|
| except requests.exceptions.RequestException as e:
|
| return f"Error: {e}"
|
|
|
| if __name__ == "__main__":
|
| user_input = input("Enter your question: ")
|
| data = {"inputs": user_input}
|
|
|
| print("Sending request...")
|
| result = query_huggingface(data)
|
| print("Response from model:")
|
| print(result)
|
|
|