atifsial123 commited on
Commit
e403126
1 Parent(s): 80e0122

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -13
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
- # Example Gradio function
18
- def search_by_name(name):
19
- # Your logic to search by name and return a response
20
- pass
 
 
 
 
 
 
 
 
 
21
 
22
  # Gradio interface
23
- iface = gr.Interface(
24
- fn=search_by_name,
25
- inputs=gr.Textbox(label="Please write your Name"),
26
- outputs=gr.Textbox(label="Your PEC number"),
27
- title="PEC Number Lookup",
28
- description="Enter your name to find your PEC number."
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