tabbyAPI-ollama/common/actions.py
TerminalMan 3aeddc5255
fix issues with optional dependencies (#204)
* fix issues with optional dependencies

* format document

* Tree: Format and comment
2024-09-19 22:24:55 -04:00

27 lines
821 B
Python

import json
from loguru import logger
from common.tabby_config import config, generate_config_file
from endpoints.server import export_openapi
def branch_to_actions() -> bool:
"""Checks if a optional action needs to be run."""
if config.actions.export_openapi:
openapi_json = export_openapi()
with open(config.actions.openapi_export_path, "w") as f:
f.write(json.dumps(openapi_json))
logger.info(
"Successfully wrote OpenAPI spec to "
+ f"{config.actions.openapi_export_path}"
)
elif config.actions.export_config:
generate_config_file(filename=config.actions.config_export_path)
else:
# did not branch
return False
# branched and ran an action
return True