ai01firebird commited on
Commit
e8a2d7c
·
verified ·
1 Parent(s): 9e3391d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
+ import os
4
+
5
+ # API-Key aus den Secrets laden
6
+ HF_API_TOKEN = os.getenv("HUG_TOKEN_READ")
7
+
8
+ # Hugging Face Inference API Client
9
+ client = InferenceClient(model="mistralai/Mistral-7B-Instruct", token=HF_API_TOKEN)
10
+
11
+ # Funktion zur Emoji-Übersetzung
12
+ def text_to_emoji(text):
13
+ prompt = f"Übersetze diesen Satz in eine Emoji-Version:\n\n\"{text}\""
14
+ response = client.text_generation(prompt, max_new_tokens=50)
15
+ return response
16
+
17
+ # Gradio UI
18
+ iface = gr.Interface(
19
+ fn=text_to_emoji,
20
+ inputs=gr.Textbox(lines=2, placeholder="Gib einen Satz ein..."),
21
+ outputs="text",
22
+ title="KI-gestützter Emoji-Übersetzer",
23
+ description="Gib einen Satz ein, und die KI wandelt ihn in eine Emoji-Version um!"
24
+ )
25
+
26
+ iface.launch()