0
0
mirror of https://github.com/MIDORIBIN/langchain-gpt4free.git synced 2024-12-23 19:22:58 +03:00

style: type strictness

This commit is contained in:
MIDORIBIN 2023-08-13 12:41:58 +09:00
parent 138abc4a30
commit 9d0b4d013e
3 changed files with 12 additions and 7 deletions

View File

@ -14,7 +14,7 @@ class G4FLLM(LLM):
# Provider.Provider # Provider.Provider
provider: Optional[ModuleType] = None provider: Optional[ModuleType] = None
auth: Optional[Union[str, bool]] = None auth: Optional[Union[str, bool]] = None
create_kwargs: Optional[dict] = None create_kwargs: Optional[dict[str, Any]] = None
@property @property
def _llm_type(self) -> str: def _llm_type(self) -> str:
@ -28,20 +28,19 @@ class G4FLLM(LLM):
**kwargs: Any, **kwargs: Any,
) -> str: ) -> str:
create_kwargs = {} if self.create_kwargs is None else self.create_kwargs.copy() 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: if self.provider is not None:
create_kwargs["provider"] = self.provider create_kwargs["provider"] = self.provider
if self.auth is not None: if self.auth is not None:
create_kwargs["auth"] = self.auth create_kwargs["auth"] = self.auth
text = ChatCompletion.create( text = ChatCompletion.create( # type: ignore
messages=[{"role": "user", "content": prompt}], messages=[{"role": "user", "content": prompt}],
**create_kwargs, **create_kwargs,
) )
if stop is not None: if stop is not None and type(stop) is str:
text = enforce_stop_tokens(text, stop) text = enforce_stop_tokens(text, stop) # type: ignore
return text return text # type: ignore
@property @property
def _identifying_params(self) -> Mapping[str, Any]: def _identifying_params(self) -> Mapping[str, Any]:

View File

@ -1 +1,3 @@
from .G4FLLM import G4FLLM from .G4FLLM import G4FLLM
__all__ = ["G4FLLM"]

4
pyrightconfig.json Normal file
View File

@ -0,0 +1,4 @@
{
"reportMissingTypeStubs": "information",
"reportUnknownMemberType": "information"
}