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