Spaces:
Runtime error

jsakshi commited on
Commit
0d9a2a0
·
verified ·
1 Parent(s): 24474a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -30
app.py CHANGED
@@ -1,30 +1,8 @@
1
- import gradio as gr
2
- from transformers import AutoModelForCausalLM, AutoTokenizer
3
-
4
- # Load the Llama 7B model
5
- model_name = "huggyllama/llama-7b"
6
- tokenizer = AutoTokenizer.from_pretrained(model_name)
7
- model = AutoModelForCausalLM.from_pretrained(model_name)
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)