Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
|
|
2 |
import openai
|
3 |
import fitz # PyMuPDF for PDF processing
|
4 |
import base64
|
|
|
|
|
5 |
|
6 |
# Variable to store API key
|
7 |
api_key = ""
|
@@ -76,7 +78,10 @@ def image_chat(image_file, text_query, temperature, top_p, max_output_tokens):
|
|
76 |
]}
|
77 |
]
|
78 |
response = query_openai(messages, temperature, top_p, max_output_tokens)
|
79 |
-
|
|
|
|
|
|
|
80 |
|
81 |
# Function to process uploaded PDF input
|
82 |
def pdf_chat(pdf_file, text_query, temperature, top_p, max_output_tokens):
|
|
|
2 |
import openai
|
3 |
import fitz # PyMuPDF for PDF processing
|
4 |
import base64
|
5 |
+
from io import BytesIO
|
6 |
+
from PIL import Image
|
7 |
|
8 |
# Variable to store API key
|
9 |
api_key = ""
|
|
|
78 |
]}
|
79 |
]
|
80 |
response = query_openai(messages, temperature, top_p, max_output_tokens)
|
81 |
+
|
82 |
+
# Convert base64 image to PIL Image for display in Gradio
|
83 |
+
img = Image.open(BytesIO(base64.b64decode(base64_image)))
|
84 |
+
return response, img # Return image for Gradio to display
|
85 |
|
86 |
# Function to process uploaded PDF input
|
87 |
def pdf_chat(pdf_file, text_query, temperature, top_p, max_output_tokens):
|