fix return service config to get/config/callbacks

This commit is contained in:
Ishaan Jaff 2024-04-13 14:34:51 -07:00
parent 885ae139b8
commit 39ed7dfa5d

View file

@ -8226,15 +8226,58 @@ async def update_config(config_info: ConfigYAML):
async def get_config():
"""
For Admin UI - allows admin to view config via UI
# return the callbacks and the env variables for the callback
"""
global llm_router, llm_model_list, general_settings, proxy_config, proxy_logging_obj, master_key
try:
import base64
config_data = await proxy_config.get_config()
config_data = config_data.get("litellm_settings", {})
_litellm_settings = config_data.get("litellm_settings", {})
environment_variables = config_data.get("environment_variables", {})
return {"data": config_data, "status": "success"}
# check if "langfuse" in litellm_settings
_success_callbacks = _litellm_settings.get("success_callback", [])
_data_to_return = []
"""
[
{
"name": "langfuse",
"variables": {
"LANGFUSE_PUB_KEY": "value",
"LANGFUSE_SECRET_KEY": "value",
"LANGFUSE_HOST": "value"
},
}
]
"""
for _callback in _success_callbacks:
if _callback == "langfuse":
_langfuse_vars = [
"LANGFUSE_PUBLIC_KEY",
"LANGFUSE_SECRET_KEY",
"LANGFUSE_HOST",
]
_langfuse_env_vars = {}
for _var in _langfuse_vars:
env_variable = environment_variables.get(_var, None)
if env_variable is None:
_langfuse_env_vars[_var] = None
else:
# decode + decrypt the value
decoded_b64 = base64.b64decode(env_variable)
_decrypted_value = decrypt_value(
value=decoded_b64, master_key=master_key
)
_langfuse_env_vars[_var] = _decrypted_value
_data_to_return.append(
{"name": _callback, "variables": _langfuse_env_vars}
)
return {"status": "success", "data": _data_to_return}
except Exception as e:
traceback.print_exc()
if isinstance(e, HTTPException):