Delete app.py
Browse files
app.py
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import gradio as gr
|
3 |
-
import requests
|
4 |
-
|
5 |
-
API_URL = "https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta"
|
6 |
-
HF_TOKEN = os.environ["HF_TOKEN"]
|
7 |
-
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
|
8 |
-
|
9 |
-
def generate_from_prompt(prompt):
|
10 |
-
payload = {
|
11 |
-
"inputs": prompt,
|
12 |
-
"parameters": {
|
13 |
-
"max_new_tokens": 180,
|
14 |
-
"temperature": 0.9,
|
15 |
-
"top_p": 0.95,
|
16 |
-
"do_sample": True
|
17 |
-
}
|
18 |
-
}
|
19 |
-
|
20 |
-
response = requests.post(API_URL, headers=headers, json=payload)
|
21 |
-
output = response.json()
|
22 |
-
|
23 |
-
if isinstance(output, list) and "generated_text" in output[0]:
|
24 |
-
return output[0]["generated_text"]
|
25 |
-
elif "generated_text" in output:
|
26 |
-
return output["generated_text"]
|
27 |
-
else:
|
28 |
-
return "⚠️ Erreur : aucune réponse utile."
|
29 |
-
|
30 |
-
iface = gr.Interface(
|
31 |
-
fn=generate_from_prompt,
|
32 |
-
inputs=gr.Textbox(label="Prompt complet", lines=10),
|
33 |
-
outputs="text",
|
34 |
-
title="IA hypnopoétique •°○",
|
35 |
-
description="Ce Space s'utilise avec un serveur externe (ex: Node.js) qui envoie un prompt déjà rédigé."
|
36 |
-
)
|
37 |
-
|
38 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|