Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,9 @@ from transformers import pipeline
|
|
| 3 |
from PIL import Image
|
| 4 |
import requests
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
# Load OCR model for extracting text from images
|
| 7 |
@st.cache_resource
|
| 8 |
def load_ocr_model():
|
|
@@ -10,10 +13,9 @@ def load_ocr_model():
|
|
| 10 |
|
| 11 |
# Function to interact with ChatGPT API
|
| 12 |
def chat_with_gpt(prompt):
|
| 13 |
-
api_key = st.secrets["OPENAI_API_KEY"]
|
| 14 |
url = "https://api.openai.com/v1/completions"
|
| 15 |
headers = {
|
| 16 |
-
"Authorization": f"Bearer {
|
| 17 |
"Content-Type": "application/json",
|
| 18 |
}
|
| 19 |
data = {
|
|
|
|
| 3 |
from PIL import Image
|
| 4 |
import requests
|
| 5 |
|
| 6 |
+
# Hardcoded OpenAI API Key
|
| 7 |
+
OPENAI_API_KEY = "your_openai_api_key_here"
|
| 8 |
+
|
| 9 |
# Load OCR model for extracting text from images
|
| 10 |
@st.cache_resource
|
| 11 |
def load_ocr_model():
|
|
|
|
| 13 |
|
| 14 |
# Function to interact with ChatGPT API
|
| 15 |
def chat_with_gpt(prompt):
|
|
|
|
| 16 |
url = "https://api.openai.com/v1/completions"
|
| 17 |
headers = {
|
| 18 |
+
"Authorization": f"Bearer {OPENAI_API_KEY}",
|
| 19 |
"Content-Type": "application/json",
|
| 20 |
}
|
| 21 |
data = {
|