Connected GPT-2 model for APFM-GPT
Browse files
app.py
CHANGED
|
@@ -1,17 +1,17 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
reply = "🤖 APFM-GPT says: " + message
|
| 6 |
-
history.append((message, reply))
|
| 7 |
-
return history, history
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
clear = gr.Button("Clear Chat")
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load a basic language model
|
| 5 |
+
chatbot = pipeline("text-generation", model="gpt2")
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
def respond(message):
|
| 8 |
+
response = chatbot(message, max_length=100, num_return_sequences=1)
|
| 9 |
+
return response[0]['generated_text']
|
|
|
|
| 10 |
|
| 11 |
+
with gr.Blocks() as demo:
|
| 12 |
+
gr.Markdown("# 🤖 APFM-GPT: Your Personal AI Assistant")
|
| 13 |
+
msg = gr.Textbox(label="Ask me anything...")
|
| 14 |
+
out = gr.Textbox(label="Response")
|
| 15 |
+
msg.submit(respond, msg, out)
|
| 16 |
|
| 17 |
demo.launch()
|