Skip to content

Commit

Permalink
add bundles on endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristhianzl committed Oct 24, 2024
1 parent 5be41ae commit ae5d31a
Show file tree
Hide file tree
Showing 71 changed files with 155 additions and 38 deletions.
10 changes: 5 additions & 5 deletions src/backend/base/langflow/api/v1/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
CustomComponentResponse,
InputValueRequest,
RunResponse,
SidebarCategoriesResponse,
SidebarComponentsResponse,
SimplifiedAPIRequest,
TaskStatusResponse,
UpdateCustomComponentRequest,
Expand Down Expand Up @@ -46,7 +46,7 @@
get_telemetry_service,
)
from langflow.services.telemetry.schema import RunPayload
from langflow.utils.constants import SIDEBAR_CATEGORIES
from langflow.utils.constants import SIDEBAR_BUNDLES, SIDEBAR_CATEGORIES
from langflow.utils.version import get_version_info

if TYPE_CHECKING:
Expand Down Expand Up @@ -634,6 +634,6 @@ def get_config():
raise HTTPException(status_code=500, detail=str(exc)) from exc


@router.get("/sidebar_categories")
def get_sidebar_categories() -> SidebarCategoriesResponse:
return SidebarCategoriesResponse(categories=SIDEBAR_CATEGORIES)
@router.get("/sidebar_components")
async def get_sidebar_components() -> SidebarComponentsResponse:
return SidebarComponentsResponse(categories=SIDEBAR_CATEGORIES, bundles=SIDEBAR_BUNDLES)
8 changes: 4 additions & 4 deletions src/backend/base/langflow/api/v1/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,12 @@ class ConfigResponse(BaseModel):
max_file_size_upload: int


class SidebarCategory(BaseModel):
class SidebarComponents(BaseModel):
display_name: str
name: str
icon: str
beta: bool = False


class SidebarCategoriesResponse(BaseModel):
categories: list[SidebarCategory]
class SidebarComponentsResponse(BaseModel):
categories: list[SidebarComponents]
bundles: list[SidebarComponents]
11 changes: 11 additions & 0 deletions src/backend/base/langflow/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,14 @@ def python_function(text: str) -> str:
{"display_name": "Toolkits", "name": "toolkits", "icon": "Package2"},
{"display_name": "Tools", "name": "tools", "icon": "Hammer"},
]

SIDEBAR_BUNDLES = [
{"display_name": "NVIDIA", "name": "nvidia_bundle", "icon": "NvidiaIcon"},
{"display_name": "Assembly AI", "name": "assemblyai_bundle", "icon": "AssemblyAIIcon"},
{"display_name": "Google", "name": "google_bundle", "icon": "GoogleIcon"},
{"display_name": "DataStax", "name": "datastax_bundle", "icon": "DataStaxIcon"},
{"display_name": "Notion", "name": "notion_bundle", "icon": "NotionIcon"},
{"display_name": "Anthropic", "name": "anthropic_bundle", "icon": "AnthropicIcon"},
{"display_name": "Cohere", "name": "cohere_bundle", "icon": "CohereIcon"},
{"display_name": "LangChain", "name": "langchain_bundle", "icon": "LangChainIcon"},
]
10 changes: 5 additions & 5 deletions src/backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
from dotenv import load_dotenv
from fastapi.testclient import TestClient
from httpx import ASGITransport, AsyncClient
from loguru import logger
from sqlmodel import Session, SQLModel, create_engine, select
from sqlmodel.pool import StaticPool
from typer.testing import CliRunner

from langflow.components.inputs import ChatInput
from langflow.graph import Graph
from langflow.initial_setup.setup import STARTER_FOLDER_NAME
Expand All @@ -27,11 +32,6 @@
from langflow.services.database.models.vertex_builds.crud import delete_vertex_builds_by_flow_id
from langflow.services.database.utils import session_getter
from langflow.services.deps import get_db_service
from loguru import logger
from sqlmodel import Session, SQLModel, create_engine, select
from sqlmodel.pool import StaticPool
from typer.testing import CliRunner

