langflow-ai / langflow

⛓️ Langflow is a visual framework for building multi-agent and RAG applications. It's open-source, Python-powered, fully customizable, model and vector store agnostic.
http://www.langflow.org
MIT License
20.23k stars 2.99k forks source link

Whether to support flow development based on API #1588

Open whwhw opened 3 months ago

whwhw commented 3 months ago

My scenario does not require a front-end page and is more suitable for simple configuration development. Does langflow provide some APIs that allow developers to define components through API interaction without using pages, thereby generating flow and json files? There doesn't seem to be an API for defining and generating streams in the official documentation I've seen so far, only an API for running through json.

dosubot[bot] commented 3 months ago

Hey @whwhw, nice to see you back in the matrix of issues! Hope you're ready for some more digital adventures. 🚀

Based on the information available in the langflow repository, it appears that langflow does provide an API for programmatically defining components and generating flows and JSON files, without the need for a front-end interface. This is suggested by the existence of a FastAPI router setup that includes a flows_router, which implies the presence of endpoints related to managing flows programmatically. You can find this in the router.py file.

The flows_router in the langflow API provides several endpoints that support operations such as creating, reading, updating, and deleting flows. These operations can be performed programmatically without the need for a front-end interface. You can find more details about these endpoints in the flows.py file.

However, the exact structure and required fields of the FlowCreate object, which is used to create new flows, are not explicitly defined within the provided context. It's inferred that FlowCreate is a Pydantic model used to validate and create new Flow objects from incoming request data, and user_id is a field that is either part of the FlowCreate model or is expected to be set on it before creating a Flow object in the database.

The FlowUpdate object, used for updating existing flows, has an optional structure with no required fields. You can find its definition in the model.py file.

To authenticate and use the flows_router endpoints, a user must be authenticated through the ProtectedRoute component. This is evident from the code snippet where the FlowPage and ViewPage components, which are likely part of the flows_router endpoints given their paths (/flow/:id/ and /flow/:id/view), are wrapped in the <ProtectedRoute> component. This indicates that access to these routes requires passing the authentication checks implemented in ProtectedRoute. You can find this in the routes.tsx file.

I hope this information helps! If you have any more questions or need further clarification, feel free to ask.

Sources

#### About Dosu This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot.
anovazzi1 commented 3 days ago

Currently, you can't create components only with the API, but you can create the flow and override the parameters for each component using the API.