Spaces:
Sleeping
Sleeping
# -*-coding:utf-8 -*- | |
import os | |
import gradio as gr | |
from qa import * | |
with gr.Blocks(title="QA Generation", theme=gr.themes.Glass()) as demo: | |
openai_key = gr.Textbox(type='password', label='输入 API key') | |
gr.Markdown("## Question Answer Generation") | |
with gr.Row(): | |
input = gr.Textbox(label='上下文') | |
qa = gr.JSON(label='问题&回答对') | |
gen = gr.Button(value='generate') | |
gr.Markdown('## Answer Generation') | |
with gr.Row(): | |
context = gr.Textbox(label='上下文') | |
question = gr.Textbox(label ='问题') | |
answer = gr.Textbox(label='答案') | |
ask = gr.Button(value='ask') | |
## Callback | |
gen.click(get_qa, [input, openai_key], [qa]) | |
ask.click(get_answer, [context, question, openai_key], [answer]) | |
# launch | |
demo.queue().launch(debug=True) |