Emojinator / app.py
ai01firebird's picture
Update app.py
d063632 verified
raw
history blame
856 Bytes
import gradio as gr
from huggingface_hub import InferenceClient
import os
# API-Key aus den Secrets laden
HF_API_TOKEN = os.getenv("HUG_TOKEN_READ")
# Hugging Face Inference API Client
client = InferenceClient(model="mistralai/Mistral-7B-Instruct-v0.1", token=HF_API_TOKEN)
# Funktion zur Emoji-Übersetzung
def text_to_emoji(text):
prompt = f"Convert this sentence into an Emoji-Sequence of the same meaning and return only the emojis, no explanation:\n\n\"{text}\""
response = client.text_generation(prompt, max_new_tokens=50)
return response
# Gradio UI
iface = gr.Interface(
fn=text_to_emoji,
inputs=gr.Textbox(lines=2, placeholder="Gib einen Satz ein..."),
outputs="text",
title="KI-gestützter Emoji-Übersetzer",
description="Gib einen Satz ein, und die KI wandelt ihn in eine Emoji-Version um!"
)
iface.launch()