xl2533's picture
Duplicate from xl2533/WhatToAsk
8c6710d
raw
history blame contribute delete
830 Bytes
# -*-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)