from tests.api_keys import get_openai_api_key

if TYPE_CHECKING:

Check failure on line 37 in src/backend/tests/conftest.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.12)

Ruff (I001)

src/backend/tests/conftest.py:1:1: I001 Import block is un-sorted or un-formatted
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from langflow.schema.message import Message

from langflow.schema.message import Message
from tests.api_keys import get_openai_api_key
from tests.integration.utils import download_flow_from_github, run_json_flow

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import pytest
from astrapy.db import AstraDB
from langchain_core.documents import Document

from langflow.components.embeddings import OpenAIEmbeddingsComponent
from langflow.components.vectorstores import AstraVectorStoreComponent
from langflow.schema.data import Data

from tests.api_keys import get_astradb_api_endpoint, get_astradb_application_token, get_openai_api_key
from tests.integration.components.mock_components import TextToData
from tests.integration.utils import ComponentInputHandle, run_single_component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from langflow.components.helpers import ParseJSONDataComponent
from langflow.components.inputs import ChatInput
from langflow.schema import Data

from tests.integration.components.mock_components import TextToData
from tests.integration.utils import ComponentInputHandle, run_single_component

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from langflow.components.inputs import ChatInput
from langflow.memory import get_messages
from langflow.schema.message import Message

from tests.integration.utils import run_single_component


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from langflow.components.inputs import TextInputComponent
from langflow.schema.message import Message

from tests.integration.utils import run_single_component


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os

import pytest

from langflow.components.models import OpenAIModelComponent
from langflow.components.output_parsers import OutputParserComponent
from langflow.components.prompts import PromptComponent

from tests.integration.utils import ComponentInputHandle, run_single_component


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from langflow.components.outputs import ChatOutput
from langflow.memory import get_messages
from langflow.schema.message import Message

from tests.integration.utils import run_single_component


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from langflow.components.outputs import TextOutputComponent
from langflow.schema.message import Message

from tests.integration.utils import run_single_component


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from langflow.components.prompts import PromptComponent
from langflow.schema.message import Message

from tests.integration.utils import run_single_component


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pytest

from langflow.components.inputs import ChatInput
from langflow.components.outputs import ChatOutput
from langflow.components.prompts import PromptComponent
from langflow.graph import Graph
from langflow.schema.message import Message

from tests.integration.utils import run_flow


Expand Down
1 change: 1 addition & 0 deletions src/backend/tests/integration/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
from fastapi import status
from fastapi.testclient import TestClient

from langflow.graph.schema import RunOutputs
from langflow.initial_setup.setup import load_starter_projects
from langflow.load import run_flow_from_json
Expand Down
1 change: 1 addition & 0 deletions src/backend/tests/integration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import requests
from astrapy.admin import parse_api_endpoint

from langflow.api.v1.schemas import InputValueRequest
from langflow.custom import Component
from langflow.field_typing import Embeddings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

import pytest

from langflow.base.tools.component_tool import ComponentToolkit
from langflow.components.agents import ToolCallingAgentComponent
from langflow.components.inputs import ChatInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import pytest
from langchain_core.language_models import BaseLanguageModel
from langflow.components.helpers.structured_output import StructuredOutputComponent
from langflow.schema.data import Data
from pydantic import BaseModel
from typing_extensions import override

from langflow.components.helpers.structured_output import StructuredOutputComponent
from langflow.schema.data import Data


class TestStructuredOutputComponent:
# Ensure that the structured output is successfully generated with the correct BaseModel instance returned by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest
from langchain_community.chat_models import ChatOllama

from langflow.components.models import ChatOllamaComponent


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from langflow.components.prototypes import CreateDataComponent
from langflow.schema import Data

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from langflow.components.prototypes import UpdateDataComponent
from langflow.schema import Data

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from langflow.components.agents import CrewAIAgentComponent, ToolCallingAgentComponent
from langflow.components.helpers import SequentialTaskComponent
from langflow.components.inputs import ChatInput
Expand Down
1 change: 1 addition & 0 deletions src/backend/tests/unit/events/test_event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import uuid

