Spaces:
Sleeping
Sleeping
Commit
·
26d8ef2
1
Parent(s):
4e20ec4
🔧 Fix 'str expected, not NoneType' startup error
Browse files✅ Problem solved:
• Fixed LANGFUSE environment variable assignment in knowledge_graph_tester.py
• Added null checks before setting os.environ values
• Only set env vars when values are not None
🎯 Root cause:
• Lines 40-41 unconditionally set LANGFUSE_PUBLIC_KEY/SECRET_KEY to environ
• These could be None, causing TypeError in os.environ assignment
• Added proper null validation
⚡ Result:
• Backend server now starts successfully
• No more TypeError: str expected, not NoneType
• Ready for HF Spaces deployment
.gitignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__/
|
| 2 |
+
*.py[cod]
|
| 3 |
+
*.class
|
| 4 |
+
logs/
|
| 5 |
+
*.log
|
| 6 |
+
datasets/
|
| 7 |
+
db/
|
| 8 |
+
cache/
|
| 9 |
+
evaluation_results/
|
agentgraph/testing/knowledge_graph_tester.py
CHANGED
|
@@ -30,15 +30,19 @@ logger = logging.getLogger(__name__)
|
|
| 30 |
# Import LiteLLM
|
| 31 |
from litellm import completion
|
| 32 |
|
| 33 |
-
# API Key setup
|
| 34 |
-
|
|
|
|
| 35 |
DEFAULT_MODEL = "gpt-4.1-mini"
|
| 36 |
|
| 37 |
|
| 38 |
from utils.config import LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_AUTH, LANGFUSE_HOST
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
if LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY:
|
|
|
|
| 30 |
# Import LiteLLM
|
| 31 |
from litellm import completion
|
| 32 |
|
| 33 |
+
# API Key setup - only set if value exists
|
| 34 |
+
if OPENAI_API_KEY:
|
| 35 |
+
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
|
| 36 |
DEFAULT_MODEL = "gpt-4.1-mini"
|
| 37 |
|
| 38 |
|
| 39 |
from utils.config import LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_AUTH, LANGFUSE_HOST
|
| 40 |
|
| 41 |
+
# Only set environment variables if they have values (not None)
|
| 42 |
+
if LANGFUSE_PUBLIC_KEY:
|
| 43 |
+
os.environ["LANGFUSE_PUBLIC_KEY"] = LANGFUSE_PUBLIC_KEY
|
| 44 |
+
if LANGFUSE_SECRET_KEY:
|
| 45 |
+
os.environ["LANGFUSE_SECRET_KEY"] = LANGFUSE_SECRET_KEY
|
| 46 |
|
| 47 |
|
| 48 |
if LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY:
|