Spaces:
Running
Running
import streamlit as st | |
import requests | |
HF_BACKEND_URL = "https://your-backend-url.hf.space" # Update with your backend link | |
st.title("π Plagiarism & AI Detector") | |
# Function to safely call API | |
def fetch_api_response(url, params=None, files=None): | |
try: | |
if files: | |
response = requests.post(url, files=files) | |
else: | |
response = requests.post(url, params=params) | |
if response.status_code == 200: | |
return response.json() | |
else: | |
return {"error": f"API Error: {response.status_code} - {response.text}"} | |
except requests.exceptions.RequestException as e: | |
return {"error": f"Request Failed: {str(e)}"} | |
# Text Plagiarism | |
st.subheader("π Check Text Plagiarism") | |
text = st.text_area("Enter text to check for plagiarism") | |
if st.button("Check Plagiarism"): | |
result = fetch_api_response(f"{HF_BACKEND_URL}/check_text", params={"text": text}) | |
st.json(result) | |
# Code Plagiarism | |
st.subheader("π» Check Code Plagiarism") | |
code = st.text_area("Paste code to check plagiarism") | |
if st.button("Check Code Plagiarism"): | |
result = fetch_api_response(f"{HF_BACKEND_URL}/check_code", params={"code": code}) | |
st.json(result) | |
# AI Detection | |
st.subheader("π€ Detect AI-Generated Content") | |
ai_text = st.text_area("Enter text to check AI detection") | |
if st.button("Detect AI"): | |
result = fetch_api_response(f"{HF_BACKEND_URL}/detect_ai", params={"text": ai_text}) | |
st.json(result) | |
# PDF Upload | |
st.subheader("π Upload PDF for Plagiarism Check") | |
pdf = st.file_uploader("Upload a PDF file", type=["pdf"]) | |
if pdf: | |
files = {"file": pdf.getvalue()} | |
result = fetch_api_response(f"{HF_BACKEND_URL}/upload_pdf", files=files) | |
st.json(result) | |