Spaces:
Runtime error
Runtime error
File size: 1,283 Bytes
6069cd9 f125ab8 6069cd9 f8aee80 f125ab8 f8aee80 f125ab8 6069cd9 947138e 4959346 d4d76ad 6069cd9 f125ab8 9cf7084 db6a7e9 cef7f1c 7494883 06adc35 cbef904 ce6b290 1912f97 f125ab8 7c6c718 cef7f1c f125ab8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
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):
#query =[[inputs[0]],[inputs[1]]
examples=[['My name is Sarah and I live in London','Where do I live?']]
return model1(examples)
demo = gr.Blocks()
with demo:
inputs=[gr.inputs.Textbox(lines=40, default=context, label="Context paragraph"),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?")
inputs[1].change(fn=f1,
inputs=inputs,
outputs=out1)
b1.click(fn=f1, inputs=inputs, outputs=out1)
demo.launch() |