Spaces:
Running
Running
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,39 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import requests
|
| 3 |
-
import os
|
| 4 |
-
|
| 5 |
-
# Hugging Face token (Settings → Variables → New Variable → Key: HF_API_KEY)
|
| 6 |
-
HF_API_KEY = os.getenv("HF_API_KEY")
|
| 7 |
-
|
| 8 |
-
def ask_model(prompt):
|
| 9 |
-
headers = {
|
| 10 |
-
"Authorization": f"Bearer {HF_API_KEY}",
|
| 11 |
-
"Content-Type": "application/json",
|
| 12 |
-
}
|
| 13 |
-
data = {"inputs": prompt}
|
| 14 |
-
|
| 15 |
-
# ✅ Yeni endpoint — artık sadece bu kullanılacak
|
| 16 |
-
API_URL = "https://router.huggingface.co/hf-inference/models/mistralai/Mistral-7B-Instruct-v0.2"
|
| 17 |
-
|
| 18 |
-
response = requests.post(API_URL, headers=headers, json=data)
|
| 19 |
-
|
| 20 |
-
if response.status_code == 200:
|
| 21 |
-
output = response.json()
|
| 22 |
-
if isinstance(output, list) and "generated_text" in output[0]:
|
| 23 |
-
return output[0]["generated_text"]
|
| 24 |
-
else:
|
| 25 |
-
return str(output)
|
| 26 |
-
else:
|
| 27 |
-
return f"Error: {response.status_code} - {response.text}"
|
| 28 |
-
|
| 29 |
-
iface = gr.Interface(
|
| 30 |
-
fn=ask_model,
|
| 31 |
-
inputs="text",
|
| 32 |
-
outputs="text",
|
| 33 |
-
title="Flutter AI Proxy",
|
| 34 |
-
description="Flutter uygulaman buraya istek atacak, model yanıt dönecek."
|
| 35 |
-
)
|
| 36 |
-
|
| 37 |
-
iface.launch()
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|