Add LLMChain component for running queries against

LLMs
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-11-02 22:46:15 -03:00
commit c23d797677

View file

@ -0,0 +1,24 @@
from langflow import CustomComponent
from langchain.chains import LLMChain
from typing import Optional, Union, Callable
from langflow.field_typing import PromptTemplate, BaseLanguageModel, BaseMemory, Chain
class LLMChainComponent(CustomComponent):
display_name = "LLMChain"
description = "Chain to run queries against LLMs"
def build_config(self):
return {
"prompt": {"display_name": "Prompt"},
"llm": {"display_name": "LLM"},
"memory": {"display_name": "Memory"},
}
def build(
self,
prompt: PromptTemplate,
llm: BaseLanguageModel,
memory: Optional[BaseMemory],
) -> Union[Chain, Callable]:
return LLMChain(prompt=prompt, llm=llm, memory=memory)