mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-06 05:25:04 +00:00
cli[minor]: Fix bug to account for name changes (#20948)
* Fix bug to account for name changes / aliases * Generate migration list from langchain to langchain_core
This commit is contained in:
@@ -4,7 +4,7 @@ import pkgutil
|
||||
|
||||
import click
|
||||
|
||||
from langchain_cli.namespaces.migrate.generate.langchain import (
|
||||
from langchain_cli.namespaces.migrate.generate.generic import (
|
||||
generate_simplified_migrations,
|
||||
)
|
||||
from langchain_cli.namespaces.migrate.generate.partner import (
|
||||
@@ -19,15 +19,27 @@ def cli():
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option(
|
||||
"--pkg1",
|
||||
default="langchain",
|
||||
)
|
||||
@click.option(
|
||||
"--pkg2",
|
||||
default="langchain_community",
|
||||
)
|
||||
@click.option(
|
||||
"--output",
|
||||
default="langchain_migrations.json",
|
||||
default=None,
|
||||
help="Output file for the migration script.",
|
||||
)
|
||||
def langchain(output: str) -> None:
|
||||
def generic(pkg1: str, pkg2: str, output: str) -> None:
|
||||
"""Generate a migration script."""
|
||||
click.echo("Migration script generated.")
|
||||
migrations = generate_simplified_migrations()
|
||||
migrations = generate_simplified_migrations(pkg1, pkg2)
|
||||
|
||||
if output is None:
|
||||
output = f"{pkg1}_to_{pkg2}.json"
|
||||
|
||||
with open(output, "w") as f:
|
||||
f.write(json.dumps(migrations, indent=2, sort_keys=True))
|
||||
|
||||
|
Reference in New Issue
Block a user