# -*- coding: utf-8 -*- """ Created on Fri Jun 16 23:31:34 2023 @author: Hua """ import gradio as gr from searchEmbeddings import search def searchEMA(inputs): results = search(inputs) outputs = f"(1) {results['Author Full Names'][4]} {results['Article Title'][4]} {results['Publication Year'][4]} \n [Abstract] {results['Abstract'][4]} \n(2) {results['Author Full Names'][3]} {results['Article Title'][3]} {results['Publication Year'][3]} \n [Abstract] {results['Abstract'][3]}" return outputs with gr.Blocks() as demo: gr.Markdown("瑞聚医学数字化设计与制造平台1.0") name = gr.Textbox(label = "Question", placeholder = "What is your problem?") output = gr.Textbox(label = "Recommended solution") greet_btn = gr.Button("Recommened solutions from ramGPT") greet_btn.click(fn=searchEMA, inputs=name, outputs=output, api_name="searchEMA") demo.launch(auth=("admin", "ramGPT"))