Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py für Hugging Face Space
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from huggingface_hub import InferenceClient
|
| 4 |
+
|
| 5 |
+
client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.3")
|
| 6 |
+
|
| 7 |
+
def get_relevance(industry: str, article_topic: str) -> str:
|
| 8 |
+
prompt = f"""Erkläre in 2-3 prägnanten Sätzen auf Deutsch,
|
| 9 |
+
warum das Thema "{article_topic}" für jemanden aus dem Bereich "{industry}"
|
| 10 |
+
praktisch relevant ist. Sei konkret und praxisbezogen."""
|
| 11 |
+
|
| 12 |
+
response = client.text_generation(
|
| 13 |
+
prompt,
|
| 14 |
+
max_new_tokens=200,
|
| 15 |
+
temperature=0.7
|
| 16 |
+
)
|
| 17 |
+
return response
|
| 18 |
+
|
| 19 |
+
demo = gr.Interface(
|
| 20 |
+
fn=get_relevance,
|
| 21 |
+
inputs=[
|
| 22 |
+
gr.Textbox(label="Dein Bereich", placeholder="z.B. Logistik, Maschinenbau..."),
|
| 23 |
+
gr.Textbox(label="Artikel-Thema", value="Large Language Models in der Praxis")
|
| 24 |
+
],
|
| 25 |
+
outputs=gr.Textbox(label="Relevanz für dich"),
|
| 26 |
+
title="🤖 Relevanz-Check",
|
| 27 |
+
theme=gr.themes.Soft()
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
demo.launch()
|