Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,18 @@
|
|
1 |
-
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
7 |
|
8 |
def generate_response(prompt):
|
9 |
response = generator(prompt, max_length=200)
|
10 |
return response[0]["generated_text"]
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
title="Waste Reuse AI",
|
17 |
-
description="This AI suggests reuse ideas for waste items."
|
18 |
-
)
|
19 |
-
|
20 |
-
iface.launch()
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
+
from huggingface_hub import login
|
3 |
|
4 |
+
# OPTIONAL: Authenticate with your Hugging Face API token (if needed)
|
5 |
+
# login("your_huggingface_api_token_here")
|
6 |
+
|
7 |
+
# Load the Mistral-7B-Instruct model
|
8 |
+
model_name = "mistralai/Mistral-7B-Instruct"
|
9 |
+
generator = pipeline("text-generation", model=model_name, device="cpu") # Change "cpu" to "cuda" if using a GPU
|
10 |
|
11 |
def generate_response(prompt):
|
12 |
response = generator(prompt, max_length=200)
|
13 |
return response[0]["generated_text"]
|
14 |
|
15 |
+
# Example Usage
|
16 |
+
if __name__ == "__main__":
|
17 |
+
user_prompt = "How can I reuse a plastic bottle?"
|
18 |
+
print("AI Suggestion:", generate_response(user_prompt))
|
|
|
|
|
|
|
|
|
|