Spaces:
Sleeping
Sleeping
Create app
Browse files
app
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the model pipeline
|
| 5 |
+
@st.cache_resource()
|
| 6 |
+
def load_model():
|
| 7 |
+
return pipeline("text2text-generation", model="Salesforce/codet5p-220m")
|
| 8 |
+
|
| 9 |
+
model = load_model()
|
| 10 |
+
|
| 11 |
+
# Streamlit UI
|
| 12 |
+
st.title("CodeCorrect AI")
|
| 13 |
+
st.subheader("AI-powered Code Autocorrect Tool")
|
| 14 |
+
|
| 15 |
+
code_input = st.text_area("Enter your code here:", height=200)
|
| 16 |
+
|
| 17 |
+
if st.button("Correct Code"):
|
| 18 |
+
if code_input.strip():
|
| 19 |
+
response = model(code_input, max_length=512)
|
| 20 |
+
corrected_code = response[0]['generated_text']
|
| 21 |
+
st.text_area("Corrected Code:", corrected_code, height=200)
|
| 22 |
+
else:
|
| 23 |
+
st.warning("Please enter some code.")
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
|