| | import json
|
| | import gradio as gr
|
| | from datasets import load_dataset
|
| |
|
| |
|
| | dataset = load_dataset("Biophin/datospreguntas")
|
| |
|
| |
|
| | base_conocimiento = dataset["train"]
|
| |
|
| |
|
| | def answer_question(question):
|
| | question = question.lower()
|
| | for item in base_conocimiento:
|
| | if question in item["pregunta"].lower():
|
| | return item["respuesta"]
|
| | return "Lo siento, no tengo una respuesta para esa pregunta."
|
| |
|
| |
|
| | interface = gr.Interface(
|
| | fn=answer_question,
|
| | inputs="text",
|
| | outputs="text",
|
| | title="Chatbot de Preguntas y Respuestas Mejorado",
|
| | description="Escribe una pregunta relacionada con el contenido del archivo JSON. El bot buscará la respuesta más relevante, incluso si no coincide exactamente con las preguntas almacenadas.",
|
| | )
|
| |
|
| |
|
| | interface.launch(share=True) |