import gradio as gr import functions as fn import json data = fn.load_embeddings() num_documents = data['num_documents'] num_segment_contents = data['num_segment_contents'] with open("gradio.json") as f: config = json.load(f) config['description'] = config['description'].format(num_documents=num_documents, num_segment_contents=num_segment_contents) config['title'] += " - Interface de Respostas Detalhadas" def on_submit(query, history): response = fn.rag_response(query, data=data, detailed_response=True) return gr.HTML(response.replace("\n", "
")) demo = gr.ChatInterface(fn=on_submit, **config) demo.launch()