import pytest

from langflow.events.event_manager import EventManager
from langflow.schema.log import LoggableType

Expand Down
1 change: 1 addition & 0 deletions src/backend/tests/unit/graph/edge/test_edge_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from langflow.components.inputs import ChatInput
from langflow.components.models import OpenAIModelComponent
from langflow.components.outputs import ChatOutput
Expand Down
3 changes: 2 additions & 1 deletion src/backend/tests/unit/graph/graph/state/test_state_model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pytest
from pydantic import Field

from langflow.components.inputs import ChatInput
from langflow.components.outputs import ChatOutput
from langflow.graph import Graph
from langflow.graph.graph.constants import Finish
from langflow.graph.state.model import create_state_model
from langflow.template.field.base import UNDEFINED
from pydantic import Field


@pytest.fixture
Expand Down
1 change: 1 addition & 0 deletions src/backend/tests/unit/graph/graph/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import deque

import pytest

from langflow.components.agents import ToolCallingAgentComponent
from langflow.components.inputs import ChatInput
from langflow.components.outputs import ChatOutput, TextOutputComponent
Expand Down
1 change: 1 addition & 0 deletions src/backend/tests/unit/graph/graph/test_cycles.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

import pytest

from langflow.components.inputs import ChatInput
from langflow.components.models import OpenAIModelComponent
from langflow.components.outputs import ChatOutput, TextOutputComponent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import TYPE_CHECKING

import pytest

from langflow.components.helpers import MemoryComponent
from langflow.components.inputs import ChatInput
from langflow.components.models import OpenAIModelComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import TYPE_CHECKING

import pytest

from langflow.graph.graph.runnable_vertices_manager import RunnableVerticesManager

if TYPE_CHECKING:
Expand Down
1 change: 1 addition & 0 deletions src/backend/tests/unit/graph/graph/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy

import pytest

from langflow.graph.graph import utils


Expand Down
1 change: 1 addition & 0 deletions src/backend/tests/unit/graph/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json

import pytest

from langflow.graph import Graph
from langflow.graph.graph.utils import (
find_last_node,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from typing import Any

import pytest
from langflow.helpers.base_model import build_model_from_schema
from pydantic import BaseModel
from pydantic_core import PydanticUndefined

from langflow.helpers.base_model import build_model_from_schema


class TestBuildModelFromSchema:
# Successfully creates a Pydantic model from a valid schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import TYPE_CHECKING

import pytest

from langflow.components.helpers import MemoryComponent
from langflow.components.inputs import ChatInput
from langflow.components.models import OpenAIModelComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from textwrap import dedent

import pytest

from langflow.components.data import FileComponent
from langflow.components.embeddings import OpenAIEmbeddingsComponent
from langflow.components.helpers import ParseDataComponent, SplitTextComponent
Expand Down
3 changes: 2 additions & 1 deletion src/backend/tests/unit/inputs/test_inputs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import pytest
from pydantic import ValidationError

from langflow.inputs.inputs import (
BoolInput,
CodeInput,
Expand All @@ -22,7 +24,6 @@
)
from langflow.inputs.utils import instantiate_input
from langflow.schema.message import Message
from pydantic import ValidationError


def test_table_input_valid():
Expand Down
1 change: 1 addition & 0 deletions src/backend/tests/unit/io/test_io_schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import TYPE_CHECKING, Literal

import pytest

from langflow.components.inputs import ChatInput

if TYPE_CHECKING:
Expand Down
1 change: 1 addition & 0 deletions src/backend/tests/unit/io/test_table_schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by qodo Gen

import pytest

from langflow.schema.table import Column, FormatterType


Expand Down
1 change: 1 addition & 0 deletions src/backend/tests/unit/schema/test_schema_message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from langchain_core.prompts.chat import ChatPromptTemplate

from langflow.schema.message import Message


Expand Down
Loading

0 comments on commit ae5d31a

Please sign in to comment.