|
8 | 8 | import requests, logging, os
|
9 | 9 | from dotenv import load_dotenv
|
10 | 10 |
|
| 11 | +# Set up logging |
| 12 | +logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
| 13 | + |
11 | 14 | # Load the environment variables from the .env file
|
12 | 15 | load_dotenv()
|
| 16 | + |
| 17 | +# Get the API URL from the environment variables |
| 18 | +api_url = os.getenv('DOCKER_API_URL') if os.getenv('RUNNING_IN_DOCKER') else os.getenv('LOCAL_API_URL') |
| 19 | + |
| 20 | +# Loggin api_url |
| 21 | +logging.info(f"API URL: {api_url}") |
| 22 | + |
13 | 23 | # Static token for the API
|
14 | 24 | STATIC_TOKEN = os.getenv("SERVICE_TOKEN")
|
15 | 25 | # Verify that the SERVICE_TOKEN is defined in the environment variables
|
16 | 26 | if STATIC_TOKEN is None:
|
17 | 27 | raise ValueError("The SERVICE_TOKEN environment variable is not defined")
|
18 | 28 |
|
19 |
| -# Set up logging |
20 |
| -logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
21 |
| - |
22 | 29 | # Default LLM configuration values
|
23 | 30 | DEFAULT_MAX_NEW_TOKENS = 100
|
24 | 31 | DEFAULT_DO_SAMPLE = True
|
@@ -115,7 +122,7 @@ def main():
|
115 | 122 | # Make a request to the API
|
116 | 123 | try:
|
117 | 124 | with st.spinner("The assistant is thinking..."):
|
118 |
| - response = requests.post("http://host.docker.internal:8000/api/v1/chat", headers=headers, json=data) |
| 125 | + response = requests.post(api_url, headers=headers, json=data) |
119 | 126 | logging.info(f"Response status code: {response.status_code}")
|
120 | 127 | logging.info(f"Response content: {response.content}")
|
121 | 128 | if response.status_code == 200:
|
|
0 commit comments