import numpy as np from sentence_transformers import SentenceTransformer from sklearn.metrics.pairwise import cosine_similarity from shiny import App, render, ui import pandas as pd # Initialize the sentence transformer model model = SentenceTransformer('all-MiniLM-L6-v2') # Sample queries #queries = [ # "What is the weather today?", # "How to learn Python?", # "Best practices for data science.", # "What is the capital of France?", # "How to cook pasta?", # ... (other queries) #] queries = pd.read_excel("egu_session_descriptions.xlsx").Description titles = pd.read_excel("egu_session_descriptions.xlsx").Title ids = pd.read_excel("egu_session_descriptions.xlsx").ID ids = [int(num) for num in ids] prefix = "https://meetingorganizer.copernicus.org/EGU25/session/" # Create a new list with the URL prefix added to each number urls = [f"{prefix}{num}" for num in ids] # The column to display as results # Precompute embeddings for the queries query_embeddings = model.encode(queries) # Define the UI app_ui = ui.page_fluid( ui.h3("EGU25 AI-session recommender"), ui.card( ui.card_header("How to use"), ui.p("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lore.")), ui.input_text_area("user_input", "Enter your text:", placeholder="Paste abstract", width = "100%"), ui.input_action_button("submit", "Get session recommendations", class_="btn btn-primary"), ui.HTML("