Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import io
|
|
2 |
import base64
|
3 |
import streamlit as st
|
4 |
import os
|
5 |
-
from
|
6 |
from PIL import Image
|
7 |
import requests
|
8 |
from io import BytesIO
|
@@ -114,16 +114,16 @@ st.markdown("""
|
|
114 |
</style>
|
115 |
""", unsafe_allow_html=True)
|
116 |
|
117 |
-
# Initialize the
|
118 |
@st.cache_resource
|
119 |
-
def
|
120 |
try:
|
121 |
-
return
|
122 |
except Exception as e:
|
123 |
st.error(f"Error initializing API client: {str(e)}")
|
124 |
return None
|
125 |
|
126 |
-
client =
|
127 |
|
128 |
# Load animations
|
129 |
lottie_telecom = load_lottie("https://assets4.lottiefiles.com/packages/lf20_qz3tpn4w.json")
|
|
|
2 |
import base64
|
3 |
import streamlit as st
|
4 |
import os
|
5 |
+
from openai import OpenAI
|
6 |
from PIL import Image
|
7 |
import requests
|
8 |
from io import BytesIO
|
|
|
114 |
</style>
|
115 |
""", unsafe_allow_html=True)
|
116 |
|
117 |
+
# Initialize the OpenAI client with error handling
|
118 |
@st.cache_resource
|
119 |
+
def get_openai_client():
|
120 |
try:
|
121 |
+
return OpenAI(api_key=st.secrets["api_key"], base_url="https://api.together.xyz")
|
122 |
except Exception as e:
|
123 |
st.error(f"Error initializing API client: {str(e)}")
|
124 |
return None
|
125 |
|
126 |
+
client = get_openai_client()
|
127 |
|
128 |
# Load animations
|
129 |
lottie_telecom = load_lottie("https://assets4.lottiefiles.com/packages/lf20_qz3tpn4w.json")
|