[AUR-424] Setup CLI interface (#25)
* [AUR-424] Setup CLI interface * [AUR-424] fix test_vectorstore:test_query * [AUR-424] exclude examples when setup CLI * [AUR-424] create kh and kh --export * [AUR-426] revise cli by using click.group * Fix dynamic import * [AUR-426] revert the format of import packages * [AUR-426] set argument default * [AUR-426] set click dependencies in setup.py --------- Co-authored-by: trducng <trungduc1992@gmail.com>
This commit is contained in:
parent
6c3d614973
commit
317323c0e5
|
@ -0,0 +1,56 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
import click
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
from kotaemon.contribs.promptui.config import export_pipeline_to_config
|
||||||
|
from kotaemon.contribs.promptui.ui import build_from_dict
|
||||||
|
|
||||||
|
|
||||||
|
# check if the output is not a .yml file -> raise error
|
||||||
|
def check_config_format(config):
|
||||||
|
if os.path.exists(config):
|
||||||
|
if isinstance(config, str):
|
||||||
|
with open(config) as f:
|
||||||
|
yaml.safe_load(f)
|
||||||
|
else:
|
||||||
|
raise ValueError("config must be yaml format.")
|
||||||
|
|
||||||
|
|
||||||
|
@click.group()
|
||||||
|
def main():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@click.group()
|
||||||
|
def promptui():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
main.add_command(promptui)
|
||||||
|
|
||||||
|
|
||||||
|
@promptui.command()
|
||||||
|
@click.argument("export_path", nargs=1)
|
||||||
|
@click.option("--output", default="promptui.yml", required=False)
|
||||||
|
def export(export_path, output):
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from theflow.utils.modules import import_dotted_string
|
||||||
|
|
||||||
|
sys.path.append(os.getcwd())
|
||||||
|
cls = import_dotted_string(export_path, safe=False)
|
||||||
|
export_pipeline_to_config(cls, output)
|
||||||
|
check_config_format(output)
|
||||||
|
|
||||||
|
|
||||||
|
@promptui.command()
|
||||||
|
@click.argument("run_path", required=False, default="promptui.yml")
|
||||||
|
def run(run_path):
|
||||||
|
build_from_dict(run_path)
|
||||||
|
check_config_format(run_path)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
7
setup.py
7
setup.py
|
@ -26,7 +26,12 @@ setuptools.setup(
|
||||||
long_description=read("README.md"),
|
long_description=read("README.md"),
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
url="https://github.com/Cinnamon/kotaemon/",
|
url="https://github.com/Cinnamon/kotaemon/",
|
||||||
packages=setuptools.find_packages(exclude=("tests", "tests.*")),
|
packages=setuptools.find_packages(
|
||||||
|
exclude=("tests", "tests.*", "examples", "examples.*")
|
||||||
|
),
|
||||||
|
dependencies=[
|
||||||
|
"click >= 8.1.7",
|
||||||
|
],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"farm-haystack==1.19.0",
|
"farm-haystack==1.19.0",
|
||||||
"langchain",
|
"langchain",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user