forked from Archives/langchain
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
717 B
Python
29 lines
717 B
Python
"""Fake LLM wrapper for testing purposes."""
|
|
from typing import Any, List, Mapping, Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from langchain.llms.base import LLM
|
|
|
|
|
|
class FakeListLLM(LLM, BaseModel):
|
|
"""Fake LLM wrapper for testing purposes."""
|
|
|
|
responses: List
|
|
i: int = 0
|
|
|
|
@property
|
|
def _llm_type(self) -> str:
|
|
"""Return type of llm."""
|
|
return "fake-list"
|
|
|
|
def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str:
|
|
"""First try to lookup in queries, else return 'foo' or 'bar'."""
|
|
response = self.responses[self.i]
|
|
self.i += 1
|
|
return response
|
|
|
|
@property
|
|
def _identifying_params(self) -> Mapping[str, Any]:
|
|
return {}
|