mlflow.set_registry_uri("databricks-uc")
model_name = f"SQL_chain"
with mlflow.start_run(run_name="sql_chain") as run:
user_query = "..."
answer = chain.invoke(user_query)
answer_json = json.dumps(answer)
signature = infer_signature(user_query, answer_json)
model_info = mlflow.langchain.log_model(
chain,
loader_fn=get_db,
artifact_path="chain",
registered_model_name=model_name,
pip_requirements=[
f"mlflow=={mlflow.__version__}",
f"langchain=={langchain.__version__}",
f"langchain_community=={langchain_community.__version__}",
f"langchain_experimental=={langchain_experimental.__version__}",
f"openai=={openai.__version__}",
f"langchain_core=={langchain_core.__version__}",
f"databricks",
f"databricks-sql-connector==2.9.3",
],
input_example=user_query,
signature=signature
)
</code>