CoolFace
Apppublic

FacundoSander/PdfQA

sourceHugging Faceupdated 3y agoView on Hugging Face
1likes
api.cpython-310.pyc18 linesDownload Raw Back to __pycache__
1o

2އUde�@s�ddlmZmZmZmZmZddlmZddlm	Z	ddl3mZmZm
Z
ddlmZddlmZddlZe�Zejded	d4�d	d�e�d�d
d��Ze�d�ed�ed�ed�ed�ed�fdededededef5dd��ZdS)�)�FastAPI�File�6UploadFile�Form�
HTTPException)�FileResponse)�escape)�create_qa_object�7get_answer�get_source_documents)�StaticFiles)rNz/staticZstatic)�	directory)�name�/c�s(�ztd�WStytddd��w)Nzstatic/index.htmli�zFile not found)�status_codeZdetail)r�FileNotFoundErrorr�rr�GC:\Users\facun\OneDrive\Escritorio\aprendiendo\aprendiendo\webQA\api.py�get_index_html
s�8�rz/ask.�stuff��api_key�file�query�9chain_type�kc10�s|�|tjd<tdd��}|�|��IdH�Wd�n1s wYtd||�}t||�}t||�}t|�}	||	d�S)NZOPENAI_API_KEYztemp.pdf�wb)�answer�source)	�os�environ�open�write�readr	r11rr)12rrrrr�bufferZqarrZescaped_sourcerrr�asks�13�141516r%)ZfastapirrrrrZfastapi.responsesr�htmlr�mainr	r17rZfastapi.staticfilesrr�appZmount�getrZpost�str�intr%rrrr�<module>s18D