2 Commits

2 changed files with 34 additions and 10 deletions
+20 -2
View File
@@ -1,22 +1,40 @@
# Frontend Configuration # Frontend Configuration
frontend: # frontend:
url: "http://localhost:5004" # url: "http://localhost:5004"
# Backend Configuration # Backend Configuration
backend: backend:
url: "http://localhost:5004" url: "http://localhost:5004"
api: "/api/chat" api: "/api/chat"
models:
- model: "AUTODETECT"
title: "Ollama"
url: "http://localhost:11434"
provider: "ollama"
- model: "AUTODETECT"
title: "Ollama-WARA"
url: "https://ollama-test.wara-ops.org"
requestOptions:
headers:
Authorization: "${OLLAMA_API_KEY}" # This should expand to something like "Basic XY...="
provider: "ollama"
# Ollama Server Configuration # Ollama Server Configuration
ollama: ollama:
title: "Ollama-local"
url: "http://localhost:11434" url: "http://localhost:11434"
api_key: "${OLLAMA_API_KEY}" # Refer to environment variable api_key: "${OLLAMA_API_KEY}" # Refer to environment variable
model: "phi3:mini" # Select a model supported by the Ollama server model: "phi3:mini" # Select a model supported by the Ollama server
# model: "llama3:70b" # Select a model supported by the Ollama server # model: "llama3:70b" # Select a model supported by the Ollama server
# model: "llama3.1:70b" # Select a model supported by the Ollama server
# model: "llama3.1:8b" # Select a model supported by the Ollama server
# model: "llama3:latest" # Select a model supported by the Ollama server # model: "llama3:latest" # Select a model supported by the Ollama server
# model: "mannix/llama3-8b-ablitered-v3:latest" # Select a model supported by the Ollama server # model: "mannix/llama3-8b-ablitered-v3:latest" # Select a model supported by the Ollama server
# model: "mistral-nemo:latest" # Select a model supported by the Ollama server # model: "mistral-nemo:latest" # Select a model supported by the Ollama server
# model: "gemma2:27b" # model: "gemma2:27b"
# model: "AUTODETECT"
# Logging comment out the whole section for default level which is INFO # Logging comment out the whole section for default level which is INFO
logging: logging:
+14 -8
View File
@@ -31,15 +31,22 @@ def configure():
return os.getenv(env_var_name, None) return os.getenv(env_var_name, None)
return value return value
def update_dict_with_env_vars(d): def update_value(value):
for key in d: if isinstance(value, dict): # Dictionaries need recursive check
if isinstance(d[key], dict): return update_dict_with_env_vars(value)
update_dict_with_env_vars(d[key]) # Recursively check nested dictionaries elif isinstance(value, list): # Lists must be traversed element by element
elif isinstance(d[key], str): return [update_value(item) for item in value]
d[key] = resolve_env_var(d[key]) elif isinstance(value, str): # If value is a string it might be an environmnet variable
return resolve_env_var(value)
else: # Anything else, just keep the old value
return value
def update_dict_with_env_vars(d): # Check all keys in d
for key in d: # Iterate over all keys in the dictionary. The keys seen are all at the same level
logger.info(f"key investigated now: {key}")
d[key] = update_value(d[key])
return d return d
# Update the config dictionary with resolved environment variables
updated_config = update_dict_with_env_vars(config) updated_config = update_dict_with_env_vars(config)
#################################### ####################################
@@ -64,7 +71,6 @@ def configure():
logger.debug(f"Constructing endpoint address as url+api: {url+api}") logger.debug(f"Constructing endpoint address as url+api: {url+api}")
global_state.set_backend_api_ep(url+api) # Extract API endpoint if defined and set in global_state global_state.set_backend_api_ep(url+api) # Extract API endpoint if defined and set in global_state
logger.debug(f"Backend API endpoint is set to {global_state.get_backend_api_ep()}") logger.debug(f"Backend API endpoint is set to {global_state.get_backend_api_ep()}")
# os.environ['BE_API_ENDPOINT'] = backend_api_ep # Look into alternative way to share this with backend.py
#################################### ####################################
# Extract Ollama parameters (url, api_key, model) # Extract Ollama parameters (url, api_key, model)