mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-20 13:54:48 +00:00
Harrison/delete bad code (#253)
This commit is contained in:
parent
db58032973
commit
ac2c2f6f28
@ -1,9 +1,8 @@
|
|||||||
"""Experiment with different models."""
|
"""Experiment with different models."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import List, Optional, Sequence, Union
|
from typing import List, Optional, Sequence
|
||||||
|
|
||||||
from langchain.agents.agent import Agent
|
|
||||||
from langchain.chains.base import Chain
|
from langchain.chains.base import Chain
|
||||||
from langchain.chains.llm import LLMChain
|
from langchain.chains.llm import LLMChain
|
||||||
from langchain.input import get_color_mapping, print_text
|
from langchain.input import get_color_mapping, print_text
|
||||||
@ -14,32 +13,29 @@ from langchain.prompts.prompt import PromptTemplate
|
|||||||
class ModelLaboratory:
|
class ModelLaboratory:
|
||||||
"""Experiment with different models."""
|
"""Experiment with different models."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(self, chains: Sequence[Chain], names: Optional[List[str]] = None):
|
||||||
self, chains: Sequence[Union[Chain, Agent]], names: Optional[List[str]] = None
|
|
||||||
):
|
|
||||||
"""Initialize with chains to experiment with.
|
"""Initialize with chains to experiment with.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chains: list of chains to experiment with.
|
chains: list of chains to experiment with.
|
||||||
"""
|
"""
|
||||||
for chain in chains:
|
for chain in chains:
|
||||||
if not isinstance(chain, (Chain, Agent)):
|
if not isinstance(chain, Chain):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"ModelLaboratory should now be initialized with Chains or Agents. "
|
"ModelLaboratory should now be initialized with Chains. "
|
||||||
"If you want to initialize with LLMs, use the `from_llms` method "
|
"If you want to initialize with LLMs, use the `from_llms` method "
|
||||||
"instead (`ModelLaboratory.from_llms(...)`)"
|
"instead (`ModelLaboratory.from_llms(...)`)"
|
||||||
)
|
)
|
||||||
if isinstance(chain, Chain):
|
if len(chain.input_keys) != 1:
|
||||||
if len(chain.input_keys) != 1:
|
raise ValueError(
|
||||||
raise ValueError(
|
"Currently only support chains with one input variable, "
|
||||||
"Currently only support chains with one input variable, "
|
f"got {chain.input_keys}"
|
||||||
f"got {chain.input_keys}"
|
)
|
||||||
)
|
if len(chain.output_keys) != 1:
|
||||||
if len(chain.output_keys) != 1:
|
raise ValueError(
|
||||||
raise ValueError(
|
"Currently only support chains with one output variable, "
|
||||||
"Currently only support chains with one output variable, "
|
f"got {chain.output_keys}"
|
||||||
f"got {chain.output_keys}"
|
)
|
||||||
)
|
|
||||||
if names is not None:
|
if names is not None:
|
||||||
if len(names) != len(chains):
|
if len(names) != len(chains):
|
||||||
raise ValueError("Length of chains does not match length of names.")
|
raise ValueError("Length of chains does not match length of names.")
|
||||||
|
Loading…
Reference in New Issue
Block a user