awacke1's picture
Update app.py
cbef904
raw
history blame
1.16 kB
import gradio as gr
from transformers import pipeline
def SetContext(textfile):
context = ""
with open(textfile, 'r') as file:
context = file.read()
return context
context = SetContext('WritingCarePlans.txt') # open text file fill textbox
question = "What should be documented in a care plan?"
title = "Transformers - Sentence to Paragraph - For Mindfulness"
examples = [
["Break the cycle of stress and anxiety"],
["Feel calm in stressful situations"],
["Deal with work pressure"],
["Learn to reduce feelings of overwhelmed"]
]
model1 = gr.Interface.load("huggingface/deepset/roberta-base-squad2")
def f1(inputs):
return model1(inputs)
demo = gr.Blocks()
with demo:
ContextParagraph = gr.inputs.Textbox(lines=40, default=context, label="Context paragraph")
QuestionInput = gr.inputs.Textbox(lines=10, default=question, label="Question")
out1=gr.Textbox()
b1 = gr.Button("roberta")
#inp = gr.Textbox(placeholder="What is a care plan for?")
inputs1[1].change(fn=f1,
inputs=[ContextParagraph ,QuestionInput ]
outputs=out1)
demo.launch()