Spaces:
Running
Running
Alexander Watson
commited on
Commit
•
fdea16e
1
Parent(s):
0629e69
init openai for HF
Browse files- src/app.py +10 -2
src/app.py
CHANGED
@@ -31,8 +31,16 @@ st.set_page_config(
|
|
31 |
|
32 |
def initialize_openai_client(api_key):
|
33 |
"""Initialize OpenAI client with API key."""
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
def load_and_analyze_dataset(dataset_name):
|
38 |
"""Load dataset and perform initial analysis."""
|
|
|
31 |
|
32 |
def initialize_openai_client(api_key):
|
33 |
"""Initialize OpenAI client with API key."""
|
34 |
+
try:
|
35 |
+
# Basic initialization without any proxy settings
|
36 |
+
return OpenAI(api_key=api_key)
|
37 |
+
except Exception as e:
|
38 |
+
print(f"Error initializing OpenAI client: {e}")
|
39 |
+
# If that fails, try with default configuration
|
40 |
+
return OpenAI(
|
41 |
+
api_key=api_key,
|
42 |
+
default_headers={"User-Agent": "Dataset-Card-Generator"}
|
43 |
+
)
|
44 |
|
45 |
def load_and_analyze_dataset(dataset_name):
|
46 |
"""Load dataset and perform initial analysis."""
|