Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,8 @@
|
|
| 1 |
-
|
| 2 |
-
from transformers import
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
def chatbot(user_input):
|
| 10 |
-
inputs = tokenizer(user_input, return_tensors="pt")
|
| 11 |
-
outputs = model.generate(**inputs, max_length=100, num_beams=3)
|
| 12 |
-
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 13 |
-
return response
|
| 14 |
-
|
| 15 |
-
# Gradio interface for the chatbot
|
| 16 |
-
with gr.Blocks() as demo:
|
| 17 |
-
gr.Markdown("# Welcome to LocoBot!")
|
| 18 |
-
chatbot_ui = gr.Chatbot()
|
| 19 |
-
text_input = gr.Textbox(label="Type your message")
|
| 20 |
-
submit_button = gr.Button("Send")
|
| 21 |
-
|
| 22 |
-
def respond(message, chat_history):
|
| 23 |
-
bot_response = chatbot(message)
|
| 24 |
-
chat_history.append(("User", message))
|
| 25 |
-
chat_history.append(("LocoBot", bot_response))
|
| 26 |
-
return chat_history, ""
|
| 27 |
-
|
| 28 |
-
submit_button.click(respond, [text_input, chatbot_ui], [chatbot_ui, text_input])
|
| 29 |
-
|
| 30 |
-
demo.launch()
|
|
|
|
| 1 |
+
# Use a pipeline as a high-level helper
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
messages = [
|
| 5 |
+
{"role": "user", "content": "Who are you?"},
|
| 6 |
+
]
|
| 7 |
+
pipe = pipeline("text-generation", model="deepseek-ai/DeepSeek-R1", trust_remote_code=True)
|
| 8 |
+
pipe(messages)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|