mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-20 05:43:55 +00:00
parent
88bc15d69b
commit
88891477eb
@ -5,6 +5,7 @@ from pathlib import Path
|
|||||||
import rich
|
import rich
|
||||||
import typer
|
import typer
|
||||||
from gritql import run
|
from gritql import run
|
||||||
|
from typer import Option
|
||||||
|
|
||||||
|
|
||||||
def get_gritdir_path() -> Path:
|
def get_gritdir_path() -> Path:
|
||||||
@ -15,6 +16,17 @@ def get_gritdir_path() -> Path:
|
|||||||
|
|
||||||
def migrate(
|
def migrate(
|
||||||
ctx: typer.Context,
|
ctx: typer.Context,
|
||||||
|
# Using diff instead of dry-run for backwards compatibility with the old CLI
|
||||||
|
diff: bool = Option(
|
||||||
|
False,
|
||||||
|
"--diff",
|
||||||
|
help="Show the changes that would be made without applying them.",
|
||||||
|
),
|
||||||
|
interactive: bool = Option(
|
||||||
|
False,
|
||||||
|
"--interactive",
|
||||||
|
help="Prompt for confirmation before making each change",
|
||||||
|
),
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Migrate langchain to the most recent version.
|
"""Migrate langchain to the most recent version.
|
||||||
|
|
||||||
@ -47,9 +59,15 @@ def migrate(
|
|||||||
rich.print("-" * 10)
|
rich.print("-" * 10)
|
||||||
rich.print()
|
rich.print()
|
||||||
|
|
||||||
|
args = list(ctx.args)
|
||||||
|
if interactive:
|
||||||
|
args.append("--interactive")
|
||||||
|
if diff:
|
||||||
|
args.append("--dry-run")
|
||||||
|
|
||||||
final_code = run.apply_pattern(
|
final_code = run.apply_pattern(
|
||||||
"langchain_all_migrations()",
|
"langchain_all_migrations()",
|
||||||
ctx.args,
|
args,
|
||||||
grit_dir=get_gritdir_path(),
|
grit_dir=get_gritdir_path(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "langchain-cli"
|
name = "langchain-cli"
|
||||||
version = "0.0.30"
|
version = "0.0.31"
|
||||||
description = "CLI for interacting with LangChain"
|
description = "CLI for interacting with LangChain"
|
||||||
authors = ["Erick Friis <erick@langchain.dev>"]
|
authors = ["Erick Friis <erick@langchain.dev>"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
Loading…
Reference in New Issue
Block a user