mirror of
https://github.com/hwchase17/langchain
synced 2024-10-29 17:07:25 +00:00
fd69cc7e42
Removed duplicate BaseModel dependencies in class inheritances. Also, sorted imports by `isort`.
29 lines
748 B
Python
29 lines
748 B
Python
"""Fake LLM wrapper for testing purposes."""
|
|
from typing import Any, List, Mapping, Optional
|
|
|
|
from langchain.llms.base import LLM
|
|
|
|
|
|
class FakeLLM(LLM):
|
|
"""Fake LLM wrapper for testing purposes."""
|
|
|
|
queries: Optional[Mapping] = None
|
|
|
|
@property
|
|
def _llm_type(self) -> str:
|
|
"""Return type of llm."""
|
|
return "fake"
|
|
|
|
def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str:
|
|
"""First try to lookup in queries, else return 'foo' or 'bar'."""
|
|
if self.queries is not None:
|
|
return self.queries[prompt]
|
|
if stop is None:
|
|
return "foo"
|
|
else:
|
|
return "bar"
|
|
|
|
@property
|
|
def _identifying_params(self) -> Mapping[str, Any]:
|
|
return {}
|