Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -287,6 +287,7 @@ async def extract_text_from_file(file: UploadFile) -> str:
|
|
| 287 |
logger.info(f"Processing file: {filename}, size: {len(content)} bytes, MIME type: {mime_type}")
|
| 288 |
|
| 289 |
try:
|
|
|
|
| 290 |
# PDF processing with fallback mechanisms
|
| 291 |
if mime_type == 'application/pdf' or filename.endswith('.pdf'):
|
| 292 |
try:
|
|
@@ -665,4 +666,16 @@ async def generate_creative_text(prompt: str) -> str:
|
|
| 665 |
"temperature": 0.8,
|
| 666 |
"top_p": 0.95,
|
| 667 |
"top_k": 40,
|
| 668 |
-
"max_output_tokens":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
logger.info(f"Processing file: {filename}, size: {len(content)} bytes, MIME type: {mime_type}")
|
| 288 |
|
| 289 |
try:
|
| 290 |
+
suc
|
| 291 |
# PDF processing with fallback mechanisms
|
| 292 |
if mime_type == 'application/pdf' or filename.endswith('.pdf'):
|
| 293 |
try:
|
|
|
|
| 666 |
"temperature": 0.8,
|
| 667 |
"top_p": 0.95,
|
| 668 |
"top_k": 40,
|
| 669 |
+
"max_output_tokens": 1024 # Fixed value
|
| 670 |
+
}
|
| 671 |
+
|
| 672 |
+
# Call the Gemini model
|
| 673 |
+
response = chatbot.generate_content(
|
| 674 |
+
enhanced_prompt,
|
| 675 |
+
generation_config=generation_config
|
| 676 |
+
)
|
| 677 |
+
return response.text
|
| 678 |
+
|
| 679 |
+
except Exception as e:
|
| 680 |
+
logger.error(f"Text generation failed: {str(e)}")
|
| 681 |
+
raise HTTPException(status_code=500, detail=f"Text generation failed: {str(e)}")
|