Update handler.py
Browse files- handler.py +14 -0
handler.py
CHANGED
|
@@ -3,6 +3,20 @@ import openai
|
|
| 3 |
from environs import Env
|
| 4 |
from typing import List, Dict, Any
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# Load environment variables
|
| 7 |
env = Env()
|
| 8 |
env.read_env("openai.env")
|
|
|
|
| 3 |
from environs import Env
|
| 4 |
from typing import List, Dict, Any
|
| 5 |
|
| 6 |
+
|
| 7 |
+
import requests
|
| 8 |
+
|
| 9 |
+
def download_env_file(url: str, local_path: str):
|
| 10 |
+
response = requests.get(url)
|
| 11 |
+
response.raise_for_status() # Ensure we notice bad responses
|
| 12 |
+
with open(local_path, 'wb') as f:
|
| 13 |
+
f.write(response.content)
|
| 14 |
+
|
| 15 |
+
# Download the .env file
|
| 16 |
+
env_file_url = "https://www.dropbox.com/scl/fi/21ldek2cdsak2v3mhyy5x/openai.env?rlkey=nxdkd8l8esdy8npa3vfgvqkhp&st=s2f2zzwl&dl=1" # Adjusted URL for direct download
|
| 17 |
+
local_env_path = "openai.env"
|
| 18 |
+
download_env_file(env_file_url, local_env_path)
|
| 19 |
+
|
| 20 |
# Load environment variables
|
| 21 |
env = Env()
|
| 22 |
env.read_env("openai.env")
|