danielritchie commited on
Commit
1ad7061
·
verified ·
1 Parent(s): b9c512e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -1,21 +1,24 @@
1
  import gradio as gr
2
 
3
- # Load your LLaMA model using gr.load
4
  model = gr.load("models/meta-llama/Llama-3.2-1B")
5
 
6
  # Function to generate responses from the model
7
  def chatbot_response(input_text):
8
- # Call the model directly through gr.load, assuming the model accepts simple text input
9
  response = model(input_text)
10
  return response
11
 
12
- # Create the Gradio interface
13
  with gr.Blocks() as demo:
14
- chatbot = gr.Chatbot() # This is for displaying the conversation
 
 
15
  with gr.Row():
16
- txt = gr.Textbox(show_label=False, placeholder="Enter your message and press Enter").style(container=False)
 
17
 
18
- # When the user submits input, call the chatbot response function
19
  txt.submit(chatbot_response, txt, chatbot)
20
 
21
  # Launch the Gradio interface
 
1
  import gradio as gr
2
 
3
+ # Load your model using gr.load (assuming the model is hosted on Hugging Face)
4
  model = gr.load("models/meta-llama/Llama-3.2-1B")
5
 
6
  # Function to generate responses from the model
7
  def chatbot_response(input_text):
8
+ # Generate response from the model
9
  response = model(input_text)
10
  return response
11
 
12
+ # Create the Gradio Blocks interface
13
  with gr.Blocks() as demo:
14
+ # Use type='messages' for the Chatbot to avoid the deprecation warning
15
+ chatbot = gr.Chatbot(type='messages') # Updated to the 'messages' format
16
+
17
  with gr.Row():
18
+ # Remove the .style method, as it's no longer available
19
+ txt = gr.Textbox(show_label=False, placeholder="Enter your message and press Enter")
20
 
21
+ # Link the input to the chatbot response function and the Chatbot display
22
  txt.submit(chatbot_response, txt, chatbot)
23
 
24
  # Launch the Gradio interface