Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PALChain loading fails #5224

Closed
2 of 14 tasks
liangz1 opened this issue May 25, 2023 · 0 comments · Fixed by #5343
Closed
2 of 14 tasks

PALChain loading fails #5224

liangz1 opened this issue May 25, 2023 · 0 comments · Fixed by #5343

Comments

@liangz1
Copy link
Contributor

liangz1 commented May 25, 2023

System Info

langchain==0.0.176

Who can help?

@hwchase17

Information

  • The official example notebooks/scripts
  • My own modified scripts

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

from langchain.chains import PALChain
from langchain import OpenAI

llm = OpenAI(temperature=0, max_tokens=512)
pal_chain = PALChain.from_math_prompt(llm, verbose=True)
question = "Jan has three times the number of pets as Marcia. Marcia has two more pets than Cindy. If Cindy has four pets, how many total pets do the three have?"
pal_chain.save("/Users/liang.zhang/pal_chain.yaml")
loaded_chain = load_chain("/Users/liang.zhang/pal_chain.yaml")

Error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [17], in <cell line: 1>()
----> 1 loaded_chain = load_chain("/Users/liang.zhang/pal_chain.yaml")

File ~/miniforge3/envs/mlflow-3.8/lib/python3.8/site-packages/langchain/chains/loading.py:449, in load_chain(path, **kwargs)
    447     return hub_result
    448 else:
--> 449     return _load_chain_from_file(path, **kwargs)

File ~/miniforge3/envs/mlflow-3.8/lib/python3.8/site-packages/langchain/chains/loading.py:476, in _load_chain_from_file(file, **kwargs)
    473     config["memory"] = kwargs.pop("memory")
    475 # Load the chain from the config now.
--> 476 return load_chain_from_config(config, **kwargs)

File ~/miniforge3/envs/mlflow-3.8/lib/python3.8/site-packages/langchain/chains/loading.py:439, in load_chain_from_config(config, **kwargs)
    436     raise ValueError(f"Loading {config_type} chain not supported")
    438 chain_loader = type_to_loader_dict[config_type]
--> 439 return chain_loader(config, **kwargs)

File ~/miniforge3/envs/mlflow-3.8/lib/python3.8/site-packages/langchain/chains/loading.py:234, in _load_pal_chain(config, **kwargs)
    232 if "llm" in config:
    233     llm_config = config.pop("llm")
--> 234     llm = load_llm_from_config(llm_config)
    235 elif "llm_path" in config:
    236     llm = load_llm(config.pop("llm_path"))

File ~/miniforge3/envs/mlflow-3.8/lib/python3.8/site-packages/langchain/llms/loading.py:14, in load_llm_from_config(config)
     12 def load_llm_from_config(config: dict) -> BaseLLM:
     13     """Load LLM from Config Dict."""
---> 14     if "_type" not in config:
     15         raise ValueError("Must specify an LLM Type in config")
     16     config_type = config.pop("_type")

TypeError: argument of type 'NoneType' is not iterable

Expected behavior

No errors should occur.

hwchase17 pushed a commit that referenced this issue May 29, 2023
# Removed deprecated llm attribute for load_chain

Currently `load_chain` for some chain types expect `llm` attribute to be
present but `llm` is deprecated attribute for those chains and might not
be persisted during their `chain.save`.

Fixes #5224
[(issue)](#5224)

## Who can review?
@hwchase17
@dev2049

---------

Co-authored-by: imeckr <chandanroutray2012@gmail.com>
vowelparrot pushed a commit that referenced this issue May 31, 2023
# Removed deprecated llm attribute for load_chain

Currently `load_chain` for some chain types expect `llm` attribute to be
present but `llm` is deprecated attribute for those chains and might not
be persisted during their `chain.save`.

Fixes #5224
[(issue)](#5224)

## Who can review?
@hwchase17
@dev2049

---------

Co-authored-by: imeckr <chandanroutray2012@gmail.com>
Undertone0809 pushed a commit to Undertone0809/langchain that referenced this issue Jun 19, 2023
# Removed deprecated llm attribute for load_chain

Currently `load_chain` for some chain types expect `llm` attribute to be
present but `llm` is deprecated attribute for those chains and might not
be persisted during their `chain.save`.

Fixes langchain-ai#5224
[(issue)](langchain-ai#5224)

## Who can review?
@hwchase17
@dev2049

---------

Co-authored-by: imeckr <chandanroutray2012@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant