Spaces:
Sleeping
Sleeping
Upload inference.py with huggingface_hub
Browse files- inference.py +14 -0
inference.py
CHANGED
|
@@ -23,6 +23,20 @@ import json
|
|
| 23 |
import time
|
| 24 |
import requests
|
| 25 |
from openai import OpenAI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# βββ Configuration ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 28 |
|
|
|
|
| 23 |
import time
|
| 24 |
import requests
|
| 25 |
from openai import OpenAI
|
| 26 |
+
from pathlib import Path
|
| 27 |
+
|
| 28 |
+
# βββ Load Environment Variables from .env if it exists βββββββββββ
|
| 29 |
+
env_file = Path(__file__).parent / ".env"
|
| 30 |
+
if env_file.exists():
|
| 31 |
+
with open(env_file) as f:
|
| 32 |
+
for line in f:
|
| 33 |
+
line = line.strip()
|
| 34 |
+
if line and not line.startswith("#"):
|
| 35 |
+
key, _, value = line.partition("=")
|
| 36 |
+
key = key.strip()
|
| 37 |
+
value = value.strip()
|
| 38 |
+
if key and value:
|
| 39 |
+
os.environ.setdefault(key, value)
|
| 40 |
|
| 41 |
# βββ Configuration ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 42 |
|