Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,9 +4,14 @@ from groq import Groq
|
|
| 4 |
from pypdf import PdfReader
|
| 5 |
import io
|
| 6 |
import uvicorn
|
| 7 |
-
|
| 8 |
app = FastAPI()
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Initialize Groq client
|
| 11 |
client = Groq(api_key="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")
|
| 12 |
|
|
@@ -28,10 +33,8 @@ Given the following document text, do 3 things:
|
|
| 28 |
1. Identify the document type (invoice, receipt, contract, report, certificate, etc.)
|
| 29 |
2. Extract key fields in JSON format.
|
| 30 |
3. Provide a short summary.
|
| 31 |
-
|
| 32 |
Document text:
|
| 33 |
{text}
|
| 34 |
-
|
| 35 |
Return your answer in this JSON structure:
|
| 36 |
{{
|
| 37 |
"document_type": "",
|
|
|
|
| 4 |
from pypdf import PdfReader
|
| 5 |
import io
|
| 6 |
import uvicorn
|
| 7 |
+
|
| 8 |
app = FastAPI()
|
| 9 |
|
| 10 |
+
# Root route required by Hugging Face to detect the app
|
| 11 |
+
@app.get("/")
|
| 12 |
+
def root():
|
| 13 |
+
return {"status": "ok", "message": "API is running"}
|
| 14 |
+
|
| 15 |
# Initialize Groq client
|
| 16 |
client = Groq(api_key="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")
|
| 17 |
|
|
|
|
| 33 |
1. Identify the document type (invoice, receipt, contract, report, certificate, etc.)
|
| 34 |
2. Extract key fields in JSON format.
|
| 35 |
3. Provide a short summary.
|
|
|
|
| 36 |
Document text:
|
| 37 |
{text}
|
|
|
|
| 38 |
Return your answer in this JSON structure:
|
| 39 |
{{
|
| 40 |
"document_type": "",
|