Add LLMChain component for running queries against
LLMs
This commit is contained in:
parent
d87b6228df
commit
c23d797677
1 changed files with 24 additions and 0 deletions
24
src/backend/langflow/components/chains/LLMChain.py
Normal file
24
src/backend/langflow/components/chains/LLMChain.py
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue