import pandas as pd import numpy as np import os from utils import * import gradio as gr data = pd.read_csv(os.path.join(os.getcwd(), "data_csv.csv")) documents = create_Doc(data) embedding = load_embedding() vectorstore = load_vectorstore(documents=documents, embeddings=embedding) def process(list_text, search_type = 'mmr'): list_text = eval(list_text) list_text = [title.lower() for title in list_text] # print(list_text) retrieve = vectorstore.as_retriever(search_type= search_type) retrieves = [] for i in list_text: # print(i) new_suggest = retrieve.invoke(i) for j in new_suggest: if j.metadata['name'].lower() != i: retrieves.append(j.metadata['name']) return retrieves if __name__ == "__main__": demo = gr.Interface(fn=process, inputs='text', outputs='text') demo.launch()