Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,19 @@
|
|
1 |
-
|
2 |
-
import
|
3 |
import gradio as gr
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
chat_history_ids = model.generate(bot_input_ids, max_length=1000, pad_token_id=tokenizer.eos_token_id)
|
21 |
-
|
22 |
-
# Decode the last output tokens from bot
|
23 |
-
response = tokenizer.decode(chat_history_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens=True)
|
24 |
-
|
25 |
-
# Update the chat history with the new user message and bot response
|
26 |
-
chat_history.append([message, response])
|
27 |
-
|
28 |
-
return response
|
29 |
-
|
30 |
-
demo = gr.ChatInterface(
|
31 |
-
fn=chat_with_history,
|
32 |
-
examples=["hey how are you ?", "hola", "Yo!"],
|
33 |
-
title="Multi Chat Bot"
|
34 |
-
)
|
35 |
-
|
36 |
-
demo.launch()
|
|
|
1 |
+
# Use a pipeline as a high-level helper
|
2 |
+
from transformers import pipeline
|
3 |
import gradio as gr
|
4 |
|
5 |
+
pipe = pipeline("text-generation", model="Gustavosta/MagicPrompt-Stable-Diffusion")
|
6 |
+
|
7 |
+
def genPrompt(text: str, total: int):
|
8 |
+
total = int(total)
|
9 |
+
ret = None
|
10 |
+
for i in range(0, total):
|
11 |
+
txt = pipe(text, max_length=1000, min_length=50)[0].get("generated_text").replace("\n", " ")
|
12 |
+
if not ret:
|
13 |
+
ret = txt
|
14 |
+
else:
|
15 |
+
ret = f"{ret}\n\n{txt}"
|
16 |
+
return ret
|
17 |
+
|
18 |
+
appli = gr.Interface(fn=genPrompt, inputs=[gr.Text(),gr.Slider(0, 10, 4)], outputs="text")
|
19 |
+
appli.launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|