File size: 1,740 Bytes
5bee5f1
f0cd87e
5bee5f1
1547aeb
5bee5f1
f0cd87e
5bee5f1
1547aeb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f0cd87e
 
 
 
1547aeb
 
5bee5f1
f0cd87e
 
 
 
1547aeb
 
5bee5f1
f0cd87e
 
 
 
1547aeb
 
5bee5f1
f0cd87e
 
 
 
 
1547aeb
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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)