File size: 1,515 Bytes
47cc341
a2e8619
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from transformers import pipeline

# Configure the page
st.set_page_config(page_title="Freelance Contract Guard", page_icon="🛡️")

st.title("🛡️ Freelance Contract Guard")
st.markdown("""
Analyze your freelance contracts for risky **Non-Compete** clauses. 
This tool uses a fine-tuned BERT model to identify predatory language.
""")

# Load your model from the Hub
@st.cache_resource
def load_model():
    # Linking to your specific repository
    return pipeline("text-classification", model="Musadiq7860/contract-guard-ai")

classifier = load_model()

# UI Input
user_text = st.text_area("Paste a contract clause here:", height=200, placeholder="e.g., The freelancer shall not provide services to any competitor...")

if st.button("Check for Risk"):
    if user_text.strip():
        with st.spinner("Analyzing legal risks..."):
            result = classifier(user_text)[0]
            label = result['label']
            score = result['score']
            
            # Assuming LABEL_1 is your 'Risky' class from training
            if label == "LABEL_1":
                st.error(f"⚠️ **RISK DETECTED:** This looks like a Non-Compete clause! (Confidence: {score:.2f})")
                st.info("💡 Non-compete clauses can limit your future work. You may want to negotiate this section.")
            else:
                st.success(f"✅ **SAFE:** No non-compete detected. (Confidence: {score:.2f})")
    else:
        st.warning("Please enter some text to analyze.")