Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,24 @@
|
|
1 |
from transformers import pipeline
|
2 |
import streamlit as st
|
3 |
|
4 |
-
#
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Definiere die Streamlit-Oberfläche
|
8 |
st.title("Prompt Generator")
|
|
|
9 |
prompt = st.text_input("Gib einen Satzanfang ein:")
|
10 |
button = st.button("Generieren")
|
11 |
|
12 |
# Generiere neuen Text beim Klick auf den Button
|
13 |
if button:
|
14 |
-
|
|
|
15 |
st.write(text)
|
|
|
1 |
from transformers import pipeline
|
2 |
import streamlit as st
|
3 |
|
4 |
+
# Definition der Chatbots
|
5 |
+
chatbots = {
|
6 |
+
"GPT-Neo 2.7B": "EleutherAI/gpt-neo-2.7B",
|
7 |
+
"DialoGPT Small": "microsoft/DialoGPT-small"
|
8 |
+
}
|
9 |
+
|
10 |
+
# Funktion zum Abrufen des ausgewählten Chatbots
|
11 |
+
def get_chatbot(name):
|
12 |
+
return pipeline('text-generation', model=chatbots[name])
|
13 |
|
14 |
# Definiere die Streamlit-Oberfläche
|
15 |
st.title("Prompt Generator")
|
16 |
+
chatbot_name = st.selectbox("Wähle einen Chatbot aus:", list(chatbots.keys()))
|
17 |
prompt = st.text_input("Gib einen Satzanfang ein:")
|
18 |
button = st.button("Generieren")
|
19 |
|
20 |
# Generiere neuen Text beim Klick auf den Button
|
21 |
if button:
|
22 |
+
chatbot = get_chatbot(chatbot_name)
|
23 |
+
text = chatbot(prompt, max_length=30, do_sample=True, temperature=0.7)[0]['generated_text']
|
24 |
st.write(text)
|