File size: 1,238 Bytes
9e57aa8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

# Load the pre-trained model and tokenizer
model = AutoModel.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)

# Upload your dataset
uploaded = files.upload()

# Load the dataset
filename = next(iter(uploaded))  # Automatically get the first uploaded file's name
df = pd.read_excel(filename)  # Read the uploaded Excel file

# Display the columns in the uploaded DataFrame to help identify correct names
print("Columns in the dataset:", df.columns.tolist())

# Function to search by name and return the PEC number
def search_by_name(name):
    name_matches = df[df['Name'].str.contains(name, case=False, na=False)]
    if not name_matches.empty:
        return f"Your PEC number: {name_matches['PEC No'].values[0]}"
    else:
        return "No matches found for your name."

# Gradio interface with the updated syntax
iface = gr.Interface(
    fn=search_by_name,
    inputs=gr.Textbox(label="Please write your Name"),
    outputs=gr.Textbox(label="Your PEC number"),
    title="PEC Number Lookup",
    description="Enter your name to find your PEC number."
)

# Launch the Gradio interface
iface.launch()