Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Set up the Hugging Face model pipeline (text generation or QA)
|
| 5 |
+
st.title("🤖📟 Arduino Expert Chatbot")
|
| 6 |
+
st.markdown("Get help with Arduino code, circuit diagrams, and projects.")
|
| 7 |
+
|
| 8 |
+
# Load the model (e.g., 'mistralai/Mixtral-8x7B-Instruct-v0.1' or any suitable)
|
| 9 |
+
@st.cache_resource
|
| 10 |
+
def load_model():
|
| 11 |
+
return pipeline("text-generation", model="mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 12 |
+
|
| 13 |
+
model = load_model()
|
| 14 |
+
|
| 15 |
+
# User input
|
| 16 |
+
query = st.text_area("Ask your Arduino question here 👇", height=150)
|
| 17 |
+
|
| 18 |
+
if st.button("Get Answer"):
|
| 19 |
+
if query:
|
| 20 |
+
with st.spinner("Thinking... 🤖"):
|
| 21 |
+
response = model(query, max_length=512, do_sample=True, temperature=0.7)
|
| 22 |
+
st.success(response[0]['generated_text'])
|
| 23 |
+
else:
|
| 24 |
+
st.warning("Please enter a question about your Arduino project.")
|
| 25 |
+
|
| 26 |
+
# Footer
|
| 27 |
+
st.markdown("---")
|
| 28 |
+
st.markdown("Made with ❤️ using Hugging Face and Streamlit")
|