diff --git a/src/backend/langflow/components/custom_components/custom.py b/src/backend/langflow/components/custom_components/custom.py new file mode 100644 index 000000000..3ebc5bda8 --- /dev/null +++ b/src/backend/langflow/components/custom_components/custom.py @@ -0,0 +1,21 @@ +from langflow import CustomComponent + +from langchain.llms.base import BaseLLM +from langchain.chains import LLMChain +from langchain import PromptTemplate +from langchain.schema import Document + +import requests + +class YourComponent(CustomComponent): + display_name: str = "Custom Component" + description: str = "My description" + + def build_config(self): + return { "url": { "multiline": True, "required": True } } + + def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document: + response = requests.get(url) + chain = LLMChain(llm=llm, prompt=prompt) + result = chain.run(response.text[:300]) + return Document(page_content=str(result))