🚀 feat(langflow): add version endpoint to API
🐛 fix(langflow): fix version import error in version endpoint
The version endpoint is added to the API to allow clients to retrieve the version of the Langflow package. The version is obtained using the `metadata.version` function from the `importlib` module. In case the package metadata is not available, an empty string is returned. The version endpoint was previously returning an error due to an import error. The error is fixed by importing the `__version__` variable from the `langflow` module.
This commit is contained in:
parent
0eaa86c5ca
commit
efbdd6fee7
2 changed files with 11 additions and 1 deletions
|
|
@ -1,4 +1,12 @@
|
|||
from importlib import metadata
|
||||
from langflow.cache import cache_manager
|
||||
from langflow.processing.process import load_flow_from_json
|
||||
|
||||
try:
|
||||
__version__ = metadata.version(__package__)
|
||||
except metadata.PackageNotFoundError:
|
||||
# Case where package metadata is not available.
|
||||
__version__ = ""
|
||||
del metadata # optional, avoids polluting the results of dir(__package__)
|
||||
|
||||
__all__ = ["load_flow_from_json", "cache_manager"]
|
||||
|
|
|
|||
|
|
@ -41,4 +41,6 @@ async def get_load(predict_request: PredictRequest):
|
|||
# get endpoint to return version of langflow
|
||||
@router.get("/version")
|
||||
def get_version():
|
||||
return {"version": version("langflow")}
|
||||
from langflow import __version__
|
||||
|
||||
return {"version": __version__}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue