Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
# Load your
|
| 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 |
-
#
|
| 9 |
response = model(input_text)
|
| 10 |
return response
|
| 11 |
|
| 12 |
-
# Create the Gradio interface
|
| 13 |
with gr.Blocks() as demo:
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
with gr.Row():
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
#
|
| 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
|