Skip to content

Commit

Permalink
Autopopulate module name in cli init (langchain-ai#12814)
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis authored Nov 3, 2023
1 parent 98aff29 commit 0da75b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions libs/cli/langchain_cli/namespaces/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ def new(
package_dir = destination_dir / module_name
shutil.move(destination_dir / "package_template", package_dir)

# update init
init = package_dir / "__init__.py"
init_contents = init.read_text()
init.write_text(init_contents.replace("__module_name__", module_name))

# replace readme
readme = destination_dir / "README.md"
readme_contents = readme.read_text()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from chain import chain
from __module_name__.chain import chain

__all__ = ["chain"]

0 comments on commit 0da75b9

Please sign in to comment.