Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
openlm.py33 linesDownload Raw Back to llms
1from typing import Any, Dict2 3from langchain_core.utils import pre_init4 5from langchain_community.llms.openai import BaseOpenAI6 7 8class OpenLM(BaseOpenAI):9    """OpenLM models."""10 11    @classmethod12    def is_lc_serializable(cls) -> bool:13        return False14 15    @property16    def _invocation_params(self) -> Dict[str, Any]:17        return {**{"model": self.model_name}, **super()._invocation_params}18 19    @pre_init20    def validate_environment(cls, values: Dict) -> Dict:21        try:22            import openlm23 24            values["client"] = openlm.Completion25        except ImportError:26            raise ImportError(27                "Could not import openlm python package. "28                "Please install it with `pip install openlm`."29            )30        if values["streaming"]:31            raise ValueError("Streaming not supported with openlm")32        return values33 
codekingpro/portable-devtools · Team Ai