diff --git a/langchain_g4f/G4FLLM.py b/langchain_g4f/G4FLLM.py index 03ed2e0..3544d63 100644 --- a/langchain_g4f/G4FLLM.py +++ b/langchain_g4f/G4FLLM.py @@ -14,7 +14,7 @@ class G4FLLM(LLM): # Provider.Provider provider: Optional[ModuleType] = None auth: Optional[Union[str, bool]] = None - create_kwargs: Optional[dict] = None + create_kwargs: Optional[dict[str, Any]] = None @property def _llm_type(self) -> str: @@ -28,20 +28,19 @@ class G4FLLM(LLM): **kwargs: Any, ) -> str: create_kwargs = {} if self.create_kwargs is None else self.create_kwargs.copy() - if self.model is not None: - create_kwargs["model"] = self.model + create_kwargs["model"] = self.model if self.provider is not None: create_kwargs["provider"] = self.provider if self.auth is not None: create_kwargs["auth"] = self.auth - text = ChatCompletion.create( + text = ChatCompletion.create( # type: ignore messages=[{"role": "user", "content": prompt}], **create_kwargs, ) - if stop is not None: - text = enforce_stop_tokens(text, stop) - return text + if stop is not None and type(stop) is str: + text = enforce_stop_tokens(text, stop) # type: ignore + return text # type: ignore @property def _identifying_params(self) -> Mapping[str, Any]: diff --git a/langchain_g4f/__init__.py b/langchain_g4f/__init__.py index 94015df..ebb9446 100644 --- a/langchain_g4f/__init__.py +++ b/langchain_g4f/__init__.py @@ -1 +1,3 @@ from .G4FLLM import G4FLLM + +__all__ = ["G4FLLM"] diff --git a/pyrightconfig.json b/pyrightconfig.json new file mode 100644 index 0000000..8321d3d --- /dev/null +++ b/pyrightconfig.json @@ -0,0 +1,4 @@ +{ + "reportMissingTypeStubs": "information", + "reportUnknownMemberType": "information" +}