PdfSumGPT / app.py
Qifan Zhang
complete version 1.0
806d7c6
raw
history blame
474 Bytes
import gradio as gr
from utils.chatgpt import ChatGPTAPI
from utils.read_pdf import read_pdf
def process(api_key: str = '', prompt: str = '', file=None) -> str:
chatgpt = ChatGPTAPI(api_key, max_input_length=1024)
pdf_contents = read_pdf(file.name)
pdf_str = '\n'.join(pdf_contents)
content = prompt + '\n' + pdf_str
response = chatgpt(content)
return response
gr.Interface(fn=process, inputs=["text", "text", "file"], outputs="text").launch()