Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,20 +14,35 @@ import gradio as gr
|
|
| 14 |
model = AutoModel.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)
|
| 15 |
tokenizer = AutoTokenizer.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
def
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# Gradio interface
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
# Launch the interface
|
| 32 |
-
iface.launch()
|
| 33 |
|
|
|
|
| 14 |
model = AutoModel.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)
|
| 15 |
tokenizer = AutoTokenizer.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)
|
| 16 |
|
| 17 |
+
# Function to load dataset (adjust this function if your dataset is complex)
|
| 18 |
+
def load_dataset():
|
| 19 |
+
df = pd.read_excel("your_dataset.xlsx") # Ensure this file exists in your working directory
|
| 20 |
+
print("Columns in the dataset:", df.columns.tolist())
|
| 21 |
+
return df
|
| 22 |
+
|
| 23 |
+
# Example function to search by name and return the PEC number
|
| 24 |
+
def search_by_name(name, df):
|
| 25 |
+
name_matches = df[df['Name'].str.contains(name, case=False, na=False)]
|
| 26 |
+
if not name_matches.empty:
|
| 27 |
+
return f"Your PEC number: {name_matches['PEC No'].values[0]}"
|
| 28 |
+
else:
|
| 29 |
+
return "No matches found for your name."
|
| 30 |
|
| 31 |
# Gradio interface
|
| 32 |
+
def build_interface():
|
| 33 |
+
df = load_dataset() # Load your dataset
|
| 34 |
+
iface = gr.Interface(
|
| 35 |
+
fn=lambda name: search_by_name(name, df),
|
| 36 |
+
inputs=gr.Textbox(label="Please write your Name"),
|
| 37 |
+
outputs=gr.Textbox(label="Your PEC number"),
|
| 38 |
+
title="PEC Number Lookup",
|
| 39 |
+
description="Enter your name to find your PEC number."
|
| 40 |
+
)
|
| 41 |
+
return iface
|
| 42 |
+
|
| 43 |
+
# Main function to run the Gradio app
|
| 44 |
+
if __name__ == "__main__":
|
| 45 |
+
iface = build_interface()
|
| 46 |
+
iface.launch()
|
| 47 |
|
|
|
|
|
|
|
| 48 |